# Code Mode: Let the Code do the Talking - Sunil Pai, Cloudflare

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

[AI Engineer](https://www.youtube.com/@aiDotEngineer) · Published 2026-04-19 · 19:40 · S tier · Agents and MCP

[Watch on YouTube](https://www.youtube.com/watch?v=8txf05vVVl4) · [All RatTube videos](/tube)

## Summary

Sunil Pai presents [code mode](/lore/one-program-can-replace-several-tool-calls) as a response to tool calling across large APIs. Instead of asking the model to make each call separately, an execution environment lets it write a program that uses the available operations.

The talk extends that idea into stateful and long-running programs as possibilities to explore. Pai also discusses agent-readable documentation, [useful errors](/lore/errors-are-part-of-the-interface), discovery, and capability-based security as parts of the developer experience.

## Section notes

- [1:12](https://www.youtube.com/watch?v=8txf05vVVl4\&t=72s): Large APIs and longer runs expose limits in ordinary tool calling.
- [4:06](https://www.youtube.com/watch?v=8txf05vVVl4\&t=246s): A slide example shows a DDoS-response prompt. The live demo lists Workers through code mode.
- [7:37](https://www.youtube.com/watch?v=8txf05vVVl4\&t=457s): Writing a script provides the analogy for composing API operations.
- [14:13](https://www.youtube.com/watch?v=8txf05vVVl4\&t=853s): Long-running workflows and per-user interfaces are proposed directions.
- [17:32](https://www.youtube.com/watch?v=8txf05vVVl4\&t=1052s): Documentation, useful errors, discovery, and capability-based security support agents.

## Key concepts

- [code mode](/lore/one-program-can-replace-several-tool-calls)
- [useful errors](/lore/errors-are-part-of-the-interface)

## Our take

Sunil Pai explains code mode, where the model writes code against an API instead of making JSON tool calls, and why that scales better, with sandboxing and capability-based security. This stack ships a code mode surface, and this is the idea behind it.

## Related videos

- [The Future of MCP — David Soria Parra, Anthropic](/tube/future-of-mcp-david-soria-parra)
- [Code Mode: Giving AI Agents an Entire API in 1,000 Tokens (With Demos)](/tube/code-mode-agents-entire-api)
- [All Code Is Slop (Except Mine) — Lauren Tan, SpaceXSI](/tube/all-code-is-slop-except-mine-lauren-tan)
- [How We Build Effective Agents: Barry Zhang, Anthropic](/tube/building-effective-agents-barry-zhang)

Summary based on the transcript. Written 2026-11-15.
