Cloudflare Code Mode Cuts Agent Tool Tokens by 99.9%
Connecting an agent to a large API usually means loading every tool definition into the model before it does anything useful. Cloudflare says it cut that cost by 99.9 percent with a feature called Code Mode, and it ships in the company's official agents SDK.
The gap is easy to picture: 1.17 million tokens on one side, about 1K on the other, on the very same API.

What Happened
Cloudflare's API has 2.5K endpoints. Wire an agent to it over MCP the usual way and the model has to ingest the definition of every one of those tools, which comes to roughly 1.17 million tokens.
Code Mode sidesteps that. Instead of loading all 2.5K tools, the model writes code and works through just two functions, search and execute. It stays around 1K tokens no matter how many endpoints sit behind it, and that code runs in an isolated worker rather than calling tools one at a time.
The rest of the SDK is built for stateful agents on Cloudflare:
- Agents go to sleep when idle and cost nothing while stopped.
- An agent can act as an MCP server or connect as a client.
- It covers scheduled tasks, workflows with human approval, voice and email.
- React hooks are there for the front end.
The repo is cloudflare/agents, under the MIT license, at 6.1K stars. The latest version is 0.34.1, from Nov 25. Code Mode itself is still marked experimental.
Why It Matters
If you have been steering around big APIs because the tool definitions alone would eat your context window and your bill, this changes the math. A 2.5K-endpoint service stops being a wall of tokens and starts looking like something an agent can work with.
One caution before you build on it: experimental means the interface can shift under you. Worth a test project now, not the thing to bet a production agent on yet.
Does this still work?
Nobody's checked yet
Sign in to tell everyone how it went.
Continue with GoogleBe the first — one tap saves the next person an hour.
It takes 3 reports in 30 days to set the status.
More shares you might like
ToolsHow to Claim a Free Domain at IDWebHostCalvin · 12h · 21 views
ToolsHow to Get $3 in Free Claude API CreditCalvin · 1d · 29 views
ToolsHow to Redeem 1,000 Telkomsel Points for a Snowville TicketCalvin · 2d · 40 views
AIHow to Make 10 Animation Styles With ClaudeCalvin · 3d · 48 views
ToolsHow to Get 5GB Telkomsel eSIM for Rp1 on GoPayCalvin · 4d · 57 views
ToolsHow to Transfer SeaBank to DANA, GoPay, OVO for FreeCalvin · 5d · 71 views
Comments
Join the conversation — sign in to comment.
No comments yet — start the conversation!