TL;DR: Pull per-turn data from traces and split it four ways: input tokens (cached and uncached), output tokens, tool time and orchestration. Money almost always goes to input, which grows with the square of turn count, so the fixes are trimming tool results, clearing used ones, caching a stable prefix and cutting turns. Time usually goes to generation and to tools called in series, so the fixes are parallel independent calls, shorter outputs on intermediate steps and fewer turns. Rank fixes by measured share, then verify the saving and the quality.
How to approach it
Refuse to guess; describe how you would measure, what the breakdown usually shows for agents, and the fix for each component, ranked.
A strong answer
Measure from the trace. For a sample of runs: per turn, input tokens (cached and uncached), output tokens, model latency (time to first token and total), each tool call's duration, and time between steps. Sum per component across the run.
TURNS = [ # illustrative trace summary per turn
{"in": 8000 + 2500 * t, "cached": 0.0, "out": 300, "model_s": 6.0,
"tools_s": [1.2, 0.9, 1.5]}
for t in range(40)
]
def breakdown(turns, in_price=3.0, out_price=15.0):
cost_in = sum(t["in"] * (1 - t["cached"]) for t in turns) * in_price / 1e6
cost_out = sum(t["out"] for t in turns) * out_price / 1e6
model_s = sum(t["model_s"] for t in turns)
tools_s = sum(sum(t["tools_s"]) for t in turns)
return round(cost_in, 2), round(cost_out, 2), round(model_s), round(tools_s)
print(breakdown(TURNS)) # => (6.81, 0.18, 240, 144)
What it shows. Input is about $6.81 of about $7 per run, so output pricing is irrelevant to the bill. Of roughly 384 seconds, model calls take 240 (mostly generating 300 tokens a turn) and tools in series 144.
Fixes for dollars, ranked.
- Trim tool results at the source and clear used ones: shrinks the growth term that every later turn pays.
- Cache a stable prefix with append-only history: most input becomes cheap reads.
- Cut turns: better tool design (one call instead of three), budgets, stopping rules.
- Route routine steps to a smaller model, measured per step type.
Fixes for seconds, ranked.
- Run independent tool calls in parallel: 144 seconds of serial tool time could become about 60.
- Shorter intermediate outputs: the model does not need 300 tokens of narration between tool calls.
- Fewer turns: every turn removed saves both.
- Caching: lowers time to first token on long contexts.
Verify. Re-run the same tasks after each change and compare cost, time and quality, because trimming results or routing steps can remove information the model needed without any error to show it.
What interviewers probe next
"Would a faster model fix it?" It shortens generation time, a real share here, but leaves tools in series and input cost untouched. Pick it only if the measurement says generation dominates and quality holds.
"Where does orchestration overhead show up?" As gaps between spans in the trace: queueing, serialisation, cold starts. Usually small, occasionally a surprise worth checking.
"How do you keep it from regressing?" Cost and latency per task on the release dashboard and in the eval report, with alerts on step changes.
What if?
What if · interview follow-ups
Hold your answer as the constraints change
Traces show input tokens are 95% of cost and serial tools are a third of wall-clock.
Start here
What if caching is enabled but the cached share is near zero?
What breaks a prefix?
Something changes early in every request: a timestamp, reordered tools, unsorted JSON or edited history. Diff two consecutive requests to the first differing block and fix it.
Carry it forwardEnabled is not the same as working; measure the cached share.
Weak answerAssuming caching works because it is turned on.
Constraint changes
What if the three tools in each turn depend on each other?
Can they still be combined?
They cannot run in parallel, but a single tool that does the three steps server-side removes two round trips through the model, saving both time and tokens.
Carry it forwardSequential tool chains can become one tool.
Weak answerRunning dependent calls in parallel.
Constraint changes
What if a smaller model halves cost but quality drops 4 points on the main task?
Is it all or nothing?
Route by step type: keep the large model for planning and synthesis, use the small one for routine steps, and escalate on check failures. Measure each step type separately.
Carry it forwardRoute steps, not whole runs.
Weak answerSwitching the entire agent to the small model.
Now defend it
One-line answer?
Dollars go to resent input and seconds to generation and serial tools; measure per turn from traces, then trim and cache input, parallelise or merge tools, shorten intermediate outputs, cut turns and route routine steps.
How it's scored
Weak: Suggests a cheaper or faster model.
Hire: Identifies input tokens as the main cost and adds caching and result trimming.
Strong Hire: Measures per-turn components from traces, explains the quadratic input growth, ranks separate fixes for cost and time, includes parallel and merged tools and shorter intermediate outputs, routes by step type, and verifies quality after each change.
Common mistakes
- Optimising output price for an input-dominated bill.
- Turning on caching without checking the cached share.
- Shrinking tool results without re-measuring quality.
- Treating latency and cost as one problem with one fix.