Why does an agent loop with 5 tool calls have ~6× the latency of a single completion and how do you mitigate?
An agent loop performs 5 sequential tool calls before final answer. Walk through where the latency comes from and explain why total wall-clock is ~6× a single completion. Identify three mitigations and what each costs.
An agent loop chains 6 model turns plus 5 tool round-trips, and context grows every turn, so prefill, decode, and network all stack into roughly 6x a single completion.
Imagine cooking a recipe where you must phone a friend after every step to ask what comes next. Each call has the same overhead: you read the whole recipe so far aloud, your friend thinks, you wait on the line, they answer, then you act. As the recipe grows, reading it aloud each time takes longer and longer. Five questions means six phone calls plus five waits for your friend to act, and every call re-reads more text than the last. The cooking itself is fast. The phone tag is what eats the clock. You speed it up by asking several independent questions in one call, by not re-reading the parts your friend already heard, and by starting the next step before they finish replying when you are confident.
Detailed answer & concept explanation~8 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: decompose one round (decode, network, tool, prefill) + why prefill grows monotonically + the 6 turns 5 trips count + three mitigations each mapped to an axis + the cost of each.
Real products, models, and research that use this idea.
- Anthropic's Claude Opus 4.7 supports parallel tool calls in a single turn plus prompt caching that bills cached prefix tokens at roughly a tenth of normal input cost.
- OpenAI's GPT-5.5 function calling returns multiple tool calls per turn, letting the agent runtime fan them out concurrently.
- LangGraph and the OpenAI Agents SDK schedule independent tool calls in parallel and persist conversation state to keep prefixes cache-friendly.
- Cursor and similar coding agents speculatively pre-fetch file reads and run reads concurrently to hide tool latency during multi-step edits.
- vLLM and SGLang implement automatic prefix caching so a shared system prompt across agent turns skips re-prefill on the server side.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does prefill grow super-linearly across an agent loop rather than staying constant?
QWhat exactly must stay stable for prompt caching to hit across turns?
QWhen does speculative tool execution lose money instead of saving latency?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Blaming tool execution or the network for the latency while ignoring that the growing context forces a larger prefill on every single turn of the loop.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.