Precompute what you can, and give a new message 2 seconds
Most of the work can happen before the agent opens the ticket.
| One ticket, over time | When the suggestion is computed |
|---|---|
| routed, then waiting in the queue | while it waits: ready when the agent opens it |
| the customer sends a new message | within a 2-second target, with the first cited step on screen and the rest streaming in |
Two moves take most of the latency off the agent's clock:
- Precompute. A ticket waits in a queue before an agent opens it. Compute the first suggestion then, so it's ready on arrival.
- Stream. Show the first cited step as soon as it's written. Order the output so each step streams with its citation.
That leaves the case you can't precompute: a new customer message mid-conversation.
Assume the target is the first cited step on screen within 2 seconds at p95, the time that 95 of every 100 requests finish within. Assume a mid-size cross-encoder costs about 3 ms per candidate on a GPU.
Slide the rerank count to 150, Anthropic's number, and watch the budget.
Rerank candidates: 3000 µs per item.
At 50 candidates the stages add up to 1,702 ms, with 298 ms to spare. At 150 the rerank takes 450 ms, and the total is 2,002, over by 2 ms.
The levers, cheapest first:
- Rerank fewer candidates.
- Use a smaller reranker.
- Shorten the prompt with fewer chunks and a trimmed conversation.
- Use a faster model for the first step.
Notice what's not on the list. The search itself, at 60 ms, is the smallest real stage.
In the editor, write total_ms(rerank_n) and max_rerank(budget_ms): the widget's budget as code. FIXED_MS holds the stages whose time doesn't depend on how many candidates you rerank.