Short answer: Code Mode can sharply cut how much data lands in your AI conversation, while leaving the number of upstream app API calls almost untouched.
Those two numbers get lumped together constantly when teams evaluate efficiency claims. A tiny final answer can still require dozens of API reads behind the scenes, and a fast script that stays comfortably inside its token budget can still return an incomplete count.
Why conversation size drops while reads stay the same
Imagine asking for a count of open tickets by team. Without Code Mode, an agent calls a search tool, pulls pages of verbose JSON directly into the chat history, and counts them in model context.
With Code Mode, the agent writes a small script that fetches those permitted records inside a sandbox, tallies them, and returns just the result. Unless the script prints raw rows to console.log, the intermediate records never enter the conversation. That is the core idea behind Anthropic's code execution with MCP and Cloudflare's API Code Mode MCP server.
In a fictional four-record example, three open items collapse cleanly to {"Service": 2, "Delivery": 1} instead of four full ticket bodies. That saves conversation space. It does not eliminate the API call that fetched the four records in the first place.
Track three measurements separately
When you test Code Mode on a real workflow, keep three metrics separate so a win in one does not mask a problem in another:
- Conversation context: how much intermediate data and output enters the model's prompt. Returning grouped counts instead of full rows shrinks this directly, unless verbose logging puts the raw data right back in.
- Provider API calls: how many requests hit your connected app. If a fictional API needs five page fetches to cover a week of tickets, moving the loop into a script still sends five requests (and still counts toward app rate limits and Yapr audit records). Only a server-side filter or aggregate endpoint reduces provider requests.
- Coverage: whether the script actually examined the whole scope. Returning
{"Service": 2, "Delivery": 1}after reading all four records in scope is complete; returning the exact same object after stopping at page one of a 400-ticket queue is partial.
These three numbers move independently. A five-line summary can hide twenty upstream requests, and a script that finishes cleanly inside its limits can still stop halfway through your data.
Measure your own workflow instead of borrowing headlines
Published token-reduction numbers from another vendor's benchmark will not match your apps, schemas, or prompts. To run an honest comparison on your own workload, hold the connection, filters, time window, and required output steady, then record:
- Total app API requests made.
- Records examined and completion status (complete, partial, unavailable, or unknown).
- Size of the data returned to the chat.
- Model token usage reported by your AI client.
Avoid turning a smaller JSON payload into an automatic cost-savings promise. Tool schemas, script-writing turns, retries, and the model's final write-up all consume tokens too.
Just as importantly, do not strip out the evidence your reader needs just to chase a smaller payload. A grouped count should carry its filter and source status; an exception report should include the specific record IDs someone needs to inspect next.
Putting it into practice
Use when to use MCP Code Mode to decide when a script beats a direct tool call, and our Code Mode pagination guide to keep partial reads honest. Yapr's Code Mode documentation lists the exact call, read-byte, and output limits so you can compare platform usage alongside your AI client's token meter.