Glossary
Code mode
An agent pattern in which the model writes code that calls tools through an API inside a sandbox, instead of issuing one tool call at a time.
Checks run on our GPUs in Switzerland. Request payloads are not stored.Security
What Code mode means
In code mode, the model does not emit tool calls one by one. It writes a short program that calls tools through a generated API, and that program runs in a sandbox. Cloudflare described the approach as “Code Mode” in 2025, and Anthropic’s engineering post “Code execution with MCP” describes the same idea. The benefits are fewer model round trips, less context spent on intermediate results, and access to ordinary programming constructs such as loops.
The trade-off is visibility. A single generated program can fire dozens or hundreds of tool calls that no human reads before they run, and a loop can repeat a harmful call many times.
The practical control point is the sandbox’s tool proxy: every call the code makes has to go through it, so a pre-execution guard placed there sees each individual call, whatever the program looks like.
Related terms
How Code mode connects to the rest of the vocabulary.