Code Mode

Code Mode is an approach in which an AI agent writes code that calls multiple tools and processes their results, instead of issuing tool calls one at a time.

1 articleLast mentioned

Code Mode is a way of connecting large language model agents to tools. Rather than emitting one tool call per turn, the model writes a program that calls the tools as functions, and that program runs in a sandbox. The name came into wide use in 2025, when Cloudflare introduced it as a method of presenting Model Context Protocol (MCP) tools to a model as a TypeScript API.

With conventional tool calling, tool definitions and the output of every call accumulate in the context window. In Code Mode the code can chain tools with loops, conditionals and parallel calls, filter intermediate results inside the sandbox, and return only the final output to the model, which reduces token use. Anthropic described the same idea in 2025 as code execution with MCP, and coding agents, MCP servers and gateways have implemented it in various forms.

This entry is based on AIPOST articles and widely known facts. If something is wrong, please send us a correction request.

Articles covering this entry

  • Claude Code's Code Mode Runs Tools From JavaScript and Trims Token CostsAI in Practice ·

    Anthropic has added an experimental feature called Code Mode to Claude Code that changes how the coding agent uses its tools.

    Read article

Found a mistake or missing an entry?

Wiki entries are based on AIPOST articles and widely known facts. If an entry is wrong, send us a correction request and we will check and fix it. Names from new articles are added to the wiki after the article is published.