Anthropic has slipped an experiment into Claude Code that could cut the bill for running software agents. Code Mode, off by default in version 2.1.323 and above, keeps the same model but changes who organises the loop. Third-party tests show real API bills falling 22 to 23 per cent, and tokens processed dropping 62 to 77 per cent when agents call external tools heavily.

Why agents burned cash
In the normal mode, Claude calls tools directly. It searches with Bash, reads a file, then edits it, and if a step depends on the previous result the tool output returns to the model before it decides what to do next. Two hidden costs inflate the context. Independent evaluator bestagent.dev found that Claude Code sends 16 built-in tool definitions each round, about 38,000 tokens in the first request alone, repeated every turn for the rest of the session. The second cost sits in the middle of a run. A tool may return hundreds of records when only a few lines matter, but every raw line stays in the history. In benchmark Bicameral’s test, pulling 120 support tickets through an MCP connector forced all 120 into context.


Let the code loop
Code Mode lets Claude write a piece of JavaScript that groups tool calls, conditions, loops and filtering into one script. Steps that need no step-by-step model decision run continuously, and only the necessary result returns to the model. Anthropic’s own example is finding a configuration file, changing a retry count from three to five and running tests. Previously that meant four round trips. Now Claude writes a small script that does the whole sequence locally and reports only which file changed and whether the tests passed. The model-facing tool list shrinks from 16 definitions to three core entry points. bestagent.dev measured the first request falling from about 38,000 tokens to 22,000. Bicameral measured a fixed reduction of roughly 13,100 tokens per round across four models.
Strong models win, weak ones stumble
Bicameral ran 96 trials on Claude Code, comparing four models across six tasks. In the heaviest case, pulling 120 tickets and summing refunds, context growth collapsed from about 54,000 tokens to 3,500 to 8,800, a fall of 84 to 94 per cent, and total tokens processed dropped 62 to 77 per cent with all 16 runs correct. On duplicate-charge review, token use fell 40 to 68 per cent, though three failures all came from the weaker Haiku model.
Ordinary file work is less dramatic. Looking for broken links across 47 Markdown files or renaming a function across 36 call sites, 14 of 16 comparisons produced more conversational content, because writing and debugging the script costs tokens. The fixed saving on tool definitions still left Opus, Sonnet and Fable 15 to 54 per cent lower overall. Haiku’s token use rose 9 per cent after one script picked the wrong directory and its error logs ate the saving. bestagent.dev, pricing against Anthropic’s API, found a CLI task falling from USD 0.45 to 0.35 and a dead-link check from USD 0.20 to 0.16. The report also warns that tokens processed are not the same as the bill, since much of the saving is cached prompt text already charged at a lower rate.
Why leave it switched off
Security is the first reason. In normal mode every read and command can be checked individually, and enterprise monitoring keeps a clear record. In Code Mode a chain of actions is packed into one script, and the safety classifier can only scan the block as a whole. Anthropic ignores project-level toggles to prevent a cloned repository from enabling the feature, and refuses to start it if enterprise telemetry export is on or telemetry is disabled. The feature also runs only in a local interactive terminal on a direct Anthropic subscription or console account. Desktop, VS Code, Amazon Bedrock and Google Cloud are excluded, and remote control, Chrome integration and computer use stop working when it is on.
The wider point is that the model did not change. Getting the harness right, deciding who runs the loop and where intermediate data lives, still extracted more than a fifth of real cost from a mature client.
Editor’s note: This is an adapted translation of the original 36Kr report. It has been trimmed and restructured for readability for an international business audience. The full original (in Chinese) is at https://m.36kr.com/p/4075148096066440.