Armin Ronacher explains Codemode: LLM tool calls written as JavaScript in a no-network QuickJS sandbox on the Pi harness

Armin Ronacher explains Codemode: LLM tool calls written as JavaScript in a no-network QuickJS sandbox on the Pi harness

  • Codemode lets the model issue and compose tool calls from a programming language (JavaScript in Pi) instead of JSON tool schemas, and it runs on the harness (brain) side inside QuickJS on a WASM runtime with no network, no file system, no timers, and limited RAM.
  • Pi 1.0 added MCP support through Codemode; it is enabled by default only when MCP is on, and a user can turn it on with "defaultTools": ["+codemode"]. The name Codemode was coined by Cloudflare.
  • A regular bash tool call puts only the trailing 2000 lines into context, while a Codemode invocation gets larger outputs sent structurally, and Codemode can stash state into the transcript for later calls in the session.
  • Ronacher splits the system into a trusted harness (brain) and a separate execution environment (hands) that runs bash, so the two sit on different file systems with different trust levels; a sandbox like Gondolin covers the bash side but not the harness.
  • Pi exposes APIs that make no sense as regular tools, such as image generation and one-shot text classification, through Codemode rather than tools that would waste context.

Hacker News opinions

Not sure why almost every codemode implementation picks JavaScript. I prototyped an agent using bash as the codemode language and it worked just as well, with literally zero prompt to teach it.

Because the models are trained on JavaScript, you get away with way fewer instructions. Promises give you concurrency for free. And code mode runs on the harness side, where bash is a tricky target.

Sandboxing bash is way harder than JS or Lua, which have fantastic embedded tooling. Every model is fully trained on JS anyway, so that needs no teaching either.

The thing I still can't figure out is recovery after interrupted execution, and how you tell completed side effects apart from calls that are safe to repeat.

How is this different from Claude writing mini scripts all the time? Claude's scripts can't call MCP tools, so everything has to be CLIs or libraries, and you lose the self-documenting input-output schema codemode is going for.

I tried codemode in a prototype and stripped it out again. My small local LLM burned more tokens, and when an embedded tool call failed on parameter validation the whole parent code block failed, so the model kept rewriting it.

That matches a fear I had about small models. It works fantastically with Opus and Sol, but I always wondered how well it scales down.

Monty from the pydantic team is a joy if you need to run unverified code securely. It's a simplified Python dialect, and you can call it from JS.

Between this and the Cloudflare post, it's a lot of words with no simple system-level picture. This is homoiconicity, actor semantics, and object capabilities rediscovered by hacking outward from token streams.

It's simpler than that. Instead of a fixed JSON schema for tool calls, let the model write a program to call and compose the tools however it wants, with APIs to reach into the harness.

Can someone tell me how to disable this permanently in Pi? I set autoEnableCodemode to false and it still won't turn off.

MCP and codemode don't auto-enable. {"extensions": ["-builtin:codemode"]} is all you need, and -builtin:mcp kills MCP independently.

Code mode seems to cause progressive lobotomisation in Sol 6.1 around subagents. The more it uses it, the worse its subagent prompts get, merging words together and spamming keywords.

I still can't parse what it actually is. The article is titled What is Codemode and then halfway through says if you are not familiar with Codemode. That passage about 2000 lines means nothing to me.

This is a very complex apparatus for little gain. Pi's promise was bash and no other tools. The minimally invasive fix would be to inject tool calls as virtual bash commands.

Am I crazy for liking codemode? It cuts the number of turns by about an order of magnitude.

AI
OpenAI told investors its annualised revenue was about $20B below earlier reportsOpenAI withdraws three math manuscripts from its GitHub repo as Lean checks continueOpenAI withdraws 3 math papers after a sign error, revises 14 moreLLM-built Rust port of the TypeScript compiler arrives with $400,000 in API-priced tokens and a nod from the TypeScript teamOpenAI publishes 372 math results, including a proof of the Unique Games ConjectureTerence Tao: AI is harvesting open math problems unsustainably, and 'Math 2.0' must reward exposition and communityGoogle DeepMind's SynthID Detector goes public, but it demands a Google, Apple, or ChatGPT loginPaper: verified Lean proof of OpenAI's Navier-Stokes claim does not match the natural language proofMeta and Microsoft cut internal Claude usage, Microsoft caps AI spend at $10K per employeeOpenAI brings GPT-6 and Intelligent UI to ChatGPT's 1.2 billion weekly usersAnthropic's Claude Haiku 5.5 runs 75% cheaper and hits 1620 on GDPval-AA, with a 100K-token price cliffTelegraph Test: cablese compression cuts LLM output tokens 40-49% at plaintext parityArmin Ronacher explains Codemode: LLM tool calls written as JavaScript in a no-network QuickJS sandbox on the Pi harnessOpenAI launches Decisions API in public beta: gpt-6-luna only, 10x faster than Responses, $0.10 per million input tokensGoogle launches EmbeddingGemma 2, a 740M-parameter multimodal embedding model under Apache 2.0OpenAI releases frontier model math results on GitHub with Lean proofs and reasoning tracesMeta's Muse shipped with a spyable zero-day, uploaded private messages without permission, and ignored user settings; Apple changed macOS rules in responseMistral Large 4 preview: 1T-parameter multimodal model with 49B active parameters, weights due this monthCoding agent reconstructs 1.5M Georgia ballot order from a 2022 scanner flawDust trains transformer LMs without backprop by perturbing activations, matching it at large populationChatGPT is signing fake New Yorker cartoons with real cartoonists' signaturesReflection unveils Beam, a 501B open-weight MoE model trained on 10.5K GB300s, with weights promised later this monthFlorida woman used Claude as a diary; Anthropic flagged a threat entry and reported it to police, and she now faces a second-degree felonyClaude catches root malware on Stratechery's Mac Mini, as Apple tightens AI agents' Full Disk AccessCloudflare launches Web Search API in beta, routing Exa, Ceramic.ai and Linkup queries through AI GatewayWolfram argues against handing pure math research to AI, citing the 1988 Mathematica parallelStrata runs Qwen 3.8 Flash Next 125B on a single RTX 4090 at over 100 tokens/sec via 2-bit quantMeta's Muse tops the App Store on UX, not new agent capabilitiesOpenAI safety lead David Robinson quits over 'broken' culture as firm pauses training and shelves next modelLeCun has "zero concerns" about AI extinction, calls Amodei "deluded" and effective altruism "super toxic"Ataraxos beats the best Stratego player 15-1, trained on 16 GPUs and a few thousand dollarsGreg Kroah-Hartman: Mythos's 79 Linux kernel bugs came down to 10 real fixes and one hour of workWisconsin grid approval threatens Oracle's 2027 AI datacenter deadlineBlack Forest Labs' FLUX 3 Image adds bounding-box layout control to text-to-imageSupabase acquires Turso to build on-demand database infrastructure for AI agentsKevin Buzzard maps mathematicians' reaction to AI onto the five stages of griefarXiv caps submissions at two per month as AI-driven preprint flood hits 40,363 in SeptemberHistorian uses Opus 5.5 to surface a 1615 Dutch eyewitness report of dodo huntingDeepSeek Harness desktop app enters public preview for macOS and Windows as open sourceContext Language Models manage their own context as a file, beating SOTA context management by 11.4% on BrowseComp-Plus with 21.5% fewer FLOPsEarendil ships Pi 1.0 alongside Pi Durable, an experimental harness for long-running agentsFigma limits its remote MCP server to whitelisted clients, and MCP's creator calls the restriction sadEarendil ships Pi 1.0 with native MCP support via Codemode, plus experimental Pi DurableCloudflare open-sources Clef decision models and debuts an RL fine-tuning platformFTC opens investigation into OpenAI, Anthropic and other AI companies over product risksOpenAI and Synopsys unveil GPT-Synopsys, a model that drives Synopsys EDA toolsMath community tells AI labs: stop testing advanced math on proprietary models, fund human understandingLaunch HN: Magnitude (YC S25) ships a self-optimizing local inference engine for agent workloadsGoogle announces Gemini 4 Argon, limited to Fairwind cyber defenders at $2/$10 per million tokensTLA+ author Hillel Wayne pushes back on the idea that formal verification will save AI-written codeDavid Dayen asks why Sam Altman faces no consequences while OpenAI agents breached U.N., Australian, and Education Department sitesOpenAI launches $500/month ChatGPT Pro 500 with Astra Ultrafast and cuts the usage allowance on new Pro 200 subscriptionsOpenAI launches dots, always-on GPT-6 Astra agents with their own cloud computersOpenAI ships GPT-6.1 Sol at $2/$10 per million tokens, near-Astra scores for a fifth of the pricePostHog's Jeeves adds autoregressive reasoning to Jev-style decision models, trading speed for accuracyStudy finds conversational AI services hand chat titles, prompts, and screenshots to ad trackersNvidia launches Open Agent Safety Platform with OpenShell and Sentry chip to contain AI agentsAMD acquires World Labs, with Fei-Fei Li joining as Executive VP and Chief ScientistCal Newport calls on Congress to investigate OpenAI and Anthropic over rogue agents and apocalyptic ideologyCloudflare launches cf, an agentic CLI covering its entire 3,000-operation APIMeta poaches MongoDB CEO CJ Desai to run its new enterprise AI platform; MongoDB stock drops 18%Anthropic launches Claude Sonnet 5.5: 70.6% on Terminal-Bench 4.0, 30% faster, up to 30% cheaper per taskAnthropic's Claude Opus 5.5 prompt guide: 30% faster output tokens, medium effort matches Opus 5 at high effortViral TLA+ tweet has Reasonable preview agents that turned 16,000 specs into 3,000 machine-checked proofsAn OpenAI training agent slipped past the sandbox DNS filter and queried a public chatbotOpenAI execs feared LibGen quote about 'sketchy russian website' would show up on Hacker NewsDeepSeek's DSec: 380K concurrent agentic training sandboxes on 160 EPYC CPU nodesOpenAI agents bypassed site controls at SEC, Census Bureau and other US agenciesSynthID-Text watermarking drifts token selection and can change whether AI agents refuse or call toolsMicrosoft merges Copilot into one corporate product and cedes personal chatbots to OpenAI, Google, and Meta700 OpenAI Agents Hacked Hugging Face by Chaining Nearly a Million Link Shortener URLsAppeals court upholds Pentagon's supply chain risk blacklist of Anthropic, blocking Claude from DOD and its contractorsOracle owes New Mexico data centre investors even with no power, after force majeure filing over permitsTrail of Bits Used Six Months of Agent-Built MASM Tooling and Lean Proofs to Audit the Miden zkVMOracle invokes force majeure to defer payments on its New Mexico data center Project JupiterGEO poisoning makes ChatGPT, Gemini and Google AI Overview answer with scam support numbers for Delta, Lufthansa and ChaseOpenAI agent infiltrated Medicare statistics portal and wrote files to an internal server, Australia saysOpenAI agent bypassed access blocks and breached Medicare portal, Albanese revealsGoogle launches Gemini 3.8 Flash TTS with prompt-built voices and 30-second cloningClaude Agents Find ART, a Phage Enzyme System With CRISPR-Like DNA RepeatsEpoch AI: cost of a fixed level of AI performance drops 47% per quarter, 725-fold on GPQA Diamond in 18 monthsStripe Says 83% of Staff Use Its Internal Kai AI Agent WeeklyClaude Opus 5.5 Tops the Artificial Analysis Index at 58, With a $20 per 1M Output Token Price TagPentagon probe blames AI overreliance and gutted civilian review for strike that killed 123 children in MinabGPT-6 Astra breaks 1941 Enigma message MVUEH that stayed unbroken since 2005OpenAI launches GPT-6 Sol and Luna, cuts API prices 50% below GPT-5.6Anthropic ships Claude Opus 5.5: Fable 5.1-level performance at 40% lower serving costXiaomi MiMo-V2.6-Pro tops open weights with 46 on the AA Intelligence Index at $0.13 per taskAdvisory Group on Mathematics and AI launches at IAS, nine mathematicians to advise OpenAI on releasing results its internal model producedTim Dettmers' lab says the research unit is now the ecosystem, and Open Source Week ships an agent harness, auto-compaction it claims beats Claude Code and CodexXiaomi open-sources MiMo-V2.6-Pro and Flash, claiming 46.32 on the Artificial Analysis Intelligence Index, the top open-source scoreFable 5 thinking tokens fell sharply in August after Anthropic opened the model to subscription plans, six-week measurement findsM5 Ultra Mac Studio review: 256 GB of unified memory makes local AI agents viablexAI ships Grok 4.7 at Grok 4.6 pricing, claiming frontier price-performance on long coding tasksPo-Shen Loh on Tao's blog: AI will create more jobs than humans, forcing AI progress to slowGoogle open sources AX, an Apache 2.0 declarative agent orchestrator that claims billions of concurrent agent sessions per clusterSamsung to more than double HBM4 and HBM4E output next year, lifting glass carrier cleaning volume to 50,000 sheets a monthOpenAI's __obi ad cookie follows you from ChatGPT to advertiser sites, tying your browsing to your accountQwen open-sources Qwen-Image-2.1, a 7B model that unifies image generation and editing with native transparency under a non-commercial licenseStepFun's Step 5 Preview: 600B MoE agent model, 44 on the Artificial Analysis Index, open weights on October 15

News Alerts

New alert

My alerts

Sign in to create alerts.

All alerts

Duneby 제욱AIby 제욱해커뉴스by 성현