Ask an agent how many commits landed across every open pull request in a repository. It pages through the API, reads every result, and answers with confidence: "276." The right answer is 278. Every call it made returned correct data. No tool failed, and nothing in the logs looks wrong. The agent had all the numbers. It just added them up in its head, and got the sum wrong.
If your agent reports totals, counts or rankings (revenue by region, refunds per customer, incidents per team), this is the bug that ships. It passes the demo at 20 rows and quietly breaks at 200. The wrong number arrives in the same confident sentence as a right one, so nobody checks it until a customer does.
We measured how often it happens and what fixes it. When our agent fetched data turn by turn and did the arithmetic itself, it was right in 8 of 8 attempts at 20 items and 4 of 8 at 200, while its token bill grew almost fivefold. When it could write a short script that did the arithmetic outside its context, it was right in 71 of 72 attempts, at a flat cost.
Same model, same tasks. The interface decided whether the sum was right.
Same agent, two ways to hold the data
How do you total 200 failed card charges by currency? A person opens a spreadsheet and types SUM. An agent with only API tools has a harder job. It fetches the charges a page at a time, keeps every page in its context, and does the sum in its head.
We tested this on Neurouter, an open-source MCP gateway. It sits between an agent and the APIs it calls, so we could change the interface without touching the agent. It offers the same API in two shapes:
- Tool mode. Each API operation is a tool. The agent makes one call per step, and every result lands in its context.
- Code mode. The agent looks up typed function signatures and writes a short Python script. The script runs in a sandbox, loops and sums there, and hands back only the final value.
The agent was gpt-6-luna in both modes. The APIs were deterministic mocks of GitHub and Stripe, built from their public specs. We wrote 4 long tasks per API, such as failed-charge totals per currency, refund totals per charge and commits across every open pull request. Each ran with 20, 100 and 200 items in the mock data. Code mode ran each cell 3 times and tool mode once: 96 attempts, all checked against exact ground truth.
At 20 items both modes got every answer right. Past that, they part ways on both panels: tool mode costs more and gets less reliable, while code mode barely moves.
At 20 items the two interfaces look identical. That's why the demo passes.
Four things we learned
- The data was right. The sum was wrong.
- In tool mode, cost grows with the data. In code mode, it doesn't.
- Long tasks ran out of room before they ran out of work.
- A sandbox you never need proves nothing.
1. The data was right. The sum was wrong.
The agent paged through every charge correctly, then reported AUD 693,300. The right total was 778,700.
That line comes from an earlier probe of 12 attempts, one per cell, on one Stripe task and one GitHub task. In tool mode the agent got the Stripe sums wrong at both 100 and 200 items:
| Items | Currency | Reported | Correct |
|---|---|---|---|
| 100 | AUD | 435,300 | 563,500 |
| 200 | AUD | 693,300 | 778,700 |
| 200 | JPY | 375,550 | 571,450 |
We then summed the pages the agent had actually received. They added up to the ground truth exactly, in every currency. The agent had paged correctly and seen every charge. Its mistakes came from adding 20–57 amounts inside its own context. Code mode did the same sums in the sandbox and was exact at every size.
The larger run showed the same pattern. Tool mode gave 3 wrong answers, all at 100 or 200 items. The errors were small and confident:
- 13 delinquent customers in USD, where the truth was 14;
- two wrong charge ids and mis-added refund totals in a top-5 list;
- "276" commits across 90 open pull requests, where the truth was 278.
For the refund list and the commit count, we recomputed the answer from the tool results in the transcript. Both add up to the ground truth. Code mode gave no wrong answers in 72 attempts. Its one failure was a dropped network connection 6.5 seconds in, after a single search.
The Guide has names for what's going on. An agent reads every token a tool returns, with no skimming, which the Guide calls literal exhaustive readingLexicon · 10Literal Exhaustive ReadingIngesting every returned token without human visual skimming.. As those pages pile up, the context fills with material the agent must keep straight. The Guide's name for reasoning that blurs as that material accumulates is attention entropyLexicon · 15Attention EntropyProgressive reasoning degradation as session debris and noise accumulate.. A sum is the worst case: every one of those numbers matters, and the model has to hold them all at once.
These errors are also easy to miss. In a still earlier probe, tool mode reported a EUR total of 1,171,050 against a true 1,211,050. Our grader asked an LLM judge whether the two answers were equivalent, and it said yes on both votes. Since then, exact numbers and ids must match exactly, and the judge can't overrule them. We caught the miss only by checking answers against the transcripts and the ground truth, a habit the Guide calls trace reviewLexicon · 52Trace ReviewInspecting reasoning and tool logs to uncover interface friction..
A model can fetch the right data and still report the wrong total. Don't make it do arithmetic in its head.
2. In tool mode, cost grows with the data. In code mode, it doesn't.
At 200 items, tool mode cost 8.7 times as much per attempt, and was still wrong more often.
| Items | Code mode, tokens per attempt | Tool mode, tokens per attempt |
|---|---|---|
| 20 | 13.5k | 30.7k |
| 100 | 18.4k | 78.4k |
| 200 | 16.8k | 146.3k |
Tool mode grew 4.8 times from 20 to 200 items. Almost all of that growth was cached input, because each turn re-sends the whole conversation, every page included. Code mode stayed between 13.5k and 18.4k at every size. The pages never entered the context. Only the script and its answer did.
That is the difference in observation yieldLexicon · 25Observation YieldUseful, decision-relevant signal per token returned by a tool., the useful, decision-relevant signal a tool returns per token. Two hundred raw charges are a low-yield way to answer a question whose answer is eight totals. The script's result is those eight totals. H-03 Token Hygiene & High Observation Yield asks for exactly this: a summary and a pointer, not a firehose the agent has to read in full.
Trips grew too. In the 12-attempt probe, at 200 items on GitHub, code mode ran 90 API calls inside one script and finished in 5 turns and 23.8k tokens. Tool mode made 99 tool calls over 17 turns and used 193.8k tokens, 97% of its limit. Each of those turns is a full model pass over a growing context, a cost the Guide calls the round-trip taxLexicon · 39Round-Trip TaxTurn latency and overhead from chaining overly atomic tool calls..
Tokens are a side effect. The real cost is every intermediate result passing through the model.
3. Long tasks ran out of room before they ran out of work
Three tool-mode attempts paged through 10 pages, hit the token limit and never answered.
Each attempt had a ceiling of 200k tokens. Half of tool mode's 6 failures were not wrong answers at all. At 200 items, 3 Stripe attempts stopped at the limit after reading 10 pages of 20 items each. None of them got as far as an answer.
The mismatch underneath is one of granularity. The agent thinks in tasks: "total the failed charges per currency." The tools offer one page of charges at a time. The Guide calls the gap between the size of the steps an agent thinks in and the size of the steps its tools allow semantic impedanceLexicon · 34Semantic ImpedanceMismatch between the granularity of agent reasoning and available actions.. In tool mode, the agent pays for that gap with its context window. In code mode, the loop pays for it, on the computer's side.
When every step costs context, a long enough task simply doesn't fit.
4. A sandbox you never need proves nothing
238 scripts. One
forloop. Nowhileloops at all.
Before these long workflows, our suites held short tasks of one to four calls. There, both modes were near the ceiling on success, and code mode won on tokens alone. When we looked at what the scripts did, 238 of them used for once and while never. Most were one or two straight-line calls and a filter. On long workflows, the same agent wrote paging loops and fan-outs of up to 90 calls in one script.
The short suites hadn't been wrong. They just never asked for what a programmable interface is for. We'll come back to what that taught us about our own tests.
An eval that never needs a loop can't show you the value of one.
What this doesn't show
- Small samples. Tool mode ran once per cell: 8 attempts per size, with no confidence intervals. Read its fall from 8/8 to 4/8 as a direction, backed by two independent runs, not as a rate.
- One strong model. Every attempt used
gpt-6-luna. We did not test weaker models, and these results may not hold for them. - Mock APIs. The mocks are deterministic and follow the public specs, but they are simpler than the real services.
- Corrected checks. Two of the 8 tasks had checks that asked for a value the prompt didn't. We fixed them after the run and re-graded the same answers. 15 attempts flipped to pass and none to fail. As run, the scores were 59/72 for code mode and 15/24 for tool mode.
What changes
- Compute on the computer's side. Let agents filter, batch and compute where the data lives, through a sandbox, a query language or plain server-side totals. Then the model never adds a column of numbers.
- Ship totals with the records. If a tool has to hand back many records, also hand back the count and the totals it already knows.
- Check numbers exactly. An LLM judge that accepts "close enough" will hide this whole class of error. Compare amounts and ids as values.
- Test at the size of real work. At 20 items the two modes looked the same. The difference showed from 100 items up.
- Read the transcripts. Recompute wrong answers from what the agent actually saw. It tells you whether the fault is in the data or in the head.
Coming next: half our agent failures were our fault: broken tasks and graders that charged their mistakes to the agent.
Where to go from here
- Our Field Guide: Designing for Agents, our interface design principles for AI agents as users. Heuristics, a lexicon, and the trajectory map that ties them together.
- Our MCP server: the Field Guide for your agent. It can search the Guide, read any heuristic or term at the depth it needs, and follow the links between them.
- Our AX tool-design skill: an agent skill for designing and reviewing tools, MCP servers and APIs that agents use, against the Field Guide's heuristics.
Your agent can fetch every row. Just don't ask it to add them up.