Flow Definition
API reference for flow.json.
Flow Definition
A flow is defined by flow.json in flows/<name>/. It declares the DAG: entry node, node list, and routing rules.
Schema
{
"name": "code-review",
"description": "Multi-dimensional code review pipeline.",
"entry": "scanner",
"maxLoop": 3,
"nodes": [
{
"id": "scanner",
"agent": "scanner",
"prompt": "Scan the changes and list findings.",
"onComplete": { "type": "goto", "target": "reviewer" }
},
{
"id": "reviewer",
"agent": "reviewer",
"prompt": "Classify findings by severity.",
"onComplete": {
"type": "switch",
"cases": [["PASS", "return"], ["FAIL", "fixer"]]
}
}
]
}
Fields
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| name | string | Yes | Unique flow name |
| description | string | Yes | Used for flow triggering |
| entry | string | Yes | Entry node id |
| maxLoop | int | No | Max node executions per run |
| nodes | Node[] | Yes | Node definitions |
Node
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| id | string | Yes | Node id |
| agent | string | Yes | Flow-scoped agent dir name |
| prompt | string | No | Task template ($task, $node.output) |
| onComplete | Route | No | Success routing |
| onError | Route | No | Failure routing |
Route
{ "type": "goto", "target": "nodeId" }
{ "type": "switch", "cases": [["PATTERN", "targetOrReturn"], ...] }
{ "type": "return" }
Input Templating
| Variable | Meaning |
|----------|---------|
| $task | Flow input task |
| $<nodeId>.output | Output of a completed node |
Flow Agents
Flow-scoped agents live in flows/<name>/agents/<short-name>/ and must return JSON output for routing. See Flow.