Flue: the open framework for building AI agents
By Flavio
Updated
Tagged: AI
A guide to Flue, the open TypeScript framework for AI agents and workflows from Astro co-founder Fred Schott, covering agents, workflows and durability.
Fred Schott, the co-founder of Astro, built a TypeScript framework for AI agents called Flue. The current release line is 2.x (@flue/cli@2.0.4 and @flue/runtime@2.0.4).
The idea is similar to what Astro did for websites: give developers a clean, open framework without locking them into a single model provider or cloud.
What is Flue?
Flue lets you pick any LLM, write an agent in TypeScript, and deploy it on your own infrastructure. Three things define the approach:
- Open. You aren’t tied to one model vendor or hosting platform.
- Durable. Agents survive restarts and outages and pick up from their last step.
- Familiar. It builds on standard tools like Vite.
Under the hood, Flue runs on Pi, an open agent harness used by tools like OpenClaw (the harness is the loop that calls the model, executes tools, and feeds results back). It bundles with Vite and uses Durable Streams to record events without dropping them. You don’t have to touch those layers directly to use Flue, though it helps to know what sits underneath.
The problem Flue solves
Building a demo agent takes an afternoon: connect an LLM, write a prompt, and call it done. Running one in production is where things break. Servers restart mid-run, model APIs time out, tool calls drop halfway, and conversations lose their history. Flue is built to handle that reliability layer so you don’t end up writing it from scratch.
Agents first (workflows are how you drive them)
In Flue 2, you only author one core primitive: an agent. A “workflow” in the docs isn’t a separate file type; it’s whatever drives that agent, whether that’s flue run from your terminal, a Node script calling start() and init(), the Agent SDK over HTTP, or an orchestrator like Cloudflare Workflows, Inngest, or Temporal.
- An agent holds the durable conversation along with its model, tools, skills, and instructions.
- A workflow triggers and coordinates that agent from CI, a cron job, or a multi-step app flow.
Let’s start by writing an agent.
Your first agent
An agent file begins with the 'use agent' directive. You configure the model with useModel(), and the string your function returns becomes the system prompt:
// src/agents/assistant.ts
'use agent'
import { useModel } from '@flue/runtime'
export function Assistant() {
useModel('anthropic/claude-sonnet-4-6')
return 'You are a helpful assistant. Keep replies short.'
}
Run it locally with the CLI:
npx flue run src/agents/assistant.ts --message "Say hello in five words or fewer."
Pass --id when you want to continue the same conversation across runs, since Flue saves conversations in your configured database.
Tools: bounded jobs inside an agent
When a job has fixed inputs and outputs, like summarizing a ticket or looking up an order, define a tool with defineTool and mount it with useTool. The model chooses when to call it, and your TypeScript code controls what actually runs:
import { defineTool } from '@flue/runtime'
import * as v from 'valibot'
export const lookupOrder = defineTool({
name: 'lookup_order',
description: 'Look up one order by id and return its current status.',
input: v.object({ orderId: v.string() }),
async run({ data }) {
const order = await orders.get(data.orderId)
return { output: { status: order.status, eta: order.eta } }
},
})
Then mount it inside the agent function:
'use agent'
import { useModel, useTool } from '@flue/runtime'
import { lookupOrder } from '../tools/lookup-order.ts'
export function OrderAssistant() {
useModel('anthropic/claude-sonnet-4-6')
useTool(lookupOrder)
return 'Help customers check the status of their orders.'
}
My advice is to keep as much logic as possible inside tools your code owns. The more deterministic your tools are, the fewer surprises you get, leaving the model to improvise only where the task is open-ended.
Tight tool-driven flows also save money, because every extra agent turn resends the conversation history.
What goes into an agent
An agent’s quality comes down to the context and capabilities you give it.
Instructions
Instructions are the job description in plain English. In Flue 2, that’s the string returned by your agent function:
return `
Triage a bug report end-to-end: reproduce the bug,
diagnose the root cause, verify whether the behavior is
intentional, and attempt a fix.`
Tools
Tools are the actions the agent can take: hitting an API, querying a database, or replying to an issue. You create one with defineTool and attach it with useTool.
Skills
A skill is a reusable piece of domain knowledge. If you’ve used skills with coding agents, this works the same way, and you can also install skills from npm.
Sandboxes
A sandbox gives the agent an isolated machine where it can run shell commands and edit files without touching your host system. You attach one through Flue’s sandbox hooks, either locally or via a remote provider like Daytona or E2B.
Subagents
For larger tasks, an agent can delegate work to subagents using the built-in task tool. You define focused roles, and the main agent routes each piece of work to the right one.
Driving agents as workflows
Once you have an agent, you can drive it from anywhere. The simplest workflow is a single flue run command:
flue run src/agents/triage.ts --message "Triage issue 17307." --id issue-17307
From Node, start() boots the runtime in-process and init() gives you a handle to a specific conversation:
import { init } from '@flue/runtime'
import { sqlite, start } from '@flue/runtime/node'
import { Reporter } from '../src/agents/reporter.ts'
await using flue = await start({
agents: [Reporter],
db: sqlite('./nightly.db'),
})
const reporter = init(Reporter, { id: 'nightly-2026-09-11' })
const receipt = await reporter.dispatch('Produce the nightly report.')
const reply = await reporter.read(receipt)
console.log(reply.text)
For multi-step flows that have to survive crashes, put those dispatch and read calls inside a durable orchestrator like Cloudflare Workflows, Inngest, or Temporal. Flue keeps each admitted send durable on its own, while the outer workflow checkpoints receipts between steps.
Channels: connecting agents to Slack and friends
A channel connects your agent to tools like Slack, GitHub, Linear, Discord, or Teams, taking care of incoming events and webhook verification. You add one through the CLI:
flue add channel slack
The command hands your coding agent a Markdown guide to wire the integration into your project. The same command works for sandboxes, databases, and telemetry:
flue add sandbox daytona
flue add database postgres
flue add tooling opentelemetry
Durability: agents that don’t lose their memory
Durability is the best part of Flue’s design. When a server restarts, a model provider times out, or a tool call gets cut off, a durable agent recovers without losing the conversation.
Flue borrows an old database idea: an append-only log as the source of truth. Every prompt, model response, and tool result gets written to Durable Streams like a flight recorder. If one process dies, another reads the log and picks up from the last completed step.
That means accepted work doesn’t disappear, interrupted runs resume automatically, and clients can reconnect without starting over. For side effects that must not repeat or drop, like payments or provisioning, mark the tool durable: true and wrap each effect in step.do(...) so recovery skips steps that already succeeded.
A frontend with @flue/react
When your agent runs behind a server and needs a UI, @flue/react gives you hooks to stream messages directly into a React app:
import { createFlueClient } from '@flue/sdk'
import { FlueProvider, useFlueAgent } from '@flue/react'
const client = createFlueClient({ baseUrl: '/api' })
function Chat() {
const { messages, status, sendMessage } = useFlueAgent({
name: 'triage',
id: 'ticket-8472',
})
// ...
}
useFlueAgent() connects to a running agent and streams updates as they arrive. Outside React, @flue/sdk lets any script or backend service talk to a deployed agent.
A CLI built for coding agents
Traditional framework CLIs install a package and drop in a few boilerplate files, leaving you to adapt everything to your actual codebase. flue add takes another route: it gives your coding agent a Markdown guide tailored to the integration so the agent can wire it into your project directly. Later, flue update upgrades those integrations the same way. The Flue team calls it “shadcn, for your agents”, which is an accurate description.
More in Flue 2.x
A few other pieces ship in 2.x:
- Observability: send telemetry to OpenTelemetry, Braintrust, Sentry, or your own collector.
- Databases: adapters for Postgres, MySQL, Redis, MongoDB, and Supabase.
- Image inputs: agents can accept images alongside text.
- npm skills: share and install skills as ordinary npm packages.
- Offline docs: run
npx flue docs searchandflue docs readso your coding agent can search the exact docs for your installed version locally.
For deployment, Flue targets Cloudflare and Node.js. Use vite dev and vite build when running an HTTP server, or stick with flue run on its own for CI jobs, cron tasks, and personal tools.
Getting started
The fastest setup is to let your coding agent scaffold it using Flue’s starter prompt:
Read https://flueframework.com/start.md then help create my first agent…
If you’d rather set it up yourself (these examples use @flue/cli@2.0.4 and @flue/runtime@2.0.4):
npm install @flue/runtime @flue/cli
npx flue init . --target node
You can also skip the scaffold and create flue.config.ts and src/agents/assistant.ts by hand using the getting started guide. Put your agents in src/agents/, and add vite plus src/app.ts once you need an HTTP server.
My take
Flue gets the fundamentals right: it’s open, works with any model, deploys anywhere, and focuses on the durability headaches that actually bite once an agent leaves your laptop. You can read the full docs at flueframework.com.
Want me to talk about your product? You can sponsor this site.
Related posts about ai: