Agents that outlive your servers.
Every model call, tool call and approval is journaled to object storage. Kill the node, redeploy, scale out — each chat picks up at the step it stopped, without paying for the model twice.
import { streamText, wrapLanguageModel } from "ai" import { chatObject, cairnMiddleware, cairnTools } from "@cairnflow/sdk" export const chat = chatObject("Chat", async (ctx, turn) => streamText({ model: wrapLanguageModel({ model: anthropic("claude-sonnet-5-5"), middleware: cairnMiddleware(ctx), // every model call → a step }), tools: cairnTools(ctx, { lookupOrder, refund }, { approve: ["refund"], // waits for a human }), messages: turn.messages, }), ) serve({ services: [chat] })
- llm.generatejournaled1.4s
- tool lookupOrderran once · result in journal0.2s
- llm.generatecalling the model on node-a…
- tool refundnot started
- stream replynot started
kill -9s, one every 10 sWatch a run survive kill -9.
Every completed step lands in S3. Kill the node, replay finished steps in 0 ms, suspend human approvals to bytes, and run on stateless compute with no disks.
Agents spend most of their lives waiting. Waiting should cost bytes, not servers.
Most of an agent's life is spent waiting on a model, a tool or a person. On Cairnflow that waiting lives in the bucket as journals and state, not in a process, a database connection or a disk you keep paying for.
History figures are from the engine's test suite and a 200-turn chat test against a local S3-compatible store.
Agents first. Not agents only.
The same runtime — durable steps, state per key, timers and promises, all on object storage — runs any code that must finish what it started.
AI agents
Chat agents, tool loops and research runs. Model and tool calls become steps, approvals wait on durable promises, streams reconnect after a reload.
cairnTools(ctx, tools, {
approve: ["refund"],
})Build an agent →Durable workflows
Signups, onboarding, document pipelines: many steps, one run per ID, waits of minutes or weeks — on a server or a serverless function.
const clicked = await ctx
.promise("email-link-clicked").get()Write a workflow →Stateful objects
State per user, account or device behind a key. One writer per key at a time, so no locks, no lost updates, no separate state store.
ctx.set("balance", balance + amount)Model state →Sagas and payments
Charge, reserve, ship — and undo the earlier steps when a later one fails for good. Each side effect is recorded, so a retry never charges twice.
catch (e) {
if (e instanceof TerminalError)
await ctx.run("undo", undoCharge)
throw e
}Handle failures →Schedules and background jobs
Server-side cron with time zones, delayed sends, and fan-out to thousands of child jobs — with retries and no external scheduler or queue.
cron: "0 2 * * *", timeZone: "Europe/Berlin",Schedule work →
Webhooks and events
Accept a webhook, acknowledge it once it is durable, process it after. Idempotency keys drop duplicates; per-scope concurrency and rate limits keep noisy tenants in check.
POST /invoke/Orders/handle/send Idempotency-Key: evt_8a1fIngest events →
serve() in TypeScript (Node.js 22.6+), Python 3.11+ or Go 1.25+ on a container, VM or KubernetesfetchHandler on Vercel, Cloudflare Workers, AWS Lambda, Deno or Bun — plus AWS Lambda in Python and GoKeep your AI SDK code. Stop losing its work.
A few lines change. streamText, your tools and useChat stay as they are — cairnflow records each model and tool call as a step, so a retry replays it from the journal instead of calling the provider again.
- Tool approvals wait on a durable promise — approve from the chat, an admin page or a Slack webhook.
- Reload the page mid-answer and
useChatreconnects to the same run. stop()cancels the run; with the streaming transport it also aborts the model call in flight and keeps the partial answer in history.
Building blocks for code that has to finish. Nothing you have to babysit.
Durable steps
Once a step's result is journaled, every retry reads it back instead of running it again — the card is charged once, not on every replay.
await ctx.run("charge", () => charge(order))Humans in the loop
A durable promise suspends the run in storage. The approval can come a minute or a month later, from anywhere.
transport.approve(chatId, id, { approved: true })Streams that reconnect
The answer reaches the browser over SSE: token by token with the streaming transport, a step at a time in request-response mode. A reload picks the stream back up; stop() cancels cooperatively.
useChat({ id: chatId, transport, resume: true })One turn per chat
A virtual object per chat ID keeps the history in state and never runs two turns of the same conversation at once.
chatObject("Chat", run) // keyed by chatIdTimers and schedules
Sleep for three days without a process. Run agents on a server-side cron with a time zone — no external scheduler.
cron: "0 2 * * *", timeZone: "Europe/Berlin"Artifacts
Screenshots, PDFs and long transcripts go to storage beside the run. The journal keeps a reference, not the bytes.
ctx.artifact.put(png, { contentType: "image/png" })No database. No disks. State lives on object storage.
Nodes keep nothing they cannot lose. Each one owns a range of keys through a lease in the bucket; when it dies, another node reads the range back from storage and carries on.
- 01Stateless nodesReplace, restart or add a node without moving data. There is no volume to attach and no replica to rebuild.
- 02Ownership by leaseA node writes to a key range only while it holds the lease, checked with compare-and-swap. A paused or partitioned node cannot overwrite its successor.
- 03Acknowledged means durableA step is confirmed to your code only after its write is in the bucket. What you were told happened survives any crash.
- 04Ranges split as load movesA hot key range splits in two and its halves move to other nodes — no resharding project.
See every step. Query every run.
Open any invocation to read its journal, timeline and trace, and why it is waiting. Retry from a step, cancel, or resume. Invocations are SQL tables, so the stuck run is a query away.
- 0Input{ text: "where is order 4512?" }12 B
- 1Runllm claude-sonnet-5-5ok
- 2Runtool lookupOrderok
- 3Runllm claude-sonnet-5-5ok
- 4Promiseapprove-call_7Qxwaiting
SELECT service, status, count(*) AS n FROM sys_invocation WHERE class = 'active' GROUP BY service, status ORDER BY n DESC
| service | status | n |
|---|---|---|
| Chat | suspended | [n] |
| OrderSync | suspended | [n] |
| Chat | running | [n] |
A runtime you trust with side effects has to be proven, not hoped.
Soak figures are from our test rig on a single-process S3-compatible store with injected request faults and latency.
Run it your way.
- One runtime binary — no coordinator, no etcd, no database
- Your S3-compatible bucket holds everything
- Console with journal, timeline and SQL
- SSO, roles and an audit log built in
- Prebuilt binaries (Linux, macOS), Docker image (
ghcr.io/cairnflowdev/cairnflow), or build from source - TypeScript (
@cairnflow/sdk), Python (cairnflow) and Go SDKs — zero runtime dependencies
- Managed Cairnflow clusters on object storage — no nodes to run
- No public launch date yet; self-host for free in the meantime
- Leave your email to hear when early access opens
Questions
The docs go deeper on every answer.
Do I have to rewrite my agent?
No. With the Vercel AI SDK you wrap the model with cairnMiddleware and the tools with cairnTools; streamText and useChat stay. Other code uses ctx.run around each side effect.
How fast is a step?
A step is confirmed when the batch of the node's shared log that holds it is durable in the bucket, so step latency follows the store you run on — object stores built for low latency answer a write in single-digit milliseconds. Batching keeps a busy node at one write per batch, not one per step, so throughput does not hinge on request count.
How long can a conversation get?
Longer than the payload limit. State, step results and outputs above a threshold are stored as immutable segments in the bucket, and a turn moves only the open tail and the new message, so a chatObject history keeps growing without trimming. We test histories of 8 MiB; a single value read back in one response is capped at 64 MiB. The payload limit still applies to each request body.
How is this different from Temporal, Restate or Inngest?
Mostly where the state lives. Cairnflow keeps journals, state, timers and queues on S3-compatible object storage, and its nodes keep nothing on local disk — there is no database to size, replicate or back up. On top of that: an AI SDK adapter with approvals and reconnecting streams, and SQL over every invocation.
What happens to the stream if the server dies?
The run continues on another node from its last completed step. The step that was in flight runs again, and useChat with resume reconnects the browser to it. Completed model and tool calls are not repeated.
Which languages and platforms are supported?
TypeScript, Python and Go. Install them from their registries: npm install @cairnflow/sdk, pip install cairnflow, and go get github.com/cairnflowdev/cairnflow/sdk/go. In TypeScript, serve() runs on Node.js 22.6 or newer, and the Fetch adapter, fetchHandler, targets Vercel, Cloudflare Workers, AWS Lambda, Deno and Bun (tested on Node.js, not yet on those platforms themselves). The Python SDK needs Python 3.11 or newer and runs as its own server, as an ASGI app or on AWS Lambda. The Go SDK needs Go 1.25 or newer and runs as its own server or on AWS Lambda. The Vercel AI SDK integration is TypeScript only. None of the SDKs has required dependencies. The wire protocol is language-neutral, and all three SDKs pass the same conformance traces.
Can I self-host?
Yes. The runtime is source-available under the Business Source License 1.1 (each version converts to Apache-2.0 after four years; the SDKs are Apache-2.0): you may read, modify and self-host it, including inside commercial products, but not offer it to others as a competing hosted service. Grab a prebuilt binary from GitHub Releases (Linux x86_64/arm64, macOS arm64), run the Docker image (ghcr.io/cairnflowdev/cairnflow), or build from source. It is one process per node and an S3-compatible bucket, with no coordinator and no database. A hosted service, Cairnflow Cloud, is planned — join the waitlist.
Ship the agent. Keep the progress.
Download a release binary or run the Docker image, start a node on your machine, and run a first durable invocation in two minutes.