TUNDRA // NEXUS

Mission Control
Curated Links/2026-02-21-code-mode-agents-api
🟢

Code Mode: give agents an entire API in 1,000 tokens

šŸ”—blog.cloudflare.com
February 21, 2026
SIGNAL8/10
#ai #dev #infrastructure

🟢 READ | ā± 6 min | šŸ“” 8/10 | šŸŽÆ AI/DevOps engineers, AI agent developers

TL;DR

Cloudflare introduces Code Mode, a technique for giving AI agents access to entire API schemas using only ~1,000 tokens instead of 1.17 million. Models write executable code instead of specifying separate tools, with safe execution in sandboxed Workers isolates. An open-sourced MCP server provides access to Cloudflare's 2,500+ endpoints with fixed token cost.

Signal

  • Code Mode reduces token consumption by 99.9% for the Cloudflare API (1,000 tokens vs 1.17M) by having models write executable code instead of specifying separate tools
  • The implementation uses two tools (search/execute) that run JavaScript in a sandboxed Dynamic Worker isolate, eliminating the need for tool definitions for each endpoint
  • Open-sourced Code Mode SDK available in Cloudflare Agents, enabling the same pattern for other MCP servers and APIs

What They're NOT Telling You

The approach requires clients to support JavaScript execution in sandboxes, which isn't universally available in all LLM environments yet. Long-term reliability and adoption patterns across different foundation models are still being evaluated, and progressive discovery through code may not provide optimal UX for non-technical workflows.

Trust Check

Factuality āœ… | Author Authority āœ… | Actionability āœ