feat(examples): task-graph โ€” a plan of subtasks run as parallel agents, plus a skill to run it on Cloud

Merged
KH
2mo ago
+509-0

What

examples/task-graph: one large engineering task, about a day of work, runs as a graph of parallel coding agents. It also ships a Claude Code skill a customer's agent can use to run the flow on Agent Relay Cloud.

This was built for a prospect whose Claude work gets stuck doing "seven subtasks one at a time". They asked for a graph of subtasks where each node shows its state.

  • task-graph.flow.ts takes a plan (subtasks with dependsOn), or has a planner agent write one.
    • Each subtask starts as soon as everything it depends on has merged. It runs in its own git worktree and branch (f.agent({ cwd })), then merges back. A conflict goes to a resolver agent, gated on the branch actually being merged.
    • Done means a commit on the branch plus a result file, never the agent saying so.
    • Planned subtasks may add at most maxFollowups follow-ups (default 3, and follow-ups can't spawn their own). Without the cap, a 4-subtask test run grew to 20.
    • The full test suite runs once on the integrated result.
    • A Linear-triggered run (flows deploy --on linear:team=โ€ฆ) opens one PR per ticket.
  • example-plan.json: a 7-subtask "team invitations" feature, four waves.
  • skill/run-task-graph/SKILL.md walks the customer's agent through:
    1. setting up the flows CLI and Cloud login;
    2. turning a Linear issue's sub-issues and "blocked by" relations into a plan;
    3. showing the waves and getting a yes;
    4. flows run --cloud --sync-code;
    5. watching progress with flows status --cloud;
    6. bringing the result back with flows sync.
  • examples/tsconfig.json now typechecks the new example.

Depends on

  • #554 (parallel agents, kernel cwd, completion-gate fix). On 2.0.26 the second concurrent agent parks and cwd is refused. Merge after #554.
  • #553 plus AgentWorkforce/cloud#3945 make the Cloud run graph show subtask names and edges. The example works without them, but Cloud then shows agent-4, run-7 and so on.

Verified

  • On #554's branch: examples/task-graph ran with real Claude agents, a 4-subtask diamond, --local-agent.
    • slugify and truncate overlapped for about 32s; index waited for both to merge.
    • Exit 0, completionReason: success, 137s, and the integrated tests passed.
  • npm run typecheck:examples: no errors in task-graph. Three errors elsewhere are already on main (the ramp helper export and URL in stuck-run-triage).
  • flows check examples/task-graph/task-graph.flow.ts: passed.
  • The follow-up cap is not exercised by a real run: in the verified run every agent reported zero follow-ups.

Limits (also in the README)

  • No budget header: a budgeted authored flow runs one step at a time today (authored-budget.ts).
  • Resuming this flow after a runner crash is untested. With concurrent steps, the order of step calls depends on timing.

๐Ÿค– Generated with Claude Code


Summary by cubic

Adds examples/task-graph, a flow that runs one large task as a graph of parallel coding agents, each in its own git worktree and branch, starting once its dependencies have merged. A subtask only counts as done when it has a commit and a result file, and planned subtasks can add up to maxFollowups (default 3) follow-up subtasks mid-run. Also ships a Claude Code skill (skill/run-task-graph) that turns a Linear issue into a plan, gets user approval, and runs it on Cloud, plus a 7-subtask example plan and README.

Plans need not be sorted: dependencies are read after every subtask is registered, and an unscheduled dependency fails closed. Subtask branches are namespaced under task-graph/<base-commit>/<id> so existing repository branches are never reset. Gates check for a parseable result file plus a commit; the planner gate additionally requires an untouched working tree and unchanged HEAD, so a planner that edits files or commits fails instead of leaking changes into the run. Worktree removal is serialized with the other run-branch git operations, and info/exclude is resolved via --git-path so setup works from a linked worktree. A testCommand can be supplied; with neither it nor an npm test script, the run stops as needs_human instead of passing untested.

Depends on #554 for parallel agents and f.agent({ cwd }); without it the example is broken on 2.0.26. Cloud will show generic step names until #553 and AgentWorkforce/cloud#3945 land. No budget header, since budgeted authored flows run one step at a time today. Resuming after a runner crash is untested, and the follow-up cap is not exercised in a real run.


[!NOTE]
Low Risk
New example and documentation only; no changes to SDK, kernel, or production runtime paths.

Overview
Adds examples/task-graph, a new authored flow that runs one large engineering task as a dependency graph of parallel Claude agents, each in its own git worktree and branch, starting only after its dependsOn subtasks have merged back.

The flow validates plans (DAG, ids, caps), optionally uses a planner agent when no plan is supplied, gates completion on commits plus result JSON (not agent claims), handles merge conflicts with a resolver agent, allows capped mid-run follow-ups (maxFollowups), runs the integrated test suite once at the end (or stops as needs_human without testCommand/npm test), and opens a single PR when triggered from a Linear ticket. Git work uses namespaced branches under task-graph/<base-commit>/ and .relayflow/ bookkeeping excluded from merges.

Also ships example-plan.json (7-subtask team invitations), README (Cloud/local/deploy limits), a run-task-graph Claude Code skill for Linear โ†’ plan โ†’ approval โ†’ Cloud run โ†’ flows sync, and includes task-graph/*.ts in examples/tsconfig.json for typechecking.

Depends on a post-2.0.26 SDK for concurrent agents and f.agent({ cwd }); intentionally omits a flow budget header because budgeted authored flows serialize steps today.

Reviewed by Cursor Bugbot for commit bdd6624755d1257530875a24ef70c4b5b02b883e. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • claude session 7371f69d ยท opened via gh pr create ยท last active 2026-09-22