Skip to content
AnswerWell geo Documentation

Research · 6 min read · Answerwell

Agents SDK Install, Companion Packages, AI SDK Pairing, and TypeScript Decorators

How to install the Cloudflare Agents SDK, optional packages, AI SDK v6 or v7 peers, upgrades from agents-sdk, and fix @callable() decorator errors.

This page summarizes Cloudflare documentation on installing and upgrading the Agents SDK (agents on npm) and the companion packages you add for chat, reasoning, code execution, voice, MCP, and AI SDK models on Workers. Most installs start with one core package; you only add @cloudflare/* and ai packages when your agent uses those features.

The Agents SDK ships as the npm package agents. For a new or existing Worker or Vite project, install it with your package manager:

npm i agents
yarn add agents
pnpm add agents
bun add agents

To pick up the latest release after a changelog update, Cloudflare documents the same pattern with @latest, for example in Agents can respond to MCP elicitation requests:

npm i agents@latest

For React front ends that talk to an agent, Add to existing project states that React bindings are included in agents, so no extra React-specific Agents package is required. For Hono, install hono-agents alongside agents:

npm i agents hono-agents

agents-sdk → agents: rename and migration

Section titled “agents-sdk → agents: rename and migration”

Older projects used the package name agents-sdk. Cloudflare renamed the package to agents:

We’ve renamed the Agents package to agents!

— Cloudflare, npm i agents

After installing agents, remove the deprecated package and update imports:

npm i agents
npm uninstall agents-sdk
grep -r 'agents-sdk' .

Replace every agents-sdk reference in source with agents (editor find-replace or a scripted replace). All future SDK updates are published only to agents.

Companion packages: what to install for each feature

Section titled “Companion packages: what to install for each feature”

The core agents package is enough for many Workers agents. Optional @cloudflare/* packages are added when you use a specific harness or channel. The table below maps common goals to packages documented in this cluster (install only what you use).

Goal Packages to add (npm example) Documented in
Chat UI / chat agents @cloudflare/ai-chat, ai, @ai-sdk/react, @ai-sdk/provider Chat agents
Workers AI via AI SDK (createAI) agents, @cloudflare/ai-chat, ai, @ai-sdk/provider, zod Agents SDK
AI SDK models + Workers binding agents, ai, @ai-sdk/provider; vendor provider only if needed AI SDK
Think harness @cloudflare/think, @cloudflare/computer, @cloudflare/ai-chat, agents, ai, zod, @ai-sdk/provider Think
Browser automation agents, @cloudflare/codemode, ai, zod Browser agent
Voice channel @cloudflare/voice, agents Voice
MCP server handler agents, @modelcontextprotocol/server@2.3.1, zod MCP Server
OpenCode harness agents@latest, @opencode/sdk@2, @opencode/plugin@2 OpenCode
Web push agents, web-push Push notifications

Changelog entries for broad SDK releases often upgrade several companions together. For example, Agents SDK adds background sub-agents and a unified turn entry point documents:

npm i agents@latest @cloudflare/think@latest @cloudflare/ai-chat@latest @cloudflare/codemode@latest @cloudflare/voice@latest

If you use only chat, a smaller set is enough—for example Agents SDK v0.14.0:

npm i agents@latest @cloudflare/think@latest @cloudflare/ai-chat@latest

MCP-focused updates may only need Think and Code Mode, as in MCP and Code Mode updates:

npm i agents@latest @cloudflare/think@latest @cloudflare/codemode@latest

For MCP server APIs, MCP Server documents:

@modelcontextprotocol/server is an optional peer dependency of agents, so your package manager does not install it for you. Use the exact version required by your installed Agents release.

Pin the version your Agents release expects (the example uses @modelcontextprotocol/server@2.3.1).

AI SDK v6 and v7: peer dependencies and pairing

Section titled “AI SDK v6 and v7: peer dependencies and pairing”

Cloudflare Agents packages work with Vercel AI SDK majors 6 and 7. Agents SDK packages support AI SDK v6 and v7 states:

The agents, @cloudflare/ai-chat, @cloudflare/codemode, and @cloudflare/think packages now support AI SDK v6 and v7. Existing applications can remain on v6 when updating these packages. Applications can also adopt v7 without changing the Cloudflare Agents APIs they use.

Supported peer ranges and matching majors:

AI SDK @ai-sdk/react
ai@^6 @ai-sdk/react@^3
ai@^7 @ai-sdk/react@^4

Install line for AI SDK v7 with current Agents companions:

npm i agents@latest @cloudflare/ai-chat@latest @cloudflare/codemode@latest @cloudflare/think@latest ai@^7 @ai-sdk/react@^4

Think adds the same pairing rule for apps using that harness. When updating Think alone, v6 apps do not have to migrate streaming or telemetry integrations first—the changelog notes that Think normalizes streaming, tool completion events, and telemetry across both AI SDK versions.

For Workers AI and AI Gateway provider packages tied to AI SDK v6, an older pinned set appears in Agents SDK v0.3.0 with AI SDK v6 support:

npm install agents@^0.3.0 workers-ai-provider@^3.0.0 ai-gateway-provider@^3.0.0 ai@^6.0.0 @ai-sdk/react@^3.0.0 @ai-sdk/openai@^3.0.0

Use that block when you intentionally align with those provider major versions; for greenfield work, prefer the latest agents@latest plus the v6 or v7 pairing table above.

AI SDK documents optional peers for model routing:

The provider needs ai@^7 and @ai-sdk/provider@^4. Both are optional peer dependencies of agents.

npm i agents ai @ai-sdk/provider

Add a vendor AI SDK provider (for example @ai-sdk/openai or @ai-sdk/anthropic) only when you pass that vendor’s model objects; catalog IDs do not require a vendor package. The same page applies to AI Gateway’s Vercel AI SDK integration.

Installing npm packages does not enable Workers AI by itself. AI SDK and OpenCode show adding an AI binding in Wrangler.

JSON:

{
"ai": {
"binding": "AI"
}
}

TOML:

[ai]
binding = "AI"

OpenCode also requires nodejs_compat, Durable Objects, and migrations in Wrangler; see OpenCode for the full configuration.

TypeScript: @callable() and TC39 decorators

Section titled “TypeScript: @callable() and TC39 decorators”

If the dev server throws SyntaxError: Invalid or unexpected token around @callable(), Add to existing project and Quick start give the same fix—set compile target so Vite’s esbuild downlevels decorators:

{
"compilerOptions": {
"target": "ES2021"
}
}

Common mistakes when installing Agents SDK packages

Section titled “Common mistakes when installing Agents SDK packages”
  • Staying on agents-sdk: Future fixes ship only to agents; uninstall agents-sdk and update imports (npm i agents).
  • Mismatched AI SDK majors: Using ai@^7 with @ai-sdk/react@^3 (or v6 with @ai-sdk/react@^4) violates documented peer ranges (AI SDK v6 and v7 support).
  • experimentalDecorators: true: Breaks @callable() at runtime despite a clean build (Quick start).
  • Assuming MCP server is installed transitively: Install @modelcontextprotocol/server at the version your agents release expects (MCP Server).
  • Upgrading agents without companions you import: If the app imports @cloudflare/ai-chat or @cloudflare/think, upgrade those to @latest together when changelog posts list a bundle (for example v0.17.0).
Section titled “Related install docs outside the core agent”

This cluster also includes install snippets for other stacks that are not the Agents SDK itself: Analyze data with AI (@anthropic-ai/sdk), Sandbox (@cloudflare/sandbox@latest), and Workers OAuth Provider 1.x (@cloudflare/workers-oauth-provider@latest for MCP OAuth). Use those packages only when you follow those guides—not as a default Agents SDK install.

  1. Confirm package.json lists agents (not agents-sdk) and that any @cloudflare/*, ai, and @ai-sdk/* versions match the v6 or v7 pairing from Agents SDK packages support AI SDK v6 and v7.

  2. Run grep -r 'agents-sdk' . in the project root; there should be no remaining imports after migration (npm i agents).

  3. Verify tsconfig.json has "target": "ES2021" and does not set "experimentalDecorators": true if you use @callable() (Quick start).

  4. If you call Workers AI from the SDK, confirm Wrangler defines an [ai] binding named as in your code (AI SDK), then start the dev server and exercise one agent route from Quick start or your app’s entry.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or clarify it.