Build and deploy Flue agents on Cloudflare Workers. Session state is automatically persisted via Durable Objects — no configuration needed. Agents can run on fast virtual sandboxes, mount an R2 bucket as a filesystem, or spin up a full container environment viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/withastro/flue/llms.txt
Use this file to discover all available pages before exploring further.
@cloudflare/sandbox.
Project setup
Create the project
agents is Cloudflare’s Agents SDK — Flue uses it to route HTTP requests to a per-agent Durable Object for session persistence.Create your wrangler.jsonc
Create
wrangler.jsonc at the project root (alongside package.json). Flue merges its own Durable Object bindings into this file at build time — you only need to declare your app-specific bindings here.Create your first agent
Source files live in
.flue/agents/ (or agents/ at the project root for the bare layout — the two never mix).triggers = { webhook: true } tells Flue to expose this agent as an HTTP endpoint at POST /agents/translate/:id.Start the dev server
flue dev --target cloudflare builds your project and starts a Cloudflare Workers dev server (via wrangler) on port 3583. It watches for structural changes — new agents, edited roles, wrangler.jsonc edits — and reloads the worker. For body edits to agent files, wrangler’s own bundler handles hot reload automatically.flue dev --target cloudflare requires wrangler as a peer dependency in your project. It is included in the install step above.Build and deploy
flue build --target cloudflare writes a Workers-compatible artifact to ./dist/. Flue merges its Durable Object bindings into the output dist/wrangler.jsonc. wrangler deploy picks that up via a redirect at .wrangler/deploy/config.json — you only ever edit the root wrangler.jsonc.Hit your deployed agent:Session persistence
When you deploy to Cloudflare, Flue uses Durable Objects to automatically persist session state — message history, context, and sandbox state all survive across requests. A user can revisit a conversation days or weeks later and pick up exactly where they left off. This is built into--target cloudflare. No extra configuration is needed.
Environment variables
Pass--env <path> to load a .env-format file for local development:
Wrangler’s docs use
.dev.vars as the convention for local secrets. The format is identical to .env, and Flue accepts either name — it just needs a path. Using .env works the same for both Node and Cloudflare targets.R2-backed agents
For agents that need persistent storage — a knowledge base, documentation corpus, product catalog — Flue integrates with Cloudflare R2. Mount a bucket directly as the agent’s filesystem and the agent can search it withgrep, glob, and read, just like a real filesystem.
wrangler.jsonc:
Container sandboxes
For agents that need a full Linux environment —git, Node.js, Python, a browser — Cloudflare provides native container support via @cloudflare/sandbox.
- Single container
- Multiple containers
Install the package:Add the Durable Object binding, migration, and container image to Add a Pin the image tag to match the
wrangler.jsonc. Any DO binding whose class_name ends with Sandbox is automatically wired up as @cloudflare/sandbox’s Sandbox class in the generated Worker bundle — you don’t need to re-export it yourself.Dockerfile at the project root:@cloudflare/sandbox version in your package.json — they’re versioned together.Use the sandbox in your agent:Workers AI
Use Cloudflare’s hosted AI models without an API key. Add theAI binding to wrangler.jsonc:
cloudflare/ model ID to init():
cloudflare/... model IDs through env.AI.run() automatically — no API key needed. This will error clearly on --target node.
Sandbox strategy
| Strategy | When to use |
|---|---|
| Empty virtual sandbox | Prompt-and-response agents, stateless transforms |
Virtual sandbox with session.shell() | Small amounts of static context written at startup |
| R2-backed virtual sandbox | Knowledge bases, large document collections |
| Container sandbox | Coding agents, full Linux environments, system tools |