Blog

Claude Code Execution With MCP vs Pi's New Codemode

November 2026 · 6 min read · Technical

Hand-drawn notebook sketch of a Claude harness passing a script to a sandbox box and getting one result back
← Back to all posts

Pi 1.0 has shipped a feature called Codemode, and Armin Ronacher's write-up of it is worth reading if you build agents. The model writes short JavaScript snippets that run in a sandboxed QuickJS environment and call Pi's own tools (read, bash, write, edit) directly, instead of spending one model round-trip on every tool call. Only the final result lands back in the model's context.

If that sounds familiar, it should. Anthropic described the same pattern for Claude in its "Code execution with MCP" engineering post: the model writes code that calls MCP tools inside a sandboxed execution layer, and large intermediate outputs never touch the context window. This post compares the two and turns the comparison into questions an Australian team can ask before choosing an agent platform.

What is code execution with MCP, and why does it matter?

Code execution with MCP is a pattern where Claude writes a small program that calls MCP tools inside a locked-down sandbox, rather than calling each tool one at a time through the model. The program can loop, filter and combine results, and only the final answer returns to Claude. That cuts the tokens and latency that classic tool calling wastes on long, multi-step tasks.

The waste in classic tool calling is easy to miss in a demo and hard to ignore in production. Every intermediate result gets reprocessed by the model on each later turn: the full contents of a file, a 200-row database query, a list of GitHub issues. A five-step task is fine. A forty-step task that reads documents, queries a system and cross-checks the two pays for those intermediate results again and again.

Both Claude's approach and Pi's Codemode attack the same cost by moving the busywork out of the model's context:

  • The model writes a script once instead of making many separate tool calls.

  • The script can run tool calls in parallel and loop over results without a model turn per step.

  • Large outputs are filtered inside the sandbox, so only the useful slice reaches the model.

  • The sandbox is isolated from the trusted harness, which limits what model-written code can touch.

Brain and hands: the shared architecture

Ronacher frames Pi's design as a split between the "brain" and the "hands". The brain is the harness: trusted, holding credentials, deciding what happens next. The hands are the sandbox: no network, no filesystem, no timers, able to call only the tools the harness exposes. That is a sound design, and it matches the shape of Claude's MCP code-execution approach, where MCP tools are the only doors out of the sandbox.

How the two approaches line up
QuestionClaude code execution with MCPPi Codemode
Who writes the code?ClaudeThe Pi agent's model
Where does it run?A sandboxed execution layerA QuickJS sandbox
What can the code call?MCP tools exposed to itPi's own read, bash, write and edit tools
What returns to the model?The final, filtered resultThe final, filtered result
Tool discoveryTools can be found as needed, not all loaded up frontFixed set of Pi tools

The difference that matters most for a business is the tool surface. Pi's Codemode wraps a small, fixed set of coding tools. Claude's version works through MCP, so the same pattern reaches whatever systems you have wrapped as MCP servers: your CRM, your ticketing system, an internal data warehouse. For a team in Sydney or Melbourne connecting agents to line-of-business systems, that reach is the point.

Why the announcement date is the wrong yardstick

It is tempting to read feature launches as a scoreboard. That misses the question a buyer should ask, which is which platform runs the pattern in production today with the surrounding tooling already hardened. Observability, sandbox guarantees, enterprise auth and audit trails decide whether a pilot survives real workloads. Those things take longer to mature than the core idea, and they matter more under the Privacy Act and, for regulated firms, APRA's operational resilience expectations.

So treat Pi's arrival as a useful signal rather than a threat or a reason to switch. When an independent harness converges on the same design Anthropic published, that is evidence the pattern is right. The decision you face is still about maturity, controls and fit with the systems you already run.

What to ask before you build

These are the architecture questions that predict whether an agent pilot becomes a production system. Ask them of any platform, Claude included:

  • Does the harness run model-written code in an isolated sandbox, or does it just chain tool calls?

  • Can it batch and parallelise tool calls without a full model round-trip per step?

  • Is MCP tool discovery on demand, or does every tool definition sit in context from turn one?

  • What can the sandbox reach: network, filesystem, credentials? Who decides, and where is that written down?

  • Can you see what the generated code did after the fact, step by step, for an audit or incident review?

An illustrative cost picture

Take an illustrative month for a mid-market finance team running an agent that reconciles supplier invoices against purchase orders. If classic tool calling pushes $6,000 of model spend because every query result is reprocessed on each turn, and code execution keeps most of those results inside the sandbox, the saving could plausibly run into thousands of dollars a month. These figures are illustrative, not measured: your own numbers depend on task length, output size and model choice, which is why we model them per workflow on our ROI calculator.

What not to conclude

Code execution is not a free upgrade for every agent. Short tasks with two or three tool calls gain little, and a sandbox adds moving parts you must secure and monitor. Model-written code can also fail in ways a single tool call cannot, such as a loop that runs longer than expected. The pattern pays off on long, data-heavy workflows, and those are also the ones where you need the strongest controls.

It is also not a reason to rebuild what works. If you already run Claude with MCP servers, the move to code execution is mostly about how tools are exposed and sandboxed, not a new platform. Our earlier pieces on choosing a sandbox for code execution with MCP and designing tools the model calls correctly cover the groundwork, and our note on custom harnesses with skills, subagents and MCP shows where this fits in a wider build.

Where to start

As at October 2026, the practical move for most Australian teams is to pick one long, repetitive workflow, measure what it costs with classic tool calling, and test the code-execution pattern against it with Claude. If you want help scoping that test or reviewing an agent platform shortlist, book a call with us and we will work through it with your team.

FAQ

Frequently asked questions

What is Pi Codemode?

Pi Codemode is a feature in Pi 1.0 where the agent writes short JavaScript snippets that run in a sandboxed QuickJS environment and call Pi's read, bash, write and edit tools directly, returning only the final result to the model.

Does Claude support code execution with MCP?

Yes. Anthropic has described a code execution with MCP pattern in which Claude writes code that calls MCP tools inside a sandboxed execution layer, so large intermediate outputs stay out of the model's context window.

Why does code execution reduce token costs?

With classic tool calling, every intermediate result is reprocessed by the model on later turns. Code execution filters and combines those results inside the sandbox, so only the final, relevant output is sent back to the model.

Is code execution with MCP safe for regulated businesses?

It can be, if the sandbox is properly isolated, tool access is limited to approved MCP servers, and every run is logged for review. Regulated firms should check those controls against their Privacy Act and APRA obligations before production use.

Ready to move from AI pilot to production?

We help mid-market Australian businesses deploy AI automations that actually reach production and deliver measurable ROI.