Engineering

How we cut first-token latency to 310 ms

Speculative decoding, warm pools and a lot of profiling. Here is every change that took our median first token from 820 ms to 310 ms, and the two ideas that did not work.

Isometric line drawing of an address bar connected to a DNS record box with A and CNAME rows and a wireframe globe

Six months ago our agents took 820 ms on average before they said their first word. For a chat window that feels slow; for a voice agent it feels broken. We set ourselves a target of 300 ms and spent a quarter getting there. This post walks through what moved the number and what did not.

Start with a real profile

Our first instinct was to blame the model. The traces said otherwise. Almost 40 percent of the wait happened before a single token was generated: loading tools, fetching memory and building a prompt that had grown to 14,000 tokens. We moved tool schemas into a cache keyed by agent version and cut the prompt by a third by sending only the tools an agent had used in its last thousand runs.

Warm pools beat cold starts

Every new conversation used to start a fresh worker. Workers now stay warm for ten minutes after their last request, and a small pool is always ready for each region. Cold starts dropped from one in six requests to one in two hundred.

Speculative decoding, carefully

A small draft model now proposes the next few tokens and the large model checks them in one pass. On short replies the gain is modest. On long tool-calling turns it saves up to 180 ms, because tool names and argument keys are easy to guess.

What did not work

Streaming partial tool calls to the client made the interface feel faster but confused two of our largest customers, whose integrations expected complete JSON. We rolled it back. Compressing the system prompt with a learned summary saved tokens but cost accuracy on long policies, so it stays off by default.

The median is now 310 ms and the 95th percentile is 690 ms. The next target is the tail, and we will write about that too.

More from the blog

Notes on keeping a personal library that stays useful.

Notes from the team on agents, evals and the work of shipping AI products people trust.

Get new posts by email.

One short email when we publish something new.

No spam. Unsubscribe in one click.

Start your personal context library.

A personal context library for Mac, iPhone and iPad. Local first, private by default.

Product

Download

iPhone and iPad

Browser extension

Company

Story

Support

Press kit

Legal

Privacy

Terms

Imprint

Shelfmark

© 2026 Shelfmark Software

Privacy

Terms

Cookies

Remix project

Create a free website with Framer, the website builder loved by startups, designers and agencies.