Engineering brief

Code Mode Agents: Less Token Bloat, More Sandbox Complexity

AI Engineer3 min read · saves 12 min

At a glance

The brief is enough

Relevance
Practical value
Radar
Time horizon
This year
Warnings
None

Giving your agent a sandbox to write code instead of a static tool catalog cut tokens by 43% and cost by 31% for Arize. The trade-off is operational overhead, debugging difficulty, and the need for strong evaluation practices.

Agent architecture directly shapes token cost, latency, and capability—code mode changes all three at once.

Watch if you're considering architectures for complex agent systems beyond simple tool chains.

Summary

The proposal. Mikail King of Arize AI advocates replacing the traditional agent tool catalog with a sandboxed programming environment—code mode. Instead of giving an agent a fixed menu of tools, you give it a Python or Bash sandbox where it can write and execute code on the fly. The agent can search for, compose, and even build its own tools, moving far beyond static function calls.

Why now. As agents take on longer-horizon tasks, the classic tool-calling pattern suffers from context bloat: every tool invocation dumps its output into the context window, racking up tokens and turns. Code mode cuts that by letting the agent run multiple operations in a single turn and return only what's needed. Arize's own numbers show a 43% token reduction and 31% cost drop with constant latency.

The real win. The strongest argument for code mode is emergent behavior. An agent that can write code can build a tool to strip PII from records instead of leaking data into the context window, or run aggregate SQL queries that pagination-based tools can't handle. King shows how Arize hoisted their REST API, SQL access, and even a browser-bound programming paradigm onto this model.

The trade-off. Code mode isn't free. You trade tool-calling simplicity for sandbox lifecycle management, network egress risk, secret vaulting, and permissions drift. Debugging becomes harder because you're now hunting errors in LLM-generated code. Tool discovery shifts from a static list to a runtime handshake. King acknowledges these as open problems, not blockers.

What's missing. The talk leans on Arize's own platform data, so the numbers carry a vendor bias. There's no independent benchmark or comparison with other code-mode implementations like Anthropic's tool use. The evaluation framework (Harbor) is also an Arize product, making it hard to separate the signal from the pitch.

The bottom line for teams. Code mode is a promising architecture for agents that need to compose multiple operations or build custom tools on the fly. But it demands investment in sandbox infrastructure, monitoring, and evaluation. Teams should pilot it on a bounded task before rolling it out broadly.

My take

The 43% token reduction and 31% cost cut are eye-catching, but I'd be cautious about generalizing from a single vendor's stack. Code mode is clearly powerful for agents that need to chain multiple operations or build custom tools dynamically, the PII example is a strong use case. But the operational complexity is real: sandbox lifecycle, secret management, and debugging LLM-generated code are non-trivial. I'd start by piloting code mode on a narrow task where dynamic tool creation would unblock something you can't do with static tools today. Pair it with a pass-at-K evaluation framework from day one; without it, you're flying blind on reliability.

What to do with this

  1. Audit your agent's current tool catalog and identify tasks that could benefit from dynamic code generation.
  2. Set up a sandbox environment with network and secret controls to test code mode agents on a single workflow.
  3. Implement a pass-at-K evaluation framework for agent tasks to measure reliability and cost changes before scaling.

Watch the video

This video is blocked due to your privacy settings. To watch this video, please accept YouTube marketing cookies.

Related breakdowns

Get TL;DW

Too Long; Didn't Watch.

A concise breakdowns of the AI and devtools videos that actually matter for engineering leaders.

Free. Weekly. No hype.

Video and thumbnails remain the property of their respective creators. tldw.news provides editorial analysis, commentary, and discovery links to original content.