A typed language for workflows that write down every answer they get.
A Flow program can touch the outside world only through typed calls, and each answer is written down before the program sees it.
Pre-release, Apache-2.0. What isn’t built yet.
- A refund request times out.Flow never resends it on its own.
- The manager approves tomorrow.The run waits on disk.
- A week later someone asks why.Every answer is on record.
One program. Two days. One call to the model.
use "./tools"
pub type Outcome { Sent(Text), Held }
pub flow main(customer: Text, email: Text) -> Result<Outcome, ToolProblem> = {
let draft = tools.draft_reply(email)?
match tools.ask_manager("Send this to ${customer}?\n\n${draft}")? {
Approve => Ok(Sent(tools.send_email(customer, draft)?)),
Deny => Ok(Held),
}
}tools/contract/lib.flow
// Generated by flow build from python module tools. Do not edit.
// from tools.py: Answer
pub type Answer { Approve, Deny }
/// Draft a reply to a customer, as a model would.
// from tools.py: draft_reply
pub flow draft_reply(email: Text) -> Text
/// Put a question to the manager. A person answers it, later.
// from tools.py: ask_manager
pub flow ask_manager(question: Text) -> Answer
/// Send an email and return the mail service's message id.
// from tools.py: send_email
pub flow send_email(to: Text, body: Text) -> TextMonday1 call to the model
A stand-in for the model drafts the reply. This is the run’s one call to the model.
draft_reply → Ok("Sorry, Dana. We have refunded the 40 do…ask_manager is asked. Its library holds the call for a person, so the run waits.
ask_manager … waitingThe run stops here, waiting. Its history is 5 facts, which is all it needs to continue later.
Tuesday0 calls to the model
Resumed from that history. draft_reply’s answer comes from the record, so the model is not called. ask_manager answers Ok("Approve").
draft_reply ← Ok("Sorry, Dana. We have refunded the 40 do…, from the recordask_manager → Ok("Approve")send_email sends the draft, and the run returns Ok(Sent("msg_7f3a")).
send_email → Ok("msg_7f3a")returned Ok(Sent("msg_7f3a"))
Later0 calls to the model
Replay runs the program against the record: 0 Tools called, verdict matched.
replay matched · 0 Tools called
Every step above was recorded by running this program in Flow’s browser engine when the page was built, with stand-in answers for the three Tools. Nothing in the program saves state or resumes anything; the CLI does the same across two real processes. Run it yourself with stand-in scripts.
One rule, four promises.
Every failed call is a case you decide.
A call’s type names the provider’s own refusal and three ways the call can go wrong, and the checker refuses a match that misses one.
Case Did the money move? Ok(Err(e))No: the provider said no NotStarted(why)No: nothing was done NetworkError { sent: false, .. }No: nothing was sent Interrupted(why)Perhaps: only the provider can say NetworkError { sent: true, .. }Perhaps: only the provider can say Every run can be explained, and checked again.
Replay reruns the program from its record, and a saved run is a test.
Replay d1ab8b0cdab0: matched No tools were called.FAIL monday-refund.flowrun against main.flow: diverged at fact 4: the program's call root#2 differs in its toolA run outlasts its process.
A waiting run is a directory on disk, and no answered call is sent again.
draft_reply send_emailTwo processes, two days. The model was asked once.
Parallel work stays under control.
Which task finished first is recorded, so a replay makes the same pick.
9 Choice root picked root/2 10 TaskStop root/1 found running, closing root/1#1 11 TaskStop root/3 found running, closing root/3#1
Your code does the work.
A Tool has no body. Your Python or Rust function answers it, or a person does, later. Flow is not a workflow service: your application starts and resumes runs with the flow command, and owns everything around a run.
# tools.py
from flow_toolkit import tool, Result
@tool
def refund(order: str, dollars: int) -> Result[Receipt, PayError]:
... # your payment clientWhy a language, not a library.
A library can record calls. It cannot make the unrecorded routes absent: one clock read outside its API, and a replay diverges. In Flow those routes do not exist.
The cost is real: you cannot reach for your usual language’s libraries inside Flow. If a job can start again from the top whenever it fails, a queue with retries is enough.
Read why Flow is built this wayWhat people build.
Claude Code’s /feature-dev, PR-Agent’s /improve, Temporal’s AI agent sample and LangGraph’s human-in-the-loop guide, each ported to one Flow program and replayed by the test suite.