BACK TO INTERVIEW BANK
cost-latencysenior

How do you reduce agent latency?

Answer

Agent latency is dominated by the number of sequential model calls, since each is a full round trip and they cannot overlap when each depends on the last.

Reduce iterations. The dominant factor. Better tool design does this: a tool that answers the question in one call removes three exploratory calls. Clearer instructions reduce wrong turns that cost a full cycle each.

Parallelise independent tool calls. Models can request several at once. If they do not depend on each other, execute concurrently. Reading four files sequentially is four waits.

Stream the response. Does not reduce total time, and substantially reduces perceived time. For anything user facing this is among the highest value changes.

Use prompt caching. Cached prefixes are processed faster as well as cheaper, so it helps both dimensions.

Route small steps to faster models. A fast model handling mechanical steps in the loop can cut total wall clock meaningfully.

Move work off the critical path. If something can happen after you respond, do it then.

What you cannot fix: the model's generation speed for a given output length, and the inherent serialisation of a loop where each step depends on the previous result. Beyond a point the honest answer is that the task takes that long, and the interface should set expectations rather than pretend otherwise.

Common wrong answer

Adding parallelism to steps that are actually dependent. Running the edit before the file has been read produces a wrong result faster. Parallelism only applies to genuinely independent calls, and misidentifying that is a correctness bug rather than a performance win.

Likely follow-ups

  • What can you not fix?
  • How do you make waiting tolerable?