Skip to content

Task Flows — graphs and loops ​

Status: Implemented Packages: @orc/core (schema + engine + service), @orc/runner (flow runner), @orc/api, @orc/mcp, @orc/cli

From a new project to a completed task ​

In Projects, create a project and choose its folder on the ORC machine. Leave Create the first task after saving selected to open the existing task dialog with that project already chosen. Existing projects offer Create task in this project.

Describe the expected artifact, acceptance checks and constraints. Pick a ready backend and preview the workflow with View flow. Built-in workflows include their implementation/review skills; the skill field is an optional override. Create saves for later. Create and start saves and starts the selected workflow through the existing bounded runner. If launch fails after saving, Retry start reuses that task. Progress, evidence and review appear in task detail. Explicit starts continue through queued reviewers and human-requested rework even when automatic task polling is disabled; active agents retain the flow timeout rail.

Development with human sign-off waits for approval after independent review. Request changes with concrete feedback to route back to the worker, or approve to complete. A completed task does not merge code or deploy it. Task, workflow and knowledge history remain available after reopening. Backend preflight is a current readiness check; it does not establish native hook enforcement parity.

GitHub issues as tasks ​

Save a github.com Git remote URL in Projects → Configuration and enable Sync repository issues as tasks. The API imports open issues into the project's ordinary task list and polls every minute. Sync now on the project's Tasks page runs a cycle immediately. API, MCP, CLI, search and workflow task references use the same stable ORC task ID. Pull requests are excluded. Existing tasks linked to the same issue are adopted; repeated imports do not create another task.

Issue titles and descriptions are edited in GitHub. ORC retains its own priority, progress, due dates, comments, dependencies and workflow configuration. Ordinary issue labels are copied to tags on first import. Comments are not synchronized. Imported and newly adopted issues have automatic agent execution disabled, including automatic review. You can explicitly start a workflow from task detail.

Connected sessions use the same task ID and the normal session task picker in the session viewer. Session links, local comments, related-task links, priority, progress and workflow settings survive GitHub issue resync. Titles and descriptions remain managed in GitHub.

Status labels is collapsed by default in project configuration. Map each ORC status to one distinct repository label. Defaults are status:todo, status:queued, status:doing, status:review, status:changes-requested, status:blocked, status:paused, status:done and status:cancelled. An open issue without a mapped label is todo. Closed issues map to done, or cancelled when closed as not_planned. An ORC transition to either terminal status closes the issue with the matching reason; an active status reopens it. Outgoing writes change only mapped status labels, preserving other GitHub labels. Missing mapped labels are created in the repository when an ORC status change first needs them; existing label colors and descriptions are preserved.

If multiple status labels conflict, or both sides changed to different statuses since the last sync, the task shows a sync error. Choose the same status on both sides, keep one status label on GitHub, then retry. Authentication, permission, rate-limit and partial-write failures remain visible and retry on the next cycle. Use existing gh auth credentials or the configured GitHub token with repository issue write access. The token stays on the API host.

Existing projects remain opted out. Disabling sync keeps imported tasks; changing repositories keeps historical tasks and stops syncing those from the old repository. Initial import reads open issues, then incremental cycles detect closures and reopenings. Each cycle has a 45-second request budget and a 2,000-result pagination limit; incomplete cycles report an error and retain the previous successful cursor.

REST configuration uses github_sync: { enabled, status_labels } on project create/update; omitting status_labels selects defaults. github_sync_state on projects and github_sync on tasks expose the latest outcome. Run POST /api/projects/{id}/github-sync for an immediate cycle; its {synced_at,error} response must have a null error to indicate success. Status changes from any ORC interface are reconciled on the next cycle. See CLI and MCP.

Why flows ​

ORC's task loop used to hardcode one shape: a worker runs the task's skill, a reviewer checks it, feedback loops back to the worker, and max_review_rounds pauses the task if it cycles too long. Every task got that shape whether it fitted or not, and the only way to change it was to patch task-loop.ts.

Real work has other shapes. Plan before building. Fix, then independently confirm the fix holds. Keep an executor working while a supervisor re-verifies its claims from outside its context. Review one change three ways at once and only proceed when all three agree. Wait for a human at a specific point rather than at the end.

A flow is that shape, declared as data: nodes joined by conditional edges that may cycle.

The core split ​

The graph is deterministic. Only the nodes are agents.

  • packages/core/src/flow-engine.ts is pure. Given a state and a node result it returns the next state plus a list of actions. No DB, no clock (the caller passes now), no agents. Loops, fan-out, joins, and every termination rail are unit-testable without spawning a single LLM.
  • packages/runner/src/flow-runner.ts is the impure half. It applies those actions: spawning sessions, writing the ledger, moving task status, killing cancelled work.

An LLM decides what happened. Nothing else. Where that verdict leads is code.

Anatomy ​

jsonc
{
  "name": "my-flow",             // must match its directory name
  "description": "...",
  "version": 1,
  "entry": "build",
  "isolation": "worktree",       // "shared" (default) or a git worktree per agent lane
  "limits": {
    "max_node_executions": 24,        // total node runs before halting
    "execution_timeout_secs": 14400,  // wall clock for the whole run
    "max_parallel": 4,                // concurrent nodes per task
    "reset_on_revisit": true,         // re-entering a node starts a fresh session
    "halt_task_status": "paused"      // where the task lands when a rail trips
  },
  "nodes": { /* id → node */ },
  "edges": [ /* { from, to, when?, label? } */ ]
}

Nodes ​

FieldApplies toMeaning
kindallagent | command | gate | human | terminal
skillagentSkill name, or $task.skill_name
promptagent, humanNode-specific instructions appended to the skill
backend, modelagentOverride the backend/model; $task.agent_backend etc. also work
roleagentworker (default) or reviewer — sets the session role
outcomesagent, humanDeclared verdicts. Defaults to whatever the outgoing edges reference
on_erroragentOutcome to route on if the node dies. Without it, the run halts
commandcommandShell command to run; exit 0 reports passed, anything else failed
metric_patterncommandRegex with one capture group extracting a number from stdout
routinganyfirst (default, first matching edge wins) or all (fan out)
joinany{ mode: "all" | "any", from: [...], cancel_siblings? }
max_visitsanyHard cap on how many times this node may run
reset_on_revisitagentPer-node override of the run default
task_statusanyStatus to set when the node starts (or, for a terminal, ends in)
varsanyMerged into run vars on entry — this is how a loopback resets state

gate nodes run nothing and route immediately: use them for deterministic branching, fan-out points, and joins. human nodes wait for orc flow resume. terminal nodes end the run and decide the task's final status.

command nodes run a shell command instead of an agent — the external success check a goal loop routes on. The command runs in the task's current worktree (or the project scope when there is no repository), with the node timeout enforced and its output bounded. It holds no worker slot, so a saturated agent pool cannot starve a check. Each run writes run vars named after the node:

VarMeaning
<node>_exitExit code
<node>_outputBounded stdout/stderr tail
<node>_metricNumber captured by metric_pattern, when it parses
<node>_stallConsecutive checks with an unchanged metric; 0 without a metric

The verdict is an ordinary outcome — passed on exit 0, failed otherwise — so edges route it like any agent verdict, and { "var": "<node>_stall", "gte": 3 } is a stall guard. Commands come from flow definitions (the same trust model as jobs: authored by a user or agent in the database), never from edge conditions, which stay declarative.

Edges and conditions ​

Edges are evaluated in order and the first match wins (unless the node sets routing: "all", which activates every match). The bounded-loop idiom is therefore a guarded loopback followed by a catch-all escalation:

jsonc
{ "from": "verify", "to": "done",  "when": { "outcome": "pass" } },
{ "from": "verify", "to": "build", "when": { "all": [
    { "outcome": "fail" },
    { "visits": { "node": "build", "lt": { "var": "max_review_rounds" } } }
]}},
{ "from": "verify", "to": "escalated", "when": { "always": true } }

Conditions are data, never code — a definition is JSON that a user or an agent authored, so it must not be able to execute anything. There is no eval, no expression language. Every condition object is strict: an unknown key is rejected rather than stripped, because a silently stripped key is what turns a guarded loopback into an unguarded one.

ConditionExample
always{ "always": true }
outcome{ "outcome": "fail" } or { "outcome": ["fail", "error"] }
visits{ "visits": { "node": "build", "lt": 4 } } (omit node = self)
executions{ "executions": { "gte": 10 } }
elapsed_secs{ "elapsed_secs": { "gt": 3600 } }
var{ "var": "tests_ok", "eq": true }, also ne/lt/gte/contains/exists
all/any/not{ "all": [ ..., ... ] }

Numeric comparators take a number or { "var": "name" }. That indirection is what lets a shipped flow say "loop while under the task's own budget" instead of baking in a constant.

Three layers keep a mistyped guard from quietly becoming an unconditional edge:

  • an unknown key (lessThan where lt was meant) is rejected, not stripped;
  • a var with no predicate at all is rejected, since it would match whenever it was evaluated;
  • a visits: { node: … } naming a node that does not exist is rejected, since a missing node reads as 0 visits and would always satisfy an lt guard.

What remains is the resolvable case: a { var } operand whose var is absent or non-numeric at runtime makes the comparison false — fail closed, so an unresolvable budget shortens a loop rather than unbounding it.

Definitions are bounded in shape too — nesting depth, value count, node and edge counts, prompt length, and each limits field all have caps — and parsing is total: parseFlowDefinition returns errors and never throws, so one unusable definition cannot abort the loop cycle for every other task.

Run vars ​

Injected at start: task_id, task_title, project_id, skill_name, required_review, max_review_rounds. Nodes extend them via flow_report(vars: …), and a node's own vars are merged when it is entered. Non-reserved vars are rendered into node prompts, which is how a supervisor's directive reaches the executor.

Fan-out and joins ​

routing: "all" on a node activates every matching edge, so several nodes run concurrently:

jsonc
"fan_out": { "kind": "gate", "routing": "all" },
"verdict":  { "kind": "gate", "join": { "mode": "all", "from": ["a", "b", "c"] } }
  • mode: "all" waits for every listed source. mode: "any" fires on the first arrival and, by default, cancels its siblings — that is the race/first-answer-wins pattern.
  • Arrival state resets once a join fires, so joins work correctly inside loops. Arrivals are also stamped with their source's visit count, so a branch that loops back past a join cannot leave an arrival behind that satisfies it on the next round.
  • Fan-in to a node that is not a join is refused (concurrent_reentry): two copies of one node cannot be told apart by a reporting agent, so a join is the construct for converging branches.
  • Fan-out never exceeds capacity. Extra nodes sit as pending rows and drain as worker slots free up, honouring agent_loop.max_workers, the project's max_workers, and the flow's max_parallel. A single-worker install runs the branches one after another instead of failing.
  • Reaching any terminal ends the whole run and cancels branches still in flight.

Fan-out costs roughly N× the tokens. Use it where one reviewer demonstrably misses things, not by default — and note that with the default agent_loop.max_workers of 1 the branches run one after another, so you pay the tokens without gaining wall-clock. Raise max_workers before choosing a custom parallel review graph.

Worktree isolation ​

With "isolation": "worktree", agent nodes work in git worktrees instead of the project checkout, so parallel nodes, or two tasks in one project, never edit the same files. All three built-in flows use it.

  • A node that needs a tree takes the tree of the most recently succeeded node when no running node holds it, so build → review → build stays in one tree. The search covers earlier runs of the same task, so orc-review-only reviews the lane orc-default built, and a reopened task continues its own branch even after its tree was removed.
  • A node that starts while that tree is busy, such as a parallel branch, gets its own <repo>/.orc/worktrees/<task>-<node> on branch orc/task/<task>-<node>. It is cut from the last succeeded lane's commit, or, when the task has no lane yet, from the default branch (origin/HEAD's local branch, then origin/HEAD, then the checkout's HEAD). The base is recorded as git config branch.<branch>.orc-base. A kept branch is reused only when it already contains that base; otherwise the lane becomes <task>-<node>-2, with a matching folder and branch. Characters other than letters, digits, - and _ in a node id become _.
  • A project whose folder is inside a repository runs in the same subfolder of the lane.
  • Each agent is told its worktree and must commit its changes there. Uncommitted work is not carried to other lanes. Parallel lanes are not merged: the next node continues in the last lane to finish, and the other lanes' work stays on their branches.
  • A task with an explicit git_worktree, a resumed node session, or a project folder that is not a git repository keeps the existing behavior.
  • The task's flow panel shows each node's branch and folder.

Two parallel lanes, each in its own worktree

Phone layout

  • When the task becomes done or cancelled, or the run ends, ORC runs git worktree remove (never --force) on the flow's worktrees and keeps the branches. It skips trees a node or an open terminal or chat session is using. A tree with uncommitted or untracked changes is kept, and a task comment names it.
  • Merging or opening a pull request from an orc/task/* branch is up to you; ORC does not push them.

Termination ​

A flow cannot loop forever. Five independent rails, each halting the run and (by default) pausing the task with a comment naming what tripped:

  1. max_visits per node
  2. limits.max_node_executions for the run
  3. limits.execution_timeout_secs wall clock — also swept from outside the graph, so a run whose nodes all hang is still caught
  4. no matching edge after an outcome → no_matching_edge
  5. nothing left to run → stalled, or join_deadlock when branches are parked at a join that can no longer be satisfied

Plus: a node that dies routes through on_error if it declares one, otherwise the run halts with the error attached. A node that ends without reporting anything halts with no_outcome rather than the graph guessing a verdict. Mutually-routing gates trip a chain limit instead of spinning.

describeHalt() turns each reason into a sentence for the task comment and orc flow status.

The node contract ​

A node reports its verdict with the flow_report MCP tool:

flow_report(task: "<id>", node: "verify", outcome: "fail",
            summary: "auth check missing on the delete path",
            vars: { tests_ok: false })

The node's prompt is assembled from its skill plus exactly the outcomes its outgoing edges can route, so the agent is told which verdicts are legal rather than inventing one the graph cannot use. Anything else is rejected with the valid list. command nodes are the exception: the runner records their verdict from the exit code, and each check posts a ledger comment with the result.

The node's prompt lists exactly the outcomes its outgoing edges can route, and anything else is rejected — with one honest exception: a node whose only outgoing edge is a catch-all has no derivable outcome list, so it accepts whatever it is given.

Fallback inference. Skills written against the old protocol drive the task status instead of the flow. If a node's session ends without a report, the outcome is inferred from the status the agent left behind:

Task statusCandidate outcomes (first routable wins)
blockedblocked
reviewsubmitted, reviewed, milestone, ready
doneapproved, pass, verified, complete, submitted
changes_requestedchanges_requested, fail, reject
cancelledblocked

If nothing matches and the node has exactly one declared outcome, that one is used. Otherwise the run halts for a human — an ambiguous guess is worse than a pause.

The ledger ​

flow_node_runs holds one row per node visit: which node, which attempt, its outcome, its summary, its session, its error. Gates and terminals are recorded too, so the row sequence is the actual path taken.

This is the durable-communication idea from the octopus-skill loop-graph pattern: nodes talk to each other through an inspectable record, not by inheriting each other's context. Each node's prompt includes the ledger so far, which means a supervisor can audit an executor's claims while starting from a clean session.

Where flows live ​

SourceLocationNotes
builtinpackages/core/src/flows/builtin.tsCompiled in — the published package ships only dist/index.js, so a filesystem-only default flow would leave npm installs with nothing to run
user~/.orc/flows/<name>/flow.jsonShadows a builtin of the same name — which flow_create requires you to ask for explicitly, since shadowing orc-default re-pipelines every task
project./.orc/flows/<name>/flow.jsonShadows user and builtin
tasktasks.flow_override (JSON column)An inline graph for one task; beats all of the above

Precedence mirrors config loading. Shadowing by name is how you customise orc-default without patching orc.

Definitions are validated on load — unknown edge targets, unreachable nodes, terminals with outgoing edges, a graph with no reachable terminal, a join whose source cannot reach it, an agent node with nothing to do, and edges shadowed by an earlier catch-all are all rejected. An invalid flow is reported by flow_list and the API, not silently skipped.

A run freezes its definition at start (flow_runs.definition), so editing a flow file never changes the shape of a run already in flight.

Built-in SDLC workflows ​

ORC ships three versioned workflow templates. Choose one in the task's Workflow picker and use View flow to inspect it before creating work. No plugin installation or separate flow per development task type is needed. CLI/MCP use the same catalog.

Built-in workflowUse it for
orc-defaultDevelopment: understand, plan as needed, implement, verify and independently review; bounded rework. required_review: false explicitly skips agent review.
orc-human-reviewThe same development process plus human sign-off. Agent review and human approval are always required, even if required_review is false.
orc-review-onlyReview existing work; approve, request changes, or pause when evidence is insufficient.

Development uses the task's assigned skill, defaulting to orc-sdlc when omitted. Its references cover proportional planning, features/refactors, debugging and validation. Review nodes use the same entry point with an explicit independent reviewer role. References load on demand; the entry point is injected once per prompt. Retired skill names remain named-read compatibility routes for saved tasks and frozen flow definitions, while new built-in templates use the two-skill layout. The human-sign-off workflow uses the same build and review contract. Human feedback returns to build while max_review_rounds permits; spent budgets pause for intervention. Approval completes the task, not a merge or deployment.

Knowledge at the right time ​

Every agent node receives the effective orc-sdlc entry point and explicit project/session identity, including reviewers and resumed workers. It directs agents to the delivery and knowledge-review reference before any outcome. Project-edited skill instructions are respected. The backend receives the same lifecycle through the shared flow runner; no host-specific hook is required for this prompt delivery.

Applicable authored retired worker/coder and knowledge-review instructions are retained for workers; reviewers receive authored reviewer/knowledge instructions instead. Supplements identify scope/change and refresh on resume. Unmodified retired playbooks are not injected, and conflicting authored instructions must be surfaced explicitly.

MomentResponsibility
Start/resume/reworkCall context, read task/ledger/feedback, read relevant memories, search knowledge bases, and verify guidance against current code.
Meaningful progressUpdate task comments/session events. Save short durable project facts as memories; check memory_list before writing.
Before any outcomeReview this work unit's memory changes, reconcile contradictions, and record verified reusable knowledge in the project Learnings KB.
Delivery/handoffLog the work unit and include Knowledge in the outcome summary: sources reused, discoveries, KB updates or no durable learning, and unavailable tools.

Tasks/sessions track progress; memories hold short project facts and decisions; KB documents hold verified lessons and procedures; skills hold reusable procedures. A quiet work unit need not create knowledge. Pass the supplied session ID on session and KB writes and the readable project name. Knowledge is evidence, not authorization. Do not store secrets, private transcripts or task noise in shared knowledge.

This release supplies lifecycle instructions and preserves actual tool/audit records. It does not enforce semantic completion of every knowledge step or establish quality gains. Missing tools/checks must be disclosed. Existing configured rule policies remain separate: this template does not activate or weaken tool restrictions, and host-level enforcement still depends on backend capability.

Migration and customization ​

orc-default and orc-review-only are version 2; existing active runs retain the frozen definition they started with. User/project overrides keep their existing precedence. The overlapping orc-plan-build-verify, orc-fix-verify, orc-supervisor, orc-parallel-review and orc-evidence-review built-ins are retired. A task or default configuration naming one receives explicit migration guidance instead of silently running another graph. Select development, human sign-off or review existing work; use a user/project or inline flow for genuinely different routing such as fan-out. The engine continues to support custom planning, joins and supervision graphs.

The engineering approach is informed by Pstack and Ponytail: targeted playbooks, smallest complete changes, connected-code review and reusable lessons. Comparative agent-quality measurements are deferred; process correctness and usability are validated separately.

Goals — loops with an external check ​

A goal is a durable objective ORC works until an external success check passes, within a budget. Where a harness-native loop (/loop, /goal) is invisible to ORC and stops silently when stuck, a goal runs as an ordinary flow: the loop, the budget and the escalation are visible and enforceable here.

POST /api/goals
{
  "objective": "make bun test packages/api pass",
  "check": "bun test packages/api",        // exit 0 = goal met
  "metric_pattern": "(\\d+) pass",          // optional progress signal
  "agents": ["claude", "codex-cli"],        // ladder order, default ["claude"]
  "budget": { "iterations": 30, "tokens": 2000000, "hours": 6 },
  "stall_limit": 3,
  "project_id": "…",                        // or task_id to attach to a task
  "skill": "orc-coder"
}

The generated flow is: one worker stage per allowed agent → a command check after every worker turn → a guarded loopback while the check fails and budget remains. Workers keep their native session across iterations (reset_on_revisit: false), so the loop keeps its conversation, not just its ledger.

  • Budgets: iterations via a visits guard on the check, wall clock via execution_timeout_secs, tokens by accumulating each worker turn's reported usage into tokens_used (best-effort where a backend estimates usage).
  • Stall ladder: when the check's metric does not improve for stall_limit iterations, the loop switches to the next allowed agent; after the last agent it asks a reviewer for a diagnosis, then raises one human request (the task shows blocked) and halts. Without a metric_pattern there is no progress signal, so the ladder never trips on stall — budgets still apply.
  • Verdict: passed when the check passes (task done); halted when a budget or the ladder ends it (task paused); stopped when you stop it. Status is derived from the flow run and the task at read time — never a second synced truth.

Surfaces: GET /api/goals, GET /api/goals/{id} (live status + check history), GET /api/tasks/{id}/goal, POST /api/goals/{id}/stop; MCP goal_create, goal_status, goal_stop. The task detail panel shows iteration and budget left, the current agent stage, stall count, tokens, the last check's exit and output, and the check history on demand. Stopping a goal kills its live sessions like a flow halt; the history stays on the flow.

Goals are long-running work: an active goal's worker is exempt from the absolute session lifetime ceiling while it keeps making progress (idle goal workers are still reclaimed), and infrastructure retries and daemon-restart recovery resume its native session instead of starting fresh. See Live sessions.

Authoring ​

bash
orc flow list                                     # what exists, plus anything invalid
orc flow show orc-default               # nodes, edges, limits
orc flow validate --file ./my-graph.json          # check before running anything
orc flow create   --file ./my-graph.json          # save reusable, to ~/.orc/flows/
orc flow attach <taskId> --file ./my-graph.json --start   # bespoke, this task only
orc flow attach <taskId> --name orc-human-review
orc flow status <taskId>                          # active nodes + ledger
orc flow resume <taskId> --outcome approved       # resolve a human node
orc flow halt   <taskId>                          # stop it, kill live nodes

Agents use flow_list, flow_read, flow_create, flow_attach (pass definition for an inline graph), flow_status, and flow_report. A planner that has just decomposed a task can author the graph for it.

Authoring checklist ​

  • Every non-terminal node needs at least one outgoing edge, and a catch-all last unless every outcome is explicitly routed. Otherwise an unexpected verdict halts the run.
  • Put the guarded loopback before the escalation edge — first match wins.
  • Give every loop a bound: max_visits, or a visits guard on the loopback edge, or both. Whichever you use is shown to the node in its prompt, so a reviewer on its last allowed round knows a rejection escalates.
  • Declare a task_status on agent nodes. A node without one falls back to its role's natural status (doing, or review for a reviewer), but saying so is clearer than relying on that.
  • Declare on_error on any node whose failure has a sensible route. Without it, a crash halts the whole run.
  • Reset stale vars with vars on the node the loop returns to.
  • Name outcomes for what happened (fail, blocked), not for where they go (go_to_build) — the edges own the routing.

HITL ​

Human gates are first-class rather than bolted on:

  • A human node parks the run, sets the task status, and posts a comment saying exactly how to resolve it.
  • orc flow resume <task> --outcome <x> (or POST /tasks/{id}/flow/resume, or flow_report) continues the graph.
  • A human moving the task out of band always wins, whatever the nodes are doing. Authority is decided by who made the change, not by what the graph is up to: a change authored by a human stops the run (or, if a gate is waiting and can route the verdict, answers it), while one authored by an agent or by the flow itself is the normal in-flow protocol and is left alone. Guessing from node status meant a human closing a task whose node was merely queued got silently ignored — and an agent was then spawned on work they had closed.
  • done, cancelled, changes_requested, blocked and paused all reach the flow, not just the three that end a task.
  • A human gate does not burn the execution timeout. Time a run spends awaiting_human is excluded from execution_timeout_secs, and the timeout sweep skips a run parked on a person. Otherwise the wall clock would be a fuse on every gate — four hours on orc-default's defaults — and the halt would cancel the node the human was about to answer.
  • Only a human node pages a human. Agent reviewer nodes also move a task to review, and notifying on those meant one task sent "ready for review" once per review round, each time asking for an approval the flow would immediately override.

In the web dashboard ​

packages/web reads flows through the same API the CLI and MCP use — it adds no flow state of its own.

  • Task detail → Flow. GET /tasks/{id}/flow gives the frozen definition plus the ordered ledger, and the panel draws both: the graph with the active node highlighted, the visit count and budget on each node, and one ledger row per visit carrying its verdict, summary, error, session link and timings. A halted run shows halt_reason with describeHalt()'s sentence. Clicking a node lists the edges leaving it, in routing order, with each condition rendered as prose.
  • The graph is drawn, not laid out by a library (src/lib/flow-graph.ts): a deterministic left-to-right layering with loopbacks classified as back edges and routed under the boxes, because "this edge goes backwards" is the thing a flow picture has to show and is exactly what a generic DAG layout hides. Flows are at most 128 nodes, so the layout stays a pure, unit-tested function with no dependency.
  • Human gates are resolvable from the UI. The offered outcomes are derived from the waiting node's outgoing edges — the same derivation declaredOutcomes() does server-side — so the menu is whatever the graph can actually route. A node with only a catch-all edge has no derivable list, and the form asks for a free-text outcome instead, matching the API, which accepts any outcome there. Submitting posts the comment and calls POST /tasks/{id}/flow/resume; POST /tasks/{id}/flow/halt sits behind a confirmation, since it kills live sessions.
  • Flows browser (/flows) lists every flow with its source, marks the one a task with no flow_name will run, flags a flow that shadows another of the same name, and renders the broken[] array from GET /flows with its validation errors — an invalid flow is visible before a task tries to run it.
  • Flow picker on task create and edit writes flow_name (clearing it falls back to the default). A task carrying an inline flow_override says so instead of offering a name, because the override wins.
  • queued reads as pending, not in progress. The board maps it into Todo and the dashboard counts it with todo, because the runner sets queued while a node waits for a worker slot. Cards whose real status differs from their column say which status they are in.
  • Task detail → Goal. A task with a goal shows its loop state above the flow: verdict, iteration and budgets left, current agent stage, stall count, tokens, the last check's exit/metric and expandable output, and the check history as a quiet summary that expands to one slim row per check. An escalated goal (the ladder's human rung) says so while the task is blocked; Stop sits behind a confirmation.

The web UI needed two additions to the API, both additive: GET /flows returns default_flow (the configured agent_loop.default_flow, without which "which flow will this task run" is unanswerable from outside the server), and each ledger row carries created_at (a queued or human-parked node has no started_at, so it is the only clock for how long it has been waiting — the same COALESCE the runner uses).

Schema ​

flow_runs
  id, task_id, project_id, flow_name, flow_source, definition (frozen snapshot),
  status (running|completed|halted|cancelled), active, visits, joins, vars,
  node_executions, paused_secs, halt_reason, started_at, ended_at

flow_node_runs
  id, flow_run_id, task_id, node_id, node_kind, attempt, retry,
  status (pending|running|awaiting_human|succeeded|failed|cancelled|skipped),
  outcome, summary, error, skill_name, gateway_session_id, resume_session,
  created_at, started_at, ended_at
  UNIQUE (flow_run_id, node_id, attempt, retry)

tasks
  + flow_name TEXT
  + flow_override TEXT (JSON)

goals
  id, task_id, flow_run_id, objective, spec (JSON), status (active|stopped),
  created_at, updated_at

A goal's live status is not stored: it is derived from its flow run and task (goalStatusFromRun), so the record cannot drift from the work it describes.

status = completed means the graph reached a terminal — including an escalation terminal that pauses the task. status = halted means a rail tripped. The two are worth distinguishing when reading a run: one is a designed outcome, the other is the safety net.

Node rows are keyed (flow_run_id, node_id, attempt, retry): attempt is the graph visit, retry distinguishes sessions within one visit. Finished runs are pruned with the rest of the history (pruneHistory, 30 days by default); running ones are kept whatever their age.

For debugging, GET /tasks/{id}/flow and orc flow status carry each node's gateway_session_id, which is the route from a suspicious verdict to the agent's actual transcript, plus per-node timings and any error text.

Prior art ​

  • Strands graph_loops — cycles via conditional edges, with max_node_executions, execution timeouts, and reset-on-revisit as explicit safety rails.
  • Graph engineering with Claude Code — nodes / edges / shared state; each node must be a loop that ships on its own; graphs cost real tokens, so they are opt-in.
  • AI-native development specifications — PM → Engineer → QA with binary verdicts and conditional loopback; acceptance criteria are what the verifier judges against.
  • octopus-skill — an executor plus an independent supervisor that re-verifies from clean context, communicating through a durable, inspectable ledger rather than shared context.

Released under the MIT License.