Cloudflare releases @cloudflare/codemode v0.1.0 with runtime-agnostic SDK architecture
Runtime-Agnostic Architecture
The @cloudflare/codemode package has been completely rewritten to support a modular, runtime-agnostic design. Code Mode continues to enable LLMs to write and execute code that orchestrates your tools, rather than calling them sequentially, resulting in significant token savings and improved model performance on complex tasks.
Key Improvements
New Executor Interface
- Minimal contract for code execution:
execute(code, fns) - Implement your own executor for any code sandboxing primitive or runtime
- Decouples the SDK from specific runtime dependencies
createCodeTool() Function
- Returns a standard AI SDK
Toolfor use in AI agents - New import path:
@cloudflare/codemode/ai - Replaces the previous
experimental_codemode()API
DynamicWorkerExecutor
- Runs generated code in Dynamic Workers
- Network isolation:
fetch()andconnect()blocked by default - Console capture: Logs from
console.log/warn/errorreturned inExecuteResult.logs - Configurable execution timeout (default 30 seconds)
Migration Guide
This release includes breaking changes:
experimental_codemode()andCodeModeProxyhave been removed- The package no longer owns LLM calls or model selection
- Update imports to use
createCodeTool()from@cloudflare/codemode/ai
To upgrade: npm i @cloudflare/codemode@latest
Refer to the Code Mode documentation for complete API reference and additional examples.