← Back
Cloudflare
Cloudflare releases @cloudflare/codemode v0.1.0 with runtime-agnostic architecture
Cloudflare Workers · releasesdkfeaturebreaking-change · developers.cloudflare.com ↗

@cloudflare/codemode v0.1.0 Released

Cloudflare has released a major rewrite of the @cloudflare/codemode package, transitioning it to a modular, runtime-agnostic SDK designed to power agent workflows. Code Mode enables LLMs to write and execute code that orchestrates multiple tools at once, rather than calling them individually—yielding significant token savings, reduced context window pressure, and improved model performance.

Key Breaking Changes

The update introduces several breaking changes developers should be aware of:

  • Removed experimental_codemode() and CodeModeProxy — The SDK no longer owns LLM calls or model selection, allowing greater flexibility in how you integrate it with different AI frameworks.
  • New import pathcreateCodeTool() is now exported from @cloudflare/codemode/ai instead of the root package.

New Features

createCodeTool() returns a standard AI SDK Tool compatible with popular AI frameworks like the Vercel AI SDK. This enables seamless integration into your existing agent architectures.

Executor interface provides a minimal contract with a single execute(code, fns) method, making it easy to implement custom code execution sandboxes or integrate with any runtime environment.

DynamicWorkerExecutor

The bundled DynamicWorkerExecutor runs code in Cloudflare's Dynamic Worker environment with production-ready features:

  • Network isolationfetch() and connect() are blocked by default (globalOutbound: null) for secure code execution
  • Console capture — Logs from console.log(), warn(), and error() are captured and returned in execution results
  • Configurable timeout — Execution limits default to 30 seconds but are customizable per invocation

Getting Started

To upgrade, install the latest version:

npm i @cloudflare/codemode@latest

Configure your Wrangler project to include a worker loader binding:

[[worker_loaders]]
binding = "LOADER"

Then create a code tool and integrate it into your AI agent using the Vercel AI SDK or similar framework. See the Code Mode documentation for full API reference and additional examples.