Hydra Orchestration Toolkit
Hydra is a Lead-driven orchestration toolkit. You (the Lead agent) make strategic decisions; Hydra handles operational management (dispatch, retry, health checks, result collection).
Sub-agents output semantic intent (done/needs_rework/replan), not routing
information. Hydra manages the lifecycle; you decide what happens next.
Why this design (vs. other coding-agent products)
- SWF decider pattern, specialized for LLM deciders. Hydra is the AWS SWF / Cadence / Temporal decider pattern.
hydra watchisPollForDecisionTask; the Lead is the decider;lead_terminal_idenforces single-decider semantics. - Parallel-first, not bolted on.
dispatch+depends_on+ worktree +mergeare first-class. Other products (Factory.ai's Droid, Amp, Claude Code subagents) treat parallelism as open research; Hydra makes it the default. - Typed result contract. Workers publish a schema-validated
result.json(outcome: completed | stuck | error, optionalstuck_reason: needs_clarification | needs_credentials | needs_context | blocked_technical). Other products return free-text final messages and require downstream parsing. - Lead intervention points.
hydra reset --feedbacklets the Lead actually intervene at decision points instead of being block-and-join. A stale or wrong run is oneresetaway.
Lead operational rules
Core rules:
- Root cause first. Fix the real implementation problem before changing tests, fixtures, or mocks.
- Do not hack tests to force a green result. If a test is wrong, fix it honestly.
- No silent fallbacks or swallowed errors. Surface failure with
outcome=stuckoroutcome=error.
Agent launch rule:
- When dispatching Claude/Codex through TermCanvas, start a fresh agent terminal with
termcanvas terminal create --prompt "...". - Do not use
termcanvas terminal inputfor task dispatch — it is not a supported automation path.
Telemetry polling:
- Treat
hydra watchas the main polling loop. Do not infer progress from terminal prose. - Before deciding wait / retry / takeover, query:
termcanvas telemetry get --workflow <workflowId> --repo .termcanvas telemetry get --terminal <terminalId>termcanvas telemetry events --terminal <terminalId> --limit 20
- Watch the derived telemetry states:
awaiting_contractmeans the worker has not yet publishedresult.json;stall_candidatemeans the worker may be hung. Trustderived_statusandtask_statusover terminal prose.
Core workflow
The Lead is the decider — Lead reads the codebase, makes the strategic calls, and dispatches workers for the steps that genuinely need a fresh agent process. There is no "researcher" role: the Lead does the research itself before deciding what to build.
hydra init --intent "Add OAuth login" --repo .
# → { workflow_id, worktree_path }
# (Lead reads the code, reviews related modules, decides the plan.)
hydra dispatch --workflow W --node dev --role dev \
--intent "Implement OAuth middleware and its tests following the design in CLAUDE.md" --repo .
# → { node_id, assignment_id, status: "dispatched" }
hydra watch --workflow W --repo .
# → DecisionPoint: dev completed
hydra dispatch --workflow W --node review --role reviewer \
--intent "Independent review of the OAuth change" \
--depends-on dev --repo .
hydra watch --workflow W --repo .
# → DecisionPoint: review completed
hydra complete --workflow W --repo .
Parallel dev
When the Lead identifies independent work streams, dispatch multiple dev workers with isolated worktrees:
hydra dispatch --workflow W --node dev-frontend --role dev \
--intent "Frontend OAuth components and their tests" \
--worktree .worktrees/frontend --repo .
hydra dispatch --workflow W --node dev-backend --role dev \
--intent "Backend OAuth middleware and its tests" \
--worktree .worktrees/backend --repo .
hydra watch --workflow W --repo .
# → DecisionPoint: both completed
hydra merge --workflow W --nodes dev-frontend,dev-backend --repo .
Handling agent results
When watchUntilDecision returns a node_completed DecisionPoint:
Check
outcome:completed— agent finished. Readreport_fileto decide next step.stuck— agent can't proceed. Readreport_filefor what's needed.error— Hydra already retried; if still failing, it reports to you.
Read the
report.mdreferenced byreport_fileto decide:- Dispatch next node →
hydra dispatch ... - Reset for rework →
hydra reset --workflow W --node dev --feedback "..." --repo . - Re-dispatch after reset →
hydra redispatch --workflow W --node dev --repo . - Complete workflow →
hydra complete --workflow W --repo .
- Dispatch next node →
Hydra promotes blocked nodes to eligible automatically, but you decide
when to dispatch. Check newly_eligible in the DecisionPoint to see
what's ready.
Agent role guidance
The role file (in .hydra/roles/<name>.md or shipped builtin) declares
an ordered terminals[] list of CLI / model / reasoning_effort triples.
Hydra always picks terminals[0] for now; future fallback logic walks
the list. The Lead chooses which role to dispatch — the role file
chooses which CLI to invoke and at what reasoning level.
lead — The Hydra decider itself. Not dispatched by hydra dispatch;
this role file codifies what the Lead terminal (the one holding the
lead_terminal_id lock and talking to the human) is supposed to be.
Default: Claude Opus at max reasoning.
dev — Writes code AND the tests that cover it. A dev-produced change is not complete until its test surface covers the new behavior. Default: Claude Opus at max reasoning, codex fallback.
reviewer — Independent cross-model second opinion at the highest available reasoning level. Default: Codex at xhigh, Claude Opus max fallback. Runs on a different model family from dev so blind spots don't overlap. The last line of defense before Lead approves a change.
There is no researcher role: the Lead does the research itself
before dispatching anything. There is no separate tester role either:
dev owns its own test surface, and reviewer provides the cross-model
check that tester used to provide.
You can override the model or reasoning effort per-dispatch via
--model and a project-level role file in .hydra/roles/.
Commands
| Command | Purpose |
|---|---|
hydra init |
Create workflow context |
hydra dispatch |
Dispatch an agent node |
hydra watch |
Wait for next decision point |
hydra approve |
Mark a node's output as approved |
hydra reset |
Reset a node and downstream |
hydra merge |
Merge parallel worktree branches |
hydra complete |
Mark workflow completed |
hydra fail |
Mark workflow failed |
hydra status |
Show workflow state |
hydra list |
List workflows |
hydra ledger |
Show workflow event log |
hydra cleanup |
Clean up workflow state |
hydra spawn |
Direct isolated worker (not a full workflow run) |
After hydra dispatch or hydra watch, always watch
After dispatching nodes, always call hydra watch to wait for the next
decision point. Do not poll manually with tick.
Result contract
Sub-agents write a slim result.json with schema_version: "hydra/result/v0.1"
plus a sidecar report.md. The JSON holds only what Hydra needs for routing;
all human-readable content lives in report.md.
result.json fields:
schema_version,workflow_id,assignment_id,run_id— passthrough IDsoutcome:"completed"/"stuck"/"error"— Hydra uses this for routingreport_file: relative or absolute path to thereport.mdwritten alongside
Hydra rejects any extra fields. Write report.md first, then publish
result.json atomically as the final artifact of the run.
{
"schema_version": "hydra/result/v0.1",
"workflow_id": "wf-...",
"assignment_id": "asg-...",
"run_id": "run-...",
"outcome": "completed",
"report_file": "report.md"
}
report.md is free-form markdown. Recommended sections: summary of what was
done, outputs (file paths + descriptions), evidence (test runs, manual checks),
and a reflection on approach / blockers / confidence.
Ledger
Every workflow action is recorded in .hydra/workflows/{id}/ledger.jsonl.
Use hydra ledger --workflow W --repo . to inspect the event log.