Agent Latency and the Critical Path
In this article
- Read an agent trace and find the critical path from the customer's request to the reply.
- Explain why steps that run side by side add up to more work than the run takes.
- Predict how much time a change can save before you make it, and spot a change that will save nothing.
- Confirm the change at p95 on the same traffic, and say why the mean can mislead.
- Terms defined here: critical path.
Overview
A customer types a question into a support chat and waits 12 seconds for the answer. The team looks at the model's dashboard and every call there takes a second or two. So where did the other seconds go, and which part should you make faster first?
In a made-up example, Brightline, a home-internet provider, runs a support assistant on its website, an agent: a program built on a language model, the AI that reads and writes text, that takes several steps on its own, such as calling tools, before it replies. It answers customers and can look up an order, issue a refund of at most $50 and hand a conversation to a person on the support team. One slow conversation with it is the case here: a customer asks about their last three orders.
By the end you can find the chain of steps that decides the total, predict what a fix will save before you build it, and check the result the way a skeptical reviewer would.
Where the twelve seconds go
The end-to-end latency is the whole wait for the reply. A run has more stages than one model call, and some of them happen at the same time, which changes what "largest" means.
Count from the moment the customer presses send, not from the moment your code calls the model. For Anthropic, latency is the time the model spends reading the prompt and producing its output. [4] That is one part of the customer's wait. In an agent you build, a run can also hold a queue wait before any work starts, your orchestration code between steps, several model calls, tool calls, a document search with a reranking step, and network hops between them all.
A queue wait is real time even though nothing useful happens in it. One cause is a rate limit: when an Anthropic API limit is exceeded, the call fails with a 429 error, and if the reply carries a retry-after header, the client should wait that many seconds before it tries again. [5]
The data for all of this is an agent trace. Each operation in it is a span, a timed log entry with a start time and an end time, and each span can point to a parent span that contains it. [2] Here the spans are given; how to collect them is its own piece of engineering.
In this made-up run the assistant works in a loop: the model reads the conversation and replies with requests to use tools, your code runs those tools, the results go back to the model, and the model is called again. The loop ends when the model writes the final reply.
The trace
Here is the made-up trace for the slow conversation, with times in seconds from the moment the customer pressed send. The invoke_agent span is the parent; the model calls and tool calls are its children. Read the start and end columns before you look at the last one.
| span | start | end | duration | on the critical path |
|---|---|---|---|---|
| queue wait | 0 | 3 | 3 | yes |
invoke_agent (parent) | 3 | 12 | 9 | contains the rest |
| model call 1: decide to look up the last three orders | 3 | 5 | 2 | yes |
lookup_order A | 5 | 7 | 2 | no |
lookup_order B | 5 | 7 | 2 | no |
lookup_order C | 5 | 11 | 6 | yes |
| model call 2: write the reply | 11 | 12 | 1 | yes |
Now add the durations, leaving out the parent because it only wraps its children: 3 + 2 + 2 + 2 + 6 + 1 = 16 seconds of work, in a run that took 12. Read 16 as the latency and you count time nobody waited for.
The gap comes from the three lookups. Model call 1 asked for all three orders at once, and they ran side by side from second 5. Google's Agent Development Kit (ADK) works this way: three tools of 2 seconds each, run in parallel, take closer to 2 seconds in total than 6. [3] Running at the same time is a fan-out, and the step it makes ends only when its last child returns. Lookups A and B were done at second 7, but model call 2 needed all three results, so it waited for C until second 11.
The critical path
Walk backwards from the reply. Model call 2 ended at 12 and started at 11, when lookup C finished. C started at 5, when model call 1 finished. Model call 1 started at 3, when the queue wait ended. That chain, queue wait, model call 1, lookup C, model call 2, is 3 + 2 + 6 + 1 = 12 seconds, exactly the wait the customer felt.
That chain is the critical path: the longest line of steps in which each one waits for the one before. Its length is the run's latency. A step of parallel work sits on it for as long as its slowest child, and every other child of that step is off the path.
Predicting the gain
Before the numbers, make your own call: you can make one change. Which span do you fix?
The rule: the saving is the time a span spends on the critical path times the fraction of it you remove. A span off the path saves nothing. Here are four candidate changes.
| change | on the path? | predicted saving | share of 12 s |
|---|---|---|---|
| model call 1 made 40% faster | yes, 2 s | 0.8 s | 7% |
| lookup C cut from 6 s to 4 s | yes, 6 s | 2 s | 17% |
| lookup A made instant | no | 0 s | 0% |
| queue wait halved | yes, 3 s | 1.5 s | 13% |
Look at the row for lookup A. Making it instant sounds like a clear win, and the run still ends at second 12, because the step still waits for C. The saving on C has a limit too: once C drops below 2 seconds, A and B become the slowest children, so no cut to C can save more than 4 seconds.
The choice is lookup C, with a predicted new total of 12 − 2 = 10 seconds. Notice what the trace changed about "fix the largest stage". The model dashboard would have pointed you at model call 1, the slower of the two model calls. On the critical path, its fix is worth less than half of the lookup fix.
Checking at p95
A prediction is a claim about one trace, and real traffic is thousands of runs. So the check comes after the change, on the same traffic (the same requests replayed, or both versions over the same period), and reads p95: the percentile that 95 of every 100 runs finish within.
Brightline ships the faster lookup. On the same traffic, p95 was 12.0 seconds before and is 10.3 seconds after. The slow conversation was a typical p95 run: 12 seconds is where the slowest 5 in 100 start, and in this made-up traffic most of them waited on a slow lookup C. After the fix, some runs at p95 are ones where lookup A or B, or the queue, is now the slowest link, so p95 lands at 10.3 and not at the predicted 10.
Why p95 and not the mean? Because fan-out makes a tail. Suppose each lookup is slow one time in twenty. A run that does three lookups side by side waits for the slowest of three, so it hits at least one slow lookup about one run in seven (1 − 0.95 × 0.95 × 0.95 ≈ 0.14). Those runs sit at the slow end, where p95 looks. In a toy like this one, the mean blends them with the many fast runs, so it can barely move while the customers who wait longest see a large change.
Change one thing, measure, then decide on the next. Anthropic's latency cookbook works the same way: its notebook measures a sample agent, tries a single technique per step and confirms the answers stay good enough. [4] A faster lookup that returns a wrong order is not a win.
Common mistakes
- Fixing the span that is easiest to see. The model dashboard points at the model. Build the critical path first and price each change in seconds saved on it.
- Starting the clock at the model call. The queue wait in the trace is 3 of the 12 seconds, a quarter of the wait. A trace that starts at the agent span shows 9 seconds and hides it.
- Reading the sum of spans as the latency. Add durations only along one chain, never across parallel children.
- Averaging a fan-out. The three lookups average about 3.3 seconds, and the step lasts 6.
- Confirming with the mean. The slow runs that fan-out creates sit in the tail, and the mean hides them.
In production
Parallel tools only run in parallel if the framework can run them that way. In ADK, from version 1.10.0 for Python, tools must be asynchronous, and one synchronous tool in a set of calls blocks the others from running alongside it. [3] In a trace, the lookups then start one after another and the critical path holds all three.
A retry after a 429 adds the retry-after seconds to that run's path, and not every 429 carries the header. [5] Watch the queue span at p95 next to the model spans.
Sources
- Semantic Conventions for GenAI agent and framework spans (OpenTelemetry). OpenTelemetry. Checked 25 Oct 2026.
- Agents SDK: Tracing. OpenAI (openai-agents-python). Checked 24 Oct 2026.
- Increase tool performance with parallel execution (ADK docs). Google. Checked 25 Oct 2026.
- Reducing latency. Anthropic. Checked 24 Oct 2026.
- Rate limits. Anthropic. Checked 24 Oct 2026.
Check yourself
Check yourself
Question 1 of 13
You want the length of the wait a customer feels in one agent run. What do you measure?
Your first check counts towards your result.