From d7ee3a52d48762b9df2a9bd65f85886fc1c671f0 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Fri, 20 Feb 2026 13:33:45 +0000 Subject: [PATCH 1/4] Add @cloudflare/codemode v0.1.0 changelog entry --- .../2026-02-20-codemode-sdk-rewrite.mdx | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx diff --git a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx new file mode 100644 index 00000000000000..6f9ea8c476939c --- /dev/null +++ b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx @@ -0,0 +1,72 @@ +--- +title: "@cloudflare/codemode v0.1.0: a new runtime agnostic modular architecture" +description: "The Code Mode SDK has been rewritten with `createCodeTool()`, `DynamicWorkerExecutor`, and a new `Executor` interface that allows for Bring Your Own (BYO) sandbox." +products: + - agents + - workers +date: 2026-02-20 +--- + +import { TypeScriptExample, WranglerConfig } from "~/components"; + +The [`@cloudflare/codemode`](https://www.npmjs.com/package/@cloudflare/codemode) package has been rewritten into a modular, runtime-agnostic SDK. Code Mode lets LLMs write and execute TypeScript that orchestrates your tools, instead of calling them one at a time. The new `Executor` interface is runtime agnostic and comes with a prebuilt `DynamicWorkerExecutor` to run generated code in a [Dynamic Worker Loader](/workers/runtime-apis/bindings/worker-loader/). + +## Breaking changes + +- Removed `experimental_codemode()` and `CodeModeProxy` — the package no longer owns an LLM call or model choice +- New import path: `createCodeTool()` is now exported from `@cloudflare/codemode/ai` + +## New features + +- **`createCodeTool()`** — Returns a standard AI SDK `Tool` to use in your AI agents. +- **`Executor` interface** — Minimal `execute(code, fns)` contract. Implement for any code sandboxing primitive or runtime. +- **`sanitizeToolName()`** — Converts MCP-style tool names (hyphens, dots) to valid JS identifiers +- **`needsApproval` filtering** — Tools with `needsApproval` are automatically excluded from code generation. + +### `DynamicWorkerExecutor` +Runs code in a [Dynamic Worker](/workers/runtime-apis/bindings/worker-loader/). It comes with the following features: + +- **Network isolation** — `fetch()` and `connect()` blocked by default (`globalOutbound: null`) when using `DynamicWorkerExecutor` +- **Console capture** — `console.log/warn/error` captured and returned in `ExecuteResult.logs` +- **Execution timeout** — Configurable via `timeout` option (default 30s) + +## Usage + + + +```ts +import { createCodeTool } from "@cloudflare/codemode/ai"; +import { DynamicWorkerExecutor } from "@cloudflare/codemode"; +import { streamText } from "ai"; + +const executor = new DynamicWorkerExecutor({ loader: env.LOADER }); +const codemode = createCodeTool({ tools: myTools, executor }); + +const result = streamText({ + model, + tools: { codemode }, + messages, +}); +``` + + + +## Wrangler configuration + + + +```jsonc +{ + "worker_loaders": [{ "binding": "LOADER" }], +} +``` + + + +See the [Code Mode documentation](/agents/api-reference/codemode/) for full API reference and examples. + +## Upgrade + +```sh +npm i @cloudflare/codemode@latest +``` From d8f7886508544909a90f1ac9273bdf642d3d14b1 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Fri, 20 Feb 2026 13:34:30 +0000 Subject: [PATCH 2/4] remove utils --- .../changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx index 6f9ea8c476939c..14198c1d9e0ff1 100644 --- a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx +++ b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx @@ -20,8 +20,6 @@ The [`@cloudflare/codemode`](https://www.npmjs.com/package/@cloudflare/codemode) - **`createCodeTool()`** — Returns a standard AI SDK `Tool` to use in your AI agents. - **`Executor` interface** — Minimal `execute(code, fns)` contract. Implement for any code sandboxing primitive or runtime. -- **`sanitizeToolName()`** — Converts MCP-style tool names (hyphens, dots) to valid JS identifiers -- **`needsApproval` filtering** — Tools with `needsApproval` are automatically excluded from code generation. ### `DynamicWorkerExecutor` Runs code in a [Dynamic Worker](/workers/runtime-apis/bindings/worker-loader/). It comes with the following features: From c5394a67f95d0af72c013cd8f7851862cb82b38b Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Fri, 20 Feb 2026 08:53:02 -0500 Subject: [PATCH 3/4] Apply suggestion from @elithrar --- .../changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx index 14198c1d9e0ff1..347f78c2c97194 100644 --- a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx +++ b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx @@ -9,7 +9,9 @@ date: 2026-02-20 import { TypeScriptExample, WranglerConfig } from "~/components"; -The [`@cloudflare/codemode`](https://www.npmjs.com/package/@cloudflare/codemode) package has been rewritten into a modular, runtime-agnostic SDK. Code Mode lets LLMs write and execute TypeScript that orchestrates your tools, instead of calling them one at a time. The new `Executor` interface is runtime agnostic and comes with a prebuilt `DynamicWorkerExecutor` to run generated code in a [Dynamic Worker Loader](/workers/runtime-apis/bindings/worker-loader/). +The [`@cloudflare/codemode`](https://www.npmjs.com/package/@cloudflare/codemode) package has been rewritten into a modular, runtime-agnostic SDK. + +Code Mode lets LLMs write and execute TypeScript that orchestrates your tools, instead of calling them one at a time. The new `Executor` interface is runtime agnostic and comes with a prebuilt `DynamicWorkerExecutor` to run generated code in a [Dynamic Worker Loader](/workers/runtime-apis/bindings/worker-loader/). ## Breaking changes From 70f6118072ff6cd5a9d7416ab07e3db1cd18f7f1 Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Fri, 20 Feb 2026 08:56:05 -0500 Subject: [PATCH 4/4] Apply suggestion from @elithrar --- .../changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx index 347f78c2c97194..f9a8ec5556ae0a 100644 --- a/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx +++ b/src/content/changelog/agents/2026-02-20-codemode-sdk-rewrite.mdx @@ -11,7 +11,9 @@ import { TypeScriptExample, WranglerConfig } from "~/components"; The [`@cloudflare/codemode`](https://www.npmjs.com/package/@cloudflare/codemode) package has been rewritten into a modular, runtime-agnostic SDK. -Code Mode lets LLMs write and execute TypeScript that orchestrates your tools, instead of calling them one at a time. The new `Executor` interface is runtime agnostic and comes with a prebuilt `DynamicWorkerExecutor` to run generated code in a [Dynamic Worker Loader](/workers/runtime-apis/bindings/worker-loader/). +[Code Mode](https://blog.cloudflare.com/code-mode/) enables LLMs to write and execute TypeScript that orchestrates your tools, instead of calling them one at a time. This can (and does) yield significant token savings, reduces context window pressure and improves overall model performance on a task. + +The new `Executor` interface is runtime agnostic and comes with a prebuilt `DynamicWorkerExecutor` to run generated code in a [Dynamic Worker Loader](/workers/runtime-apis/bindings/worker-loader/). ## Breaking changes