Skip to content
AnswerWell geo Documentation

Research · 9 min read · Answerwell

Worker Configuration File: Bindings, Durable Objects, Migrations, and Containers

How to set up wrangler.jsonc for Agents, Durable Objects, SQLite storage, Workers AI, Containers, and common deployment mistakes.

This page summarises Cloudflare documentation on the Wrangler configuration file (wrangler.jsonc or wrangler.toml). That file defines your Worker entry point, compatibility settings, and bindings that expose Durable Objects, Workers AI, static assets, Workflows, Containers, and other platform resources to your code as properties on env.

wrangler.jsonc: what the Worker configuration file controls

Section titled “wrangler.jsonc: what the Worker configuration file controls”

The Wrangler configuration file configures your Cloudflare Worker and its bindings. For an agents project, a typical baseline includes name, main, compatibility_date, optional compatibility_flags, Durable Object bindings for each agent class, and provisioning for SQLite-backed agent state.

The wrangler.jsonc file configures your Cloudflare Worker and its bindings. Here is a complete example for an agents project:

— Cloudflare, Configuration

Field Role
name Worker name used at deploy time
main Entry module (for example src/server.ts)
compatibility_date Pins runtime behaviour; docs often say to set it to today’s date when you create the project
upload_source_maps Uploads source maps for debugging
compatibility_flags Often includes nodejs_compat for the Agents SDK
$schema Optional JSON Schema path for editor validation

Broader Worker options—routes, workers_dev, KV, D1, queues—appear in the general Configuration reference and in feature-specific guides; this page focuses on patterns repeated across Agents, Containers, and Durable Objects.

durable_objects.bindings: how agent classes appear on env

Section titled “durable_objects.bindings: how agent classes appear on env”

Each agent class needs a binding so your Worker can reach the correct Durable Object namespace from code.

Each agent class needs a binding:

— Cloudflare, Configuration

Field Description
name Property on env (for example env.CounterAgent)
class_name Must match the exported class name in your entry module exactly

name in bindings becomes the property on env (for example, env.CounterAgent)

class_name must exactly match your exported class name

— Cloudflare, Quick start

Use a descriptive binding name and a different class name when that helps readability or naming conventions:

{
"durable_objects": {
"bindings": [
{
"name": "COUNTER_DO",
"class_name": "CounterAgent"
}
]
}
}

Access the namespace with env.COUNTER_DO while the implemented class remains CounterAgent. See Configuration.

Add one binding per agent class, list every new class in a single migration (or in exports), and re-export each class from your entry file:

{
"durable_objects": {
"bindings": [
{ "name": "CounterAgent", "class_name": "CounterAgent" },
{ "name": "Chat", "class_name": "Chat" },
{ "name": "Scheduler", "class_name": "Scheduler" }
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["CounterAgent", "Chat", "Scheduler"]
}
]
}

Details: Add to existing project and Quick start.

SQLite storage: migrations with new_sqlite_classes vs exports

Section titled “SQLite storage: migrations with new_sqlite_classes vs exports”

Agent state and chat history use SQLite on the Durable Object. You must register each class once—either with a migration or an exports block, not both for the same provisioning model.

Legacy migrations array (still widely documented)

Section titled “Legacy migrations array (still widely documented)”
{
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["CounterAgent"]
}
]
}

new_sqlite_classes enables SQLite storage for state persistence

— Cloudflare, Quick start

AIChatAgent and similar chat agents require this migration:

The new_sqlite_classes migration is required — AIChatAgent uses SQLite for message persistence and stream chunk buffering.

— Cloudflare, Chat agents

Chat-oriented examples also set compatibility_flags: ["nodejs_compat"] and an ai binding; see Chat agent.

exports with storage: "sqlite" (agents configuration guide)

Section titled “exports with storage: "sqlite" (agents configuration guide)”

The agents Configuration guide shows declaring storage per class:

{
"exports": {
"MyAgent": { "type": "durable-object", "storage": "sqlite" },
"ChatAgent": { "type": "durable-object", "storage": "sqlite" }
}
}

When you add another agent class, declare it under exports as in Adding a new agent.

Containers: do not mix exports and migrations

Section titled “Containers: do not mix exports and migrations”

For Container-backed Durable Object classes:

Existing applications that use the legacy migrations array can continue to use it, but exports and migrations cannot be combined.

— Cloudflare, Get started

Container minimal setup uses exports instead of migrations in the current pattern:

The exports entry declares the Durable Object class with SQLite storage. Existing applications that use the legacy migrations array can continue to use it, but exports and migrations cannot be combined.

— Cloudflare, Wrangler configuration

Common binding blocks: Workers AI, assets, Workflows, and more

Section titled “Common binding blocks: Workers AI, assets, Workflows, and more”

Beyond Durable Objects, feature docs add focused sections to the same Wrangler file.

Chat, voice, Think harnesses, and AI Search agents typically include:

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

ai binds Workers AI — no API key needed

— Cloudflare, Chat agent

For the Vercel AI SDK with createAI, install agents, ai, and @ai-sdk/provider, then add the same binding per Vercel AI SDK.

Section titled “AI Search namespace binding (not single-instance ai_search)”

Agents that call create() at runtime need ai_search_namespaces with remote: true because AI Search does not run locally:

The namespace binding (ai_search_namespaces), not the single-instance ai_search binding, is required because the agent calls create() at runtime. The remote option lets wrangler dev proxy requests to your deployed instance, since AI Search does not run locally.

— Cloudflare, Agents SDK

Human-in-the-loop knowledge-base setup adds worker_loaders as well; see Human-in-the-loop knowledge base updates.

Interactive apps (chess demo, Think agent UI) use an assets block—for example directory, binding, optional not_found_handling, and run_worker_first for API or agent routes. Examples: Build an Interactive ChatGPT App and Getting started (Think harness).

Long-running orchestration adds workflows next to agent bindings:

{
"workflows": [
{
"name": "research-workflow",
"binding": "RESEARCH_WORKFLOW",
"class_name": "ResearchWorkflow"
}
]
}

See Build a Durable AI Agent and Run Workflows.

Other bindings (when the feature needs them)

Section titled “Other bindings (when the feature needs them)”
Binding Typical use Doc
vpc_services Private resources such as S3 via Workers VPC Access a private S3 bucket
agent_memory Agent memory namespace Get started
browser + services Browser Run with outbound Worker Outbound Workers
pipelines Stream consumers Fan out a stream
worker_loaders Isolated Worker execution (Code Mode, facets) Durable Object Facets

Leave out binding sections your Worker never uses; each adds deploy-time requirements.

Containers in Wrangler: image, class, and Durable Object wiring

Section titled “Containers in Wrangler: image, class, and Durable Object wiring”

A Container application ties three configuration areas together: the container definition, a Durable Object binding, and class export/storage.

The configuration uses three sections:

containers defines the container image and associates it with a Durable Object class through class_name. durable_objects.bindings makes the Durable Object namespace available to Worker code. In this example, access it through env.MY_CONTAINER. exports declares the Durable Object class and provisions it with SQLite storage.

The class_name in containers and durable_objects.bindings, and the key in exports, must match the exported Durable Object class in your Worker.

— Cloudflare, Wrangler configuration

Minimal pattern:

{
"containers": [
{
"class_name": "MyContainer",
"image": "./Dockerfile",
"max_instances": 10
}
],
"durable_objects": {
"bindings": [
{ "name": "MY_CONTAINER", "class_name": "MyContainer" }
]
},
"exports": {
"MyContainer": { "type": "durable-object", "storage": "sqlite" }
}
}

image points to a Dockerfile, to a directory containing a Dockerfile, or to a fully qualified image reference such as registry.cloudflare.com/<YOUR_ACCOUNT_ID>/<IMAGE>:<TAG>.

— Cloudflare, Get started

Sandbox SDK projects follow the same three-part layout (containers, durable_objects, migrations for Sandbox class) per Sandbox SDK configuration. Agent-attached sandboxes may use scheduling_policy: "durable_object" so the agent can choose the image at start()—see Sandbox.

Legacy changelog examples still show migrations with new_sqlite_classes for containers; prefer the exports flow for new apps per Wrangler configuration.

env environments: staging and production overrides

Section titled “env environments: staging and production overrides”

Define per-environment Worker names, bindings, and vars under env:

{
"env": {
"staging": {
"name": "my-agent-staging",
"vars": { "ENVIRONMENT": "staging" }
},
"production": {
"name": "my-agent-production",
"vars": { "ENVIRONMENT": "production" }
}
}
}

Repeat durable_objects.bindings inside each environment when overrides replace top-level binding lists. Full example: Configuration.

Deploy with wrangler deploy --env staging or the matching environment name.

After you add or rename bindings, regenerate TypeScript types for Env:

Generate types for your bindings:

npx wrangler types

This creates a worker-configuration.d.ts file with the Env type that includes your bindings.

— Cloudflare, Build a Durable AI Agent

The same command appears in Get started for agent memory bindings.

Section titled “Troubleshooting: No such Durable Object class and related mistakes”

If deploy or dev reports that the Durable Object class is unknown, add a migration entry:

{
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["YourAgentClass"]
}
]
}

See Add to existing project and Quick start.

class_name must equal the exported class identifier. A typo in Wrangler or a missing export from main produces binding errors at runtime.

Omitting new_sqlite_classes for AIChatAgent breaks message persistence; always list the chat agent class in migrations or provision it via exports.

Combining exports and migrations for Containers

Section titled “Combining exports and migrations for Containers”

Do not configure exports and migrations together.

— Cloudflare, Wrangler configuration

Pick one provisioning style and migrate legacy apps deliberately.

Preview deployments and container env bindings

Section titled “Preview deployments and container env bindings”

If code uses env.MY_CONTAINER without a matching binding under previews, Preview can fail with error 1101:

If you use env.MY_CONTAINER without declaring the Durable Object binding in your previews block, the binding will not exist in the Preview and your Worker can return a 1101 error.

— Cloudflare, Resources and isolation

Mirror production containers and durable_objects.bindings under previews when you test Containers in Preview.

Examples for the agents package consistently set compatibility_flags: ["nodejs_compat"]. Push notification agents document that nodejs_compat is required for libraries such as web-push—see Push notifications.

  1. Open your wrangler.jsonc or wrangler.toml and confirm every agent or container class used in code has a matching durable_objects.bindings entry with correct name and class_name, following Configuration.

  2. Verify each Durable Object class is listed in migrations (new_sqlite_classes) or exports (storage: "sqlite"), and that Container projects do not mix both mechanisms per Wrangler configuration.

  3. Run npx wrangler types (or yarn / pnpm wrangler types) and confirm generated Env includes your bindings, as described in Build a Durable AI Agent.

  4. Deploy or run wrangler dev for your stack; for Container apps, use npx wrangler containers list and npx wrangler containers info when validating Preview setups per Resources and isolation.

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

If something on this page does not match your project or the official docs, email yimasynthetic@gmail.com with the page URL and the exact statement you want clarified or corrected.