OMH Autopilot — End-to-End Autonomous Pipeline
When to Use
- End-to-end feature implementation from idea to verified, reviewed code
- The user says: "autopilot", "build me", "handle it all", "e2e this"
When NOT to Use
- Single-file changes or trivial tasks (just do them)
- You want to stay in one continuous session (autopilot is multi-session)
- You only need planning (omh-ralplan) or execution (omh-ralph)
Prerequisites
- The
omh plugin must be installed (~/.hermes/plugins/omh/)
Architecture: One Phase Step Per Invocation
Each autopilot invocation reads state, does ONE unit of work, exits. The caller re-invokes.
This preserves fresh context at every level — including during the ralph loop.
Invocation 1: Phase 0 — requirements (or skip)
Invocation 2: Phase 1 — planning (or skip)
Invocations 3-N: Phase 2 — ralph iterations (one per call)
Invocation N+1: Phase 3 — QA cycle [FRESH SESSION]
Invocation M: Phase 4 — validation round [FRESH SESSION]
Final: Phase 5 — cleanup → complete
See references/caller-examples.md for how to drive the loop.
Procedure
Step 0: Resolve Instance and Acquire Lock
Autopilot drives a goal through spec → plan → ralph → QA → validation.
Two autopilot sessions on the same goal would race on autopilot,
ralph, and ralph-tasks state simultaneously. Use per-instance state
- Resolve
instance_id in this order:
- If a confirmed spec exists at
.omh/specs/{name}-spec.md, use
instance_id = "{name}".
- Else if a plan exists at
.omh/plans/ralplan-{slug}.md, use
instance_id = "{slug}".
- Else derive from the goal:
instance_id = kebab(goal)[:60].
- Acquire the autopilot lock:
lock = omh_state(action="lock", mode="autopilot",
lock_key="{instance_id}",
session_id="{HERMES_SESSION_ID or uuid}",
holder_note="autopilot driving {goal_or_plan}")
On acquired=false, report held_by, offer wait/cancel/different
goal. Stale-pid auto-release applies.
- Pass
instance_id to every omh_state call in this invocation
(autopilot, ralph, ralph-tasks).
- When dispatching to ralph in Phase 2, pass the same
instance_id in the delegation context so the ralph subagent
acquires mode="ralph" lock on the same slug.
- Release the autopilot lock at every exit point (paused,
blocked, complete, exception):
omh_state(action="unlock", mode="autopilot",
lock_key="{instance_id}",
session_id="{HERMES_SESSION_ID or uuid}")
Singleton fallback (legacy). Omitting instance_id writes
.omh/state/autopilot-state.json and skips locking. Acceptable only
when running one autopilot at a time.
On Every Invocation: Dispatch
state = omh_state(action="read", mode="autopilot", instance_id="{instance_id}")
- Not found: Fresh start → Smart Detection (below)
- Found: Check
context_checkpoint flag → if true, clear it and exit (phase boundary)
- Check staleness:
state.stale = true → warn, offer fresh start
- Check pause: if
pause_after_phase matches current completed phase → set phase="paused", exit
- Dispatch to current phase handler
Smart Detection (Fresh Start)
When no autopilot state exists, detect artifacts:
- Confirmed spec in
.omh/specs/*-spec.md → create state at Phase 1
- Consensus plan in
.omh/plans/ralplan-*.md → create state at Phase 2
- Ralph complete (
omh_state(action="check", mode="ralph", instance_id="{instance_id}") → phase="complete") → create state at Phase 3
- Nothing → create state at Phase 0
Check for active ralph: omh_state(action="check", mode="ralph", instance_id="{instance_id}") → if active, warn about existing session.
omh_state(action="write", mode="autopilot", instance_id="{instance_id}", data={
"phase": "requirements", "goal": "...", "ralph_iteration": 0,
"qa_cycle": 0, "max_qa_cycles": 5, "validation_round": 0,
"max_validation_rounds": 3, "validation_verdicts": {},
"skip_qa": false, "skip_validation": false, "pause_after_phase": null
})
Phase 0: Requirements
Goal: Ensure a confirmed spec exists.
- Check
.omh/specs/*-spec.md with status: confirmed → found? Set spec_file, advance to Phase 1, exit
- Not found — assess input:
- Concrete (file paths, function names, specific tech): generate inline spec, advance
- Vague: Load
omh-deep-interview and follow it. This phase is interactive.
- Update state:
phase: "planning", spec_file: "<path>". Exit.
For fully autonomous runs: run omh-deep-interview separately first.
Phase 1: Planning
Goal: Ensure a consensus plan exists.
- Check
.omh/plans/ralplan-*.md → found? Set plan_file, advance to Phase 2, exit
- Not found: Load
omh-ralplan, follow its procedure with the spec as input
- Update state:
phase: "execution", plan_file, ralph_iteration: 0, context_checkpoint: true. Exit.
Phase 2: Execution (Ralph Iterations)
Each invocation performs exactly ONE ralph iteration:
- Run one ralph iteration via
delegate_task with the omh-ralph skill context:delegate_task(goal="[omh-role:executor] Follow the omh-ralph skill procedure:
read state, pick the next incomplete task, execute it, verify, update state, exit.",
context="<current ralph state + plan file contents>")
- After ralph completes its step, check ralph status:
ralph = omh_state(action="check", mode="ralph", instance_id="{instance_id}")
active=true → increment ralph_iteration, exit (caller re-invokes)
phase="complete" → advance: phase: "qa", context_checkpoint: true, exit
phase="blocked" → set autopilot phase: "blocked", report, exit
Phase 3: QA Cycling
Each invocation performs ONE QA cycle. Starts in fresh session (context_checkpoint).
If skip_qa: true → advance to Phase 4, exit.
- Gather evidence using the project's actual build/test/lint commands (check for
Makefile, package.json, Cargo.toml, pyproject.toml, etc. to determine the right commands):
evidence = omh_gather_evidence(commands=["<build>", "<test>", "<lint>"])
- If
evidence.all_pass → advance: phase: "validation", context_checkpoint: true, exit
- If failures:
- Increment
qa_cycle. Check 3-strike on qa_error_history. If triggered → phase="blocked", exit
- If
qa_cycle > max_qa_cycles (default 5) → phase="blocked", exit
- Delegate diagnosis to architect subagent (read-only)
- Delegate fix to executor subagent
- Update state, exit (next invocation re-runs QA)
Phase 4: Multi-Reviewer Validation
Each invocation performs ONE validation round. Starts in fresh session.
If skip_validation: true → advance to Phase 5, exit.
- Gather evidence using the project's actual build/test commands:
evidence = omh_gather_evidence(commands=["<build>", "<test>"])
- Delegate 3 parallel reviews (exactly 3 = Hermes concurrent limit):
delegate_task(tasks=[
{goal: "[omh-role:architect] Architectural review:\n{spec + plan}", context: "{evidence}"},
{goal: "[omh-role:security-reviewer] Security review:\n{changed files list}", context: "{evidence}"},
{goal: "[omh-role:code-reviewer] Code quality review:\n{changed files list}", context: "{evidence}"}
])
- Record verdicts in
validation_verdicts
- All APPROVE → advance to Phase 5, exit
- Any REQUEST_CHANGES → delegate fix to executor, increment
validation_round, exit
- If
validation_round > max_validation_rounds (default 3) → phase="blocked", exit
Phase 5: Cleanup
- Set
phase: "complete" (safety — if interrupted, re-invocation retries cleanup)
- Delete state files:
omh_state(action="clear", mode="autopilot", instance_id="{instance_id}")
omh_state(action="clear", mode="ralph", instance_id="{instance_id}")
omh_state(action="clear", mode="ralph-tasks", instance_id="{instance_id}")
- Preserve:
.omh/logs/, .omh/plans/, .omh/specs/
- Report completion summary: goal, phases completed, ralph iterations, QA cycles, validation rounds
State Management
All state via omh_state tool. Atomic writes and staleness handled automatically.
Sentinel Convention
omh_state(action="check", mode="autopilot", instance_id="{instance_id}")
→ {exists, active, phase, stale}
Pitfalls
- Don't loop ralph in a single session. Each ralph iteration is a separate invocation. Context exhaustion is real.
- Don't reimplement ralph. Load the skill, follow its procedure.
- Phase boundaries = fresh sessions. Respect
context_checkpoint.
- Don't skip QA. Ralph verifies per-task. QA catches integration issues.
- Phase 0 is interactive if no spec exists. Pre-create specs for automated runs.
- 3 subagent limit. Phase 4 uses all 3 slots for parallel review.
1---2name: omh-autopilot3description: pipeline: interview→plan→execute→QA→verify (idea→code)4---56# OMH Autopilot — End-to-End Autonomous Pipeline78## When to Use910- End-to-end feature implementation from idea to verified, reviewed code11- The user says: "autopilot", "build me", "handle it all", "e2e this"1213## When NOT to Use1415- Single-file changes or trivial tasks (just do them)16- You want to stay in one continuous session (autopilot is multi-session)17- You only need planning (omh-ralplan) or execution (omh-ralph)1819## Prerequisites2021- The `omh` plugin must be installed (`~/.hermes/plugins/omh/`)2223## Architecture: One Phase Step Per Invocation2425Each autopilot invocation reads state, does ONE unit of work, exits. The caller re-invokes.26This preserves fresh context at every level — including during the ralph loop.2728```29Invocation 1: Phase 0 — requirements (or skip)30Invocation 2: Phase 1 — planning (or skip)31Invocations 3-N: Phase 2 — ralph iterations (one per call)32Invocation N+1: Phase 3 — QA cycle [FRESH SESSION]33Invocation M: Phase 4 — validation round [FRESH SESSION]34Final: Phase 5 — cleanup → complete35```3637See `references/caller-examples.md` for how to drive the loop.3839## Procedure4041### Step 0: Resolve Instance and Acquire Lock4243Autopilot drives a goal through spec → plan → ralph → QA → validation.44Two autopilot sessions on the same goal would race on `autopilot`,45`ralph`, and `ralph-tasks` state simultaneously. Use per-instance state46+ advisory lock.47481. **Resolve `instance_id`** in this order:49 - If a confirmed spec exists at `.omh/specs/{name}-spec.md`, use50 `instance_id = "{name}"`.51 - Else if a plan exists at `.omh/plans/ralplan-{slug}.md`, use52 `instance_id = "{slug}"`.53 - Else derive from the goal: `instance_id = kebab(goal)[:60]`.542. **Acquire the autopilot lock**:55 ```56 lock = omh_state(action="lock", mode="autopilot",57 lock_key="{instance_id}",58 session_id="{HERMES_SESSION_ID or uuid}",59 holder_note="autopilot driving {goal_or_plan}")60 ```61 On `acquired=false`, report `held_by`, offer wait/cancel/different62 goal. Stale-pid auto-release applies.633. **Pass `instance_id` to every `omh_state` call** in this invocation64 (autopilot, ralph, ralph-tasks).654. **When dispatching to ralph in Phase 2**, pass the same66 `instance_id` in the delegation context so the ralph subagent67 acquires `mode="ralph"` lock on the same slug.685. **Release the autopilot lock at every exit point** (paused,69 blocked, complete, exception):70 ```71 omh_state(action="unlock", mode="autopilot",72 lock_key="{instance_id}",73 session_id="{HERMES_SESSION_ID or uuid}")74 ```7576> **Singleton fallback (legacy).** Omitting `instance_id` writes77> `.omh/state/autopilot-state.json` and skips locking. Acceptable only78> when running one autopilot at a time.7980### On Every Invocation: Dispatch8182```83state = omh_state(action="read", mode="autopilot", instance_id="{instance_id}")84```8586- **Not found**: Fresh start → Smart Detection (below)87- **Found**: Check `context_checkpoint` flag → if true, clear it and exit (phase boundary)88- Check staleness: `state.stale = true` → warn, offer fresh start89- Check pause: if `pause_after_phase` matches current completed phase → set phase="paused", exit90- Dispatch to current phase handler9192### Smart Detection (Fresh Start)9394When no autopilot state exists, detect artifacts:95961. Confirmed spec in `.omh/specs/*-spec.md` → create state at Phase 1972. Consensus plan in `.omh/plans/ralplan-*.md` → create state at Phase 2983. Ralph complete (`omh_state(action="check", mode="ralph", instance_id="{instance_id}")` → phase="complete") → create state at Phase 3994. Nothing → create state at Phase 0100101Check for active ralph: `omh_state(action="check", mode="ralph", instance_id="{instance_id}")` → if active, warn about existing session.102103```104omh_state(action="write", mode="autopilot", instance_id="{instance_id}", data={105 "phase": "requirements", "goal": "...", "ralph_iteration": 0,106 "qa_cycle": 0, "max_qa_cycles": 5, "validation_round": 0,107 "max_validation_rounds": 3, "validation_verdicts": {},108 "skip_qa": false, "skip_validation": false, "pause_after_phase": null109})110```111112### Phase 0: Requirements113114**Goal**: Ensure a confirmed spec exists.1151161. Check `.omh/specs/*-spec.md` with `status: confirmed` → found? Set `spec_file`, advance to Phase 1, exit1172. Not found — assess input:118 - **Concrete** (file paths, function names, specific tech): generate inline spec, advance119 - **Vague**: Load `omh-deep-interview` and follow it. **This phase is interactive.**1203. Update state: `phase: "planning"`, `spec_file: "<path>"`. Exit.121122**For fully autonomous runs**: run `omh-deep-interview` separately first.123124### Phase 1: Planning125126**Goal**: Ensure a consensus plan exists.1271281. Check `.omh/plans/ralplan-*.md` → found? Set `plan_file`, advance to Phase 2, exit1292. Not found: Load `omh-ralplan`, follow its procedure with the spec as input1303. Update state: `phase: "execution"`, `plan_file`, `ralph_iteration: 0`, `context_checkpoint: true`. Exit.131132### Phase 2: Execution (Ralph Iterations)133134Each invocation performs **exactly ONE ralph iteration**:1351361. Run one ralph iteration via `delegate_task` with the omh-ralph skill context:137 ```138 delegate_task(goal="[omh-role:executor] Follow the omh-ralph skill procedure:139 read state, pick the next incomplete task, execute it, verify, update state, exit.",140 context="<current ralph state + plan file contents>")141 ```1422. After ralph completes its step, check ralph status:143 ```144 ralph = omh_state(action="check", mode="ralph", instance_id="{instance_id}")145 ```146 - `active=true` → increment `ralph_iteration`, exit (caller re-invokes)147 - `phase="complete"` → advance: `phase: "qa"`, `context_checkpoint: true`, exit148 - `phase="blocked"` → set autopilot `phase: "blocked"`, report, exit149150### Phase 3: QA Cycling151152Each invocation performs **ONE QA cycle**. Starts in fresh session (context_checkpoint).153154If `skip_qa: true` → advance to Phase 4, exit.1551561. Gather evidence using the project's actual build/test/lint commands (check for157 Makefile, package.json, Cargo.toml, pyproject.toml, etc. to determine the right commands):158 ```159 evidence = omh_gather_evidence(commands=["<build>", "<test>", "<lint>"])160 ```1612. If `evidence.all_pass` → advance: `phase: "validation"`, `context_checkpoint: true`, exit1623. If failures:163 - Increment `qa_cycle`. Check 3-strike on `qa_error_history`. If triggered → phase="blocked", exit164 - If `qa_cycle > max_qa_cycles` (default 5) → phase="blocked", exit165 - Delegate diagnosis to architect subagent (read-only)166 - Delegate fix to executor subagent167 - Update state, exit (next invocation re-runs QA)168169### Phase 4: Multi-Reviewer Validation170171Each invocation performs **ONE validation round**. Starts in fresh session.172173If `skip_validation: true` → advance to Phase 5, exit.1741751. Gather evidence using the project's actual build/test commands:176 ```177 evidence = omh_gather_evidence(commands=["<build>", "<test>"])178 ```1792. Delegate 3 parallel reviews (exactly 3 = Hermes concurrent limit):180 ```181 delegate_task(tasks=[182 {goal: "[omh-role:architect] Architectural review:\n{spec + plan}", context: "{evidence}"},183 {goal: "[omh-role:security-reviewer] Security review:\n{changed files list}", context: "{evidence}"},184 {goal: "[omh-role:code-reviewer] Code quality review:\n{changed files list}", context: "{evidence}"}185 ])186 ```1873. Record verdicts in `validation_verdicts`1884. All APPROVE → advance to Phase 5, exit1895. Any REQUEST_CHANGES → delegate fix to executor, increment `validation_round`, exit1906. If `validation_round > max_validation_rounds` (default 3) → phase="blocked", exit191192### Phase 5: Cleanup1931941. Set `phase: "complete"` (safety — if interrupted, re-invocation retries cleanup)1952. Delete state files:196 ```197 omh_state(action="clear", mode="autopilot", instance_id="{instance_id}")198 omh_state(action="clear", mode="ralph", instance_id="{instance_id}")199 omh_state(action="clear", mode="ralph-tasks", instance_id="{instance_id}")200 ```2013. Preserve: `.omh/logs/`, `.omh/plans/`, `.omh/specs/`2024. Report completion summary: goal, phases completed, ralph iterations, QA cycles, validation rounds203204## State Management205206All state via `omh_state` tool. Atomic writes and staleness handled automatically.207208## Sentinel Convention209210```211omh_state(action="check", mode="autopilot", instance_id="{instance_id}")212→ {exists, active, phase, stale}213```214215## Pitfalls216217- **Don't loop ralph in a single session.** Each ralph iteration is a separate invocation. Context exhaustion is real.218- **Don't reimplement ralph.** Load the skill, follow its procedure.219- **Phase boundaries = fresh sessions.** Respect `context_checkpoint`.220- **Don't skip QA.** Ralph verifies per-task. QA catches integration issues.221- **Phase 0 is interactive** if no spec exists. Pre-create specs for automated runs.222- **3 subagent limit.** Phase 4 uses all 3 slots for parallel review.