TL;DR: Cost per task is steps times what each step reads and writes. Input tokens dominate, because every step re-reads the whole transcript, so a run's input bill grows with the square of its length; output tokens are few but priced several times higher per token, and thinking tokens are output. Latency follows the same chain: steps times the time per model call plus tool time. So the first cut is steps the task does not need, the second is context the model re-reads every turn, the third is tools that cause retries, then caching the stable prefix, then a cheaper model for easy steps. Changing the model is the last rung, not the first.
How to approach it
Build the chain on the board with illustrative numbers and show where the total comes from. Then put latency beside it. Then give the order of cuts and say why that order: cheapest to try and to undo first, each measured on the same tasks. Interviewers ask this to see whether you reach for the model switch before you have looked at a trace.
A strong answer
One run, illustrative, with relative prices so the shape is the point (Optimise an Agent in the Right Order):
steps 24 model calls
stable prefix 5,000 tokens (instructions + 30 tool definitions)
transcript growth 1,800 tokens per step (call + result)
output per step 150 tokens; 400 on the 6 steps that reason
input tokens on step n 5,000 + 1,800 n
input over the run 24 * 5,000 + 1,800 * (1 + 2 + ... + 24)
= 120,000 + 1,800 * 300 = 660,000
output over the run 18 * 150 + 6 * 400 = 5,100
price (illustrative) input 1 unit per 1,000 tokens
output 5 units per 1,000 tokens
cached input 0.1 unit per 1,000 tokens
cost, no cache 660 + 25.5 = 685.5 units
cost, prefix cached prefix: 24 * 5,000 = 120,000 -> 12 units
rest: 540,000 -> 540 units
total: 552 + 25.5 = 577.5 units
Two things stand out. Input is 96 percent of the bill, and most of it is the transcript being re-read: the triangular sum, 1,800 times 300, is 540,000 of the 660,000 input tokens. The prefix cache saves a sixth; it cannot touch the transcript because the transcript changes every step. Output, including reasoning tokens, is small in count but five times the price, which is why "set reasoning effort high everywhere" shows up on the bill out of proportion to its token count.
Latency follows the same structure:
per step model call 2.5 s + tool 0.8 s (average) = 3.3 s
run 24 * 3.3 = 79 s
Steps multiply everything. A run that needs 12 steps instead of 24 roughly halves both the time and the bill, and because the triangular sum shrinks faster than linearly, the input cost falls by more than half.
So the order of cuts is the order of effect per unit of risk:
| Rung | Cut | Why first | How to see it in the trace |
|---|---|---|---|
| 1 | Steps the task does not need | Every step carries the whole transcript | Repeated reads, a tool call then a second to confirm it, planning steps that change nothing |
| 2 | Context re-read every turn | The triangular sum | An 8,000-token tool result left in place for 20 steps |
| 3 | Tools that cause retries | Each retry is a step | Schema errors, vague descriptions, results the model cannot parse |
| 4 | Cache the stable prefix | Free once the prefix is stable | Cached-token count near zero on steps after the first |
| 5 | Route easy steps to a cheaper model | Most steps are routine | File picks and formatting running on the largest model |
| 6 | Optimise prompts against a metric | Changes behaviour, needs an eval set | Only after the set exists |
| 7 | Fine-tune or train | Expensive, slow to undo, needs a stable task and grader | When the rungs above are exhausted and the task is stable |
Each rung is cheaper to try and to undo than the one below it, and each is measured the same way: the same task set, repeated runs, cost and pass rate side by side, before and after. Cutting steps that lowered the pass rate is not an optimisation.
Authority line: the harness owns the budget. The model does not know what a step costs or how many it has used; the harness counts tokens and time against the task's budget and ends the run, and that budget is where the optimisation target is written down.
What interviewers probe next
"The model is 60 percent of the cost. Why not switch to a cheaper one first?" Because the cheaper model inside the same wasteful loop re-reads the same bloated transcript and may need more steps to finish, and you cannot measure that until the steps and context are fixed. Fix the loop, then test the switch on the same tasks.
"The prefix cache rate is low. Why?" Something near the front of the prompt changes per step or per run: a timestamp, a user name in the system prompt, tool definitions in a different order. Make the prefix byte-stable and watch the cached-token count on step two.
"How do you cut latency without cutting steps?" Run independent read calls in parallel in one step, stream the model's output so the user sees progress, and move slow tools to a cheaper check-then-fetch. Steps are still the biggest lever.
How it's scored
Weak: Proposes a cheaper model or a shorter prompt with no chain showing where the cost is.
Hire: Chains cost from steps and context, shows input dominates through the triangular sum, puts latency on the same chain, and cuts steps and context before the model.
Strong Hire: Also prices output and reasoning tokens separately, reads the cache rate as a diagnostic, measures every rung on the same tasks with pass rate beside cost, and keeps the budget with the harness.
Common mistakes
- Switching models before reading a trace.
- Counting tokens per call instead of per run, and missing the triangular growth.
- Leaving large tool results in the transcript.
- A system prompt with a timestamp, so the cache never hits.
- Optimising cost without checking that the pass rate held.