🔧 What changed 0:00
Anthropic added an experimental feature to Claude Code that replaces per-tool calls with code: Claude writes a short JavaScript program, the harness runs it in your session, and tool calls become function calls inside that program. Same model, fewer round trips, less of the conversation spent on intermediate results.
| Without Code Mode | With Code Mode |
|---|---|
Model asks for Read, waits, reads result, decides next call | Model writes one program that makes several calls and returns what matters |
| Every tool result lands in the context window | Intermediate results stay inside the program |
| Loop drives the sequence | Code drives the sequence |
The framing he gives it is the correct one: this is an example of the model swallowing the harness. Instead of the harness presenting a fixed menu of actions, the model gets a general-purpose action — writing code — that can express all of them.
🚰 The problem: context as middleman 0:57
Each tool call's output goes into the context window; the next call requires the model to read the whole conversation again. Chain six MCP servers and you are paying to re-read intermediate data that existed only to be passed along.
| Symptom | Cause |
|---|---|
| Large context growth on multi-tool tasks | Every intermediate result is persisted in the transcript |
| Cost that survives caching | Cached tokens are cheaper, not free — you still pay to carry data you no longer need |
| Round-trip latency | Each call is a full model turn |
| Poor results from noisy MCP servers | A tool returns 10,000 rows and the model must read them to filter |
📉 Cloudflare's two steps 2:13
The idea is not Anthropic's. Cloudflare argued it in a piece he rightly calls the populariser, then demonstrated it on their own API — and the demonstration is the clearest number in the whole topic.
| Measure | Native MCP | Code Mode |
|---|---|---|
| Cloudflare API surface | 2,500+ endpoints | Two tools: search and execute |
| Tool definitions in context | 1.17 million tokens, measured with tiktoken | Roughly 1,000 tokens |
| Where the work runs | Model decides call by call | TypeScript in an isolated sandbox, no internet access beyond the MCP APIs |
His retelling rounds 2,500+ to "2,600" and 1.17 million to "1.1 million", which is close enough in spirit and worth stating exactly.
🌐 Server side, client side, gateway 3:20
| Flavour | Spans | Example |
|---|---|---|
| Server-side code mode | One vendor's own tools | Cloudflare's own MCP server; each vendor decides for itself |
| Gateway code mode | Many servers, one proxy | An MCP gateway that exposes search and execute across everything you connect |
| Client-side code mode | The whole harness | Claude Code's version: all tools, including built-ins and sub-agents |
He demonstrates the gateway middle ground with a self-hosted instance carrying a few dozen MCP servers, where you can also bundle connections so different team members get different tool sets — a genuinely useful pattern for teams, and the point at which "which tools does this agent have" stops being a per-machine question.
🧰 Claude Code's version 5:25
The harness exposes essentially one tool that runs code — the REPL tool, which he pronounces as "ripple": read, evaluate, print, loop. Inside it, the old tools are functions.
| Formerly a tool | Now a function in the REPL |
|---|---|
| Bash / shell | A tagged-template function for running commands |
| Read, Edit, Write | Functions taking paths and content |
| WebFetch | A function |
| MCP tool calls | Functions, so several servers can be combined in one program |
| Sub-agents | Not yet exposed programmatically — see the unreleased section |
In the transcript you see the tool calls, not the code: pressing Ctrl+O opens the transcript viewer where each program appears as a collapsed code row. He also demonstrates the polling companion tool, which checks on a long-running program that has detached into the background.
🔁 Why a persistent REPL differs 6:57
Server-side code mode runs one program and returns a result. Claude Code's REPL stays open for the session, so state accumulates.
| Behaviour | Consequence |
|---|---|
| Variables persist between programs | Store a huge result once, inspect a slice, then process it further without re-reading it |
| Loops and parallelism inside one call | Hundreds of files or calls handled in one step |
| Filtering before returning | A chatty MCP server becomes tolerable: assign to a variable, preview a little, keep going |
| State you cannot see | The conversation no longer contains the data the model is reasoning over |
Ctrl+O rather than trusting the summary.
He answers the obvious objection — could Claude not just write a shell script? — correctly: a script lacks access to the harness's own tools. The REPL is privileged in a way a script is not, which is exactly why its permission model matters.
🚧 Setup, and the limits the docs list 5:46
| Item | Documented value |
|---|---|
| Enable | CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude, or an env block in your settings |
| Version | v2.1.323 or later, any release channel |
| Status | Experimental and off by default; may change or be removed in any release |
| Account | A Claude subscription or Console account — not available on every surface |
| Limit | Detail |
|---|---|
| Resuming | Only in the terminal, with Code Mode on |
| Waiting code | Stops after ten minutes, including time spent at permission prompts |
| Background code | Up to two hours, and requires auto or bypass-permissions mode to start |
| Session portability | Cannot move to the desktop app or become a background session; /fork cannot start a background copy |
| Unavailable with it | Remote Control, Claude in Chrome, computer use |
| Agent teams | Cannot be used together with the agent-teams feature today |
PreToolUse hooks, and to inspect the code itself you hook the REPL tool and read the JavaScript from its input. The exception worth knowing: in auto mode the classifier reviews the code as a whole rather than each call — a wider unit of review, which is a weaker guarantee per action.
📏 His measurement 8:38
He ran his own comparison on real issues in real open-source projects, with and without code mode, after noticing the feature appear in the binary about eleven days earlier.
| Measure | Result |
|---|---|
| Input tokens | About half |
| Total cost | 71% of normal mode, so roughly a 30% saving |
| Task success | Not reported in the same terms — the comparison is on cost, not correctness |
🧪 Browser Use and Prime Agent 8:58
| Project | Claim | Status |
|---|---|---|
| Browser Use 1.0 | Deleted about 90% of its old library; the agent now writes Python against the raw Chrome DevTools Protocol — up to 50% better, two to five times cheaper, faster | Vendor announcement, not independently measured here |
| Prime Agent | A Python REPL as the single tool; file ops, shell, sub-agents and context management all through code | Confirmed — PrimeIntellect-ai/prime-agent, 22.7k stars, Rust, self-described as a "self-improving RLM agent" |
| Terminal-Bench comparison | Claude Code 65% versus 71% with a single Python REPL, at slightly lower cost per task | A third-party post shown on screen; not in the repo README or the vendor's RLM write-up |
The report that Prime Agent's performance figures come from a screenshot rather than a published evaluation is a caution about all three: these are vendor-and-enthusiast numbers, gathered while the technique is new, and the technique changes the harness, the prompt and the cost curve simultaneously.
💡 The mismanaged geniuses 9:33
The article he recommends is real, and its thesis is a good frame for everything above.
| Detail | Value |
|---|---|
| Title | The Mismanaged Geniuses Hypothesis |
| Authors | Alex L. Zhang, Zhening Li and Omar Khattab — the video credits only Zhang |
| Published | 9 April 2026 |
🧬 Three properties of an RLM 18:43
The interesting speculation in the video is that Claude Code is drifting toward a recursive language model — a model that manages its own context as data. Three properties are required:
| Property | Present in Claude Code? |
|---|---|
| A REPL that persists between calls | Yes — variables defined in one program survive into the next |
| Sub-agents launched and managed from inside the REPL | Not yet — three context tools appeared in the binary but are unreleased |
| The prompt itself living in a variable | No — a large pasted prompt still lands in the context window |
🧩 The missing third 19:42
What "prompt as a variable" would actually mean: a two-million-token prompt handed to the model as a reference, with the model writing code to slice it, summarise parts, hand sections to sub-agents, and read only what it needs.
| Today | With prompt-as-variable |
|---|---|
| A giant prompt fills the window and triggers compaction | The prompt is data; the model reads what it chooses |
| Compaction decides what to drop | The model decides what to drop, explicitly |
| Conversation history is append-only | History becomes mutable state |
💳 The cache problem 22:10
He flags this correctly and points at the right place. Anthropic's context-editing documentation is explicit about the trade.
| Documented behaviour | Consequence |
|---|---|
| Clearing tool results invalidates cached prompt prefixes | You pay cache-write costs each time content is cleared |
clear_at_least sets a minimum number of tokens per clearing | The feature refuses to clear a trickle that would not justify breaking the cache |
| Keeping thinking blocks preserves the cache; clearing them invalidates at that point | A per-workload choice between cache hits and window space |
🔮 What is not shipped 10:10
| Claim | Status |
|---|---|
| Three functions — spawn, list and release context — appeared in the binary alongside Code Mode | His strings-inspection; not in the documentation |
| They would let code fork the main conversation, explore branches, and return only the best results | Speculation built on those strings |
| Spawned contexts could message the coordinator back | Speculation |
| Code Mode and agent teams cannot be enabled together today | Documented — an explicit current incompatibility |
✅ Claims checked
| Claim | Verdict | Evidence |
|---|---|---|
| Claude Code has an experimental Code Mode | Correct | Documented as "Run tool calls from code with Code Mode"; off by default |
Enabled with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 | Correct | Documented, including the settings-file variant |
| Requires v2.1.323 or later | Correct | Stated in the requirements section |
| Claude writes JavaScript that makes several tool calls in one step | Correct | Docs example edits a file and runs tests in one program |
| The tool that runs the code is a REPL, followed by polling | Correct | Docs name the tool REPL and reference a poll event for background code |
| Tool calls inside the code still respect permissions | Correct | Each call goes through deny/ask rules and PreToolUse hooks |
| Auto mode reviews the code rather than each call | Correct — and it is a weaker per-action check | Documented limitation |
| Long-running code detaches and can be polled | Partly | Waiting stops at ten minutes; background runs up to two hours but requires auto or bypass-permissions mode |
| Cloudflare reduced 2,600 tools to two | Figures slightly off | Their own post says 2,500+ endpoints, 1.17M tokens, to two tools and about 1,000 tokens |
| Code Mode used half the input tokens and 71% of the cost | His own measurement | No task list, scoring or run count published |
| Browser Use deleted ~90% of its library and gained 2–5× cheaper | Vendor claim | Announcement material, not independently reproduced here |
| Prime Agent is an RLM harness with a persistent Python REPL | Correct | Repo README: REPL as the built-in tool, programmatic sub-agents, prompt-as-a-variable |
| 65% → 71% on Terminal-Bench with a REPL | Unverifiable here | Shown from a third-party post; absent from the repo and the vendor's RLM write-up |
| The mismanaged geniuses hypothesis says models are underutilised, not incapable | Correct | Published 9 April 2026 by Zhang, Li and Khattab |
| An RLM needs a persistent REPL, sub-agents from code, and prompt-as-variable | Consistent with the framing | Two present in Claude Code, third absent |
| Context editing breaks the prompt cache | Correct, and documented | Tool-result clearing invalidates cached prefixes; clear_at_least exists to make it worthwhile |
| The Meta "context language models" paper on prefix/suffix caching | Unverified | Could not confirm the paper as described; the cache trade-off itself is documented by Anthropic |
Basis note. Built from the full 14:54 recording and checked against the Claude Code Code Mode documentation, Cloudflare's two code-mode posts, the Prime Agent repository and the mismanaged-geniuses post. Two corrections of substance: the tool is a documented REPL with a ten-minute/two-hour distinction he compresses, and Cloudflare's figures are 2,500+ endpoints and 1.17M tokens. His own cost measurement is reported as his, with its missing method stated.
🔑 Key takeaways
- A tool call is a message; code is a computation. Everything done inside the computation — loops, filters, joins, parallelism — never enters the conversation.
- The interface becomes constant-size: Cloudflare went from 2,500+ endpoints and 1.17M tokens to two tools and about 1,000 tokens.
- Three flavours, increasing scope: one vendor's server, a gateway across vendors, then the whole harness. Claude Code ships the third.
- Everything is behind one tool: bash, read, edit, fetch and MCP calls become functions inside the
REPL. - Persistence is the difference from server-side code mode: variables survive between programs, so a huge result can be stored once and sliced.
- That persistence has an audit cost: data the model reasons over may no longer be in the transcript. Read the code rows with
Ctrl+O. - Permissions survive: each call inside the code goes through your deny/ask rules and hooks — but auto mode reviews the code as a unit, not each call.
- Bash rules match text, so a denied command can be expressed in a form the rule misses. Generated code is the mechanism that finds that gap.
- Long code is bounded: ten minutes when waiting, two hours in background, and background requires auto or bypass-permissions mode.
- Code Mode and agent teams do not run together today — the likely reason the unreleased context functions matter.
- It is experimental, off by default, and restricted: no Remote Control, no Claude in Chrome, no computer use, no portable sessions.
- The RLM framing is two-thirds true: persistent REPL yes, sub-agents from code not yet, prompt-as-variable no.
- The missing third is blocked by billing, not science: editing your own context invalidates the prompt cache, which is why context editing stays coarse.
- Prevention beats curation: not creating the tokens is cheaper than any strategy for clearing them later.
🔗 Resources
- The video — Ray Amjad, 14:54 (no sponsor; self-promotion excluded here)
- Code Mode documentation — requirements, permissions, long-running code, limitations
- Cloudflare: Code Mode and an entire API in 1,000 tokens
- Prime Agent — persistent Python REPL, programmatic sub-agents
- The Mismanaged Geniuses Hypothesis — Zhang, Li, Khattab
- Context editing — the cache-invalidation trade and
clear_at_least