Essential Insights
-
Code Mode cuts context waste by running tool workflows as code in a sandbox, so intermediate results don’t keep flowing back through the model.
-
For simple lookups, it’s not automatically better: in this benchmark, regular tool calling was usually cheaper and more reliable below roughly 16 tools. Tool search may be a simpler fix for large tool catalogs.
-
For repetitive, many-item tasks, Code Mode shines: on 100-item tests, it used about 120× fewer tokens and was 18× faster, while avoiding fan-out errors in the benchmark.
-
Choose based on your workload and model: chained tasks had mixed results, smaller models varied widely, and generated code needs strong security isolation. The 16-tool crossover is a benchmark-specific guide—not a universal rule.
Why MCP Agents Face a Context Cost
MCP makes it easier for agents to connect with tools. Yet every tool description, call and result can add to the model’s context. The agent may resend that history on later turns, even when it no longer needs every detail.
Code Mode changes the workflow. The model writes a short program that calls tools in a sandbox. The program handles intermediate steps, then returns the useful result. That can cut context use and reduce back-and-forth.
Still, Code Mode adds complexity. A script can fail, and model-written code needs strong security controls. Tool search offers a simpler option when the main problem is loading too many tool descriptions.
What the Benchmark Found
The benchmark tested 12 tasks, five models and four approaches, using real data and known answers. On simple, single-step tasks, regular tool calling usually cost less and proved more reliable when the agent had 16 or fewer tools. Above that point, Code Mode often became cheaper. Treat 16 as a clue, not a universal cutoff.
Fan-out tasks changed the picture. These tasks repeat the same action across many items. Code Mode used 3.7 times fewer tokens on 10 items and 120 times fewer on 100. At 100 items, it also ran about 18 times faster. It achieved a 100% success rate on the benchmark’s fan-out tasks.
Chained tasks, where each result guides the next step, produced mixed results. So did model performance. Some smaller models handled basic code well but struggled with longer chains.
Choosing an Approach
Start with the workload. For a few tools and one lookup, use regular tool calling. If tool descriptions crowd the context, test tool search. For repetitive work across many records, Code Mode may deliver major savings.
Then test the model you plan to deploy. The benchmark covered one business domain, so its results may not predict every agent’s performance. Also, isolate generated code from sensitive files, credentials and unrestricted network access.
Code Mode gives MCP agents a useful new option. But the best choice depends on the tools, task and model—not a single benchmark number.
Continue Your Tech Journey
Explore the future of technology with our detailed insights on Artificial Intelligence.
Access comprehensive resources on technology by visiting Wikipedia.
AITechV1
