Your traffic is shifting from single-turn chat to agents: 20 to 50 model calls per task, tool calls in between, sessions lasting tens of minutes. What does that do to your serving design?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
It changes what you are optimising for, from per-token latency to task completion time and cost per task.
Full worked answer
It changes what you are optimising for, from per-token latency to task completion time and cost per task.
Prefix reuse stops being an optimisation and becomes the economics. Every step resends the whole trajectory, so cumulative input tokens grow roughly quadratically with step count. Without prefix caching you re-prefill the entire history each step; with it you prefill only the delta. That makes context discipline a serving concern: append-only history, never reorder or edit earlier turns, stable tool definitions, and nothing volatile near the front of the prompt. Pair it with cache-aware routing or session affinity, otherwise the cache exists but nobody hits it.
Idle gaps. Tool calls take anywhere from ~100 ms to seconds, during which the session's KV sits there earning nothing. Retain it (memory pressure, fewer concurrent sessions) or drop it (re-prefill on return)? This is the natural home for a KV offload tier: evict to host memory on a tool-call boundary, reload on return, which is cheap because host bandwidth vastly exceeds prefill throughput.
Burstier queueing. Sub-agents fan out in parallel and then go quiet, so arrivals are correlated rather than Poisson. Your P99 will be worse than the average-rate arithmetic predicts, and capacity sized on mean QPS will miss.
Latency budget per step. Thirty steps at two seconds is a minute. That is fine if you stream progress, but the SLO you defend is task completion time, and the metric split you need is model latency versus tool latency, because it is often the tools.
Lifecycle. A user cancelling a task must kill in-flight generations and pending tool calls; long tasks need durable server-side execution rather than living on one HTTP connection. Background agents should be preemptible and backfill the interactive pool's trough, in a separate priority class, or one batch job will wreck chat P99.
Guardrails. Cap steps and total tokens per task. An agent loop without a budget is an unbounded cost incident waiting for a bad Tuesday.
Metrics: tokens per task, cache hit rate per step, model vs tool latency split, steps to completion, task success rate.
What a good answer covers
- It changes what you are optimising for, from per-token latency to task completion time and cost per task
- Prefix reuse stops being an optimisation and becomes the economics
- Every step resends the whole trajectory, so cumulative input tokens grow roughly quadratically with step…
- Without prefix caching you re-prefill the entire history each step; with it you prefill only the delta
- That makes context discipline a serving concern
Key terms: Idle gaps · Burstier queueing · Latency budget per step · Lifecycle · Guardrails
In the glossary: Prefix caching · Prefill · Tool call · SLO · Guardrails
Interviewer follow-ups to expect
Why is input token growth in an agent loop roughly quadratic in steps, and what would you change to flatten it?
Make the case for and against keeping session KV resident during a 5-second tool call.
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep