Stage Configuration Reference
Audience: Users — Pipeline authors configuring stage execution, model overrides, artifacts, and protected paths.
For global credentials, endpoints, installation, and run commands, see the Configuration Reference. For contract authoring rules, see the Pipeline Authoring Guide.
Stage Configuration
Global Harness and Per-Stage Runtime Overrides
Runtime selection belongs in the active global config. Every field in a stage override is optional, and an empty override is valid.
harness: opencode
model_effort: medium
stage_overrides:
Plan:
harness: codex
model: gpt-5.6
effort: xhigh
Review Plan:
harness: codex
effort: high
Implement:
model: openai/gpt-5.6-codex
effort: high
goal: false
Review Code:
model: openai/gpt-5.6-mini
iterations:
2:
model: openai/gpt-5.6-codex
goal: true
4:
model: openai/gpt-5.6-pro
effort: high
goal: falseConfiguration constraints:
- Override keys are case-sensitive stage names. A key must match the stage name in
hpilot.yamlexactly to affect that stage. - Valid stage override fields are exactly
harness,model,effort,goal, anditerations; each threshold value accepts onlyharness,model,effort, andgoal, so nested schedules and unknown fields are rejected. A model must be a non-empty string.goalaccepts only a YAML boolean; null, strings, numbers, lists and mappings are rejected with the exact field path. - Harness and effort names are normalized to lowercase. Override keys remain case-sensitive, and model identifiers preserve their casing.
stage_overrides: nullor an omitted mapping disables overrides. Use{}for an intentionally empty stage entry; a null stage entry is invalid.iterationsmay be empty. Its keys must be unquoted canonical positive decimal YAML integers such as1,2, or10; zero, negatives, booleans, floats, quoted numbers, leading zeroes, signs, separators, and alternate-base spellings are rejected.
Resolution happens independently for each harness-backed stage:
- Start with the global
harnessand the stage-levelharness,model,effort, andgoalfields. An entirely omittedgoalresolves to false. - Apply every threshold less than or equal to the current stage iteration in ascending numeric order, changing only the fields present at each threshold.
- If effort remains unset, use global
model_effort; if model remains unset, preserve the selected harness default.
Command stages do not resolve or record any of these settings. Omitting a model or effort sends nothing, preserving the harness default.
The Review Code example starts with openai/gpt-5.6-mini and inherited global medium effort, switches to openai/gpt-5.6-codex at iteration 2, then switches to openai/gpt-5.6-pro and high effort at iteration 4. Iterations 1–5 therefore use mini/medium, codex/medium, codex/medium, pro/high, and pro/high. Goal mode in the same example resolves disabled/enabled/enabled/disabled/disabled across visits 1–5 because an omitted goal resolves false, threshold 2 enables it, and threshold 4 disables it again. Thresholds mean “starts at iteration,” not “only on iteration,” and fields inherit independently until a later threshold replaces them. A threshold at 1 applies after the ordinary stage fields and can change the first visit.
The schedule advances only after a successful routed revisit increments the stage's existing iteration counter. A failed attempt and its retry use the same iteration and therefore the same threshold unless the active config is deliberately edited between attempts. Harness Pilot reloads the complete active home or workspace-local config before every attempt, so a live edit takes effect at the next attempt boundary without advancing the schedule.
Every effective runtime change uses normal adapter selection and continuation safety. A harness change selects that adapter, while a harness, model, effort, or goal-mode change prevents reuse of an incompatible retry session. Selecting a different threshold that produces the same effective runtime does not reset continuation. Explicit false disables an inherited true value without affecting other fields.
goal: true is an opt-in Codex-only native persisted goal. It makes all physical automatic turns inside one native operation count as one Harness Pilot logical completion; the stage contract and verifier still decide acceptance. An inherited true value combined with a non-Codex effective harness fails preflight at the responsible stage or threshold path, while false is neutral. Command stages ignore goal settings because they do not resolve agent runtimes. Goal mode checks the SDK's required protocol surface and requires codex-cli 0.158.0 or newer; it fails closed rather than falling back to ordinary turns.
Standalone task startup, daemon task startup, and hpilot doctor validate the base plus every distinct cumulative threshold runtime, including thresholds beyond a pipeline stage's max_iterations. An inherited value is never discarded to make a later harness valid; for example, switching to Cursor while inheriting an explicit effort is rejected before launch with the stage and threshold in the error.
| Harness | Acceptance and destination |
|---|---|
| Codex | Any normalized value; sent to the SDK turn. |
| Claude | Any normalized value; sent through SDK options. |
| OpenCode | Native advertised model variant, encoded as provider/model#variant and applied to the session on every turn. Effort-only overrides resolve the configured/server-default model first; unknown variants fail explicitly, with no legacy reasoningEffort fallback. See the OpenCode guide. |
| Antigravity | A choice advertised in the ACP session for the selected model. |
| Cursor | No effort channel; every explicit value is rejected before launch. |
| Mock | Any normalized value; retained for propagation tests. |
Harness Pilot trims and lowercases every non-empty effort string. Static config validation checks only whether the adapter has an effort channel and passes the normalized value through. Codex, Claude, and Mock forward the normalized value to their runtime. Antigravity resolves it against the session's effort choices after selecting the model. OpenCode validates the variant against the server's model catalog. Harness Pilot never silently drops an explicit value, and preflight checks the effective stage slice so a global model_effort combined with a Cursor stage blocks the run unless that stage is outside the slice.
A deterministic first-attempt rejection from a harness is reported as Harness configuration rejected. It ends the stage without consuming the remaining retry budget. Transient transport, provider, and runtime failures continue through normal retry handling.
For agent stages, max_retries limits completed agent turns across fresh launches, resumed launches, and in-session continuations. A blocked contract or verifier evaluation can continue in the same session only while slots remain. A failed launch with no completed turn still consumes one slot; provider overload retries that repeat the same unfinished prompt do not. Command stages continue to count each command launch as one attempt.
After validation, stderr reports the stable settings for the attempt:
[Review Code] Harness: opencode, model: openai/gpt-5.6-codex, effort: medium, goal: disabled, iteration threshold: 2, config source: workspace-localEdits made during an attempt apply at the next attempt, stage, retry, or routed visit. The before and after phases within one attempt use the same captured effective hook pair. Changing only hooks does not reset retry continuation; changing the resolved harness, model, effort, or goal mode does. JSON Running entries and daemon stage_start events include runtime_iteration_threshold when a threshold applies, alongside the effective runtime, iteration count, maximum iterations, and config source; the field is absent for base-only and schedule-free attempts. Usage stays attributed to the effective harness, model, and effort actually launched, while session metadata also records the effective goal mode.
Legacy migration
For one deprecation window, Harness Pilot reads these legacy keys and warns once per load: agent_tool or agent becomes harness; stage_agents becomes the per-stage harness field; and top-level stage_models becomes the per-stage model field. The older nested llm.stage_models key remains ignored; move those values into stage_overrides.
hpilot use rewrites runtime settings with canonical keys only while preserving complete iteration schedules, empty schedules, numerically ordered integer thresholds, and verbatim model identifiers. Different global legacy and canonical values are rejected. Defining a per-stage harness or model in both a legacy mapping and stage_overrides is also rejected, even when the values match. Legacy mappings normalize to schedule-free overrides. This normalization layer is planned for removal in the next breaking release.
Self-Refining Review Loop Example
This pattern enables autonomous correction loops without a separate fix stage.
stages:
- name: Implement
- name: Review Code
max_iterations: 5
max_iterations_next_stage: Verify
prompt: |
Review the implementation and edit the code directly when focused fixes are needed.
Do not use `APPROVED` status if this run edited any code or tests.
Use `APPROVED` status only when the code is ready for verification and this run made no code or test edits.
contract:
fields:
Findings:
description: Key issues found during the review.
example: |
- Retry coverage does not assert the exhausted-attempts path.
Required Changes:
description: Concrete fixes required before approval.
example: |
- Add a regression test for the exhausted retry path.
routes:
APPROVED:
description: The implementation passed review and move to verification.
next_stage: Verify
CHANGES_MADE:
description: This review run applied focused fixes, so the updated implementation must be reviewed again.
next_stage: Review Code
- name: VerifyContract Rules:
- No Top-Level Next: Contract stages MUST use
contract.routesfor branching. - Status Match: Route keys MUST appear in the emitted YAML
Statusfield (capitalized). Lowercasestatusis rejected with a clear error message. - Injections: Injected fields MUST have a corresponding entry in
contract.fieldsorcontract.field_definitions. - Self-Referencing Routes: Self-referencing routes (where
next_stageequals the stage's ownname) SHOULD usemax_iterationswithmax_iterations_next_stageto prevent unbounded loops. - Required Tasks: Optional
contract.required_taskslists fixed work items that must appear in the artifact'sCompleted TasksYAML list before any route passes. See Pipeline Authoring Guide for configuration and behavior.
Contract route fields:
| Field | Type | Default | Description |
|---|---|---|---|
next_stage | str or null | null | Target stage; omission makes the route terminal. |
description | str or null | null | Route meaning rendered in contract guidance. |
injections | list[str] | [] | Defined artifact fields promoted to the target stage. |
ignore_max_iterations | bool | false | Preserve this contract route instead of replacing it with max_iterations_next_stage when the limit is reached. |
When a route injects nonempty fields, Harness Pilot appends them to the target stage's prompt inside one <handoff> block headed Messages from previous stage:. Field headings, order, and text are preserved; no block is added if none of the selected fields has content. Prompt template variables such as {latest_contract_findings} continue to receive the field value directly.
ignore_max_iterations must be an unquoted YAML boolean; strings and integers are rejected. A route cannot set it to true while its next_stage points directly back to the containing stage because that would bypass the maximum iteration limit indefinitely. It may be used on routes to another stage and terminal routes. The field is accepted but inert when the containing stage has no max_iterations, and it affects only route replacement rather than iteration counting or resets.
Stage Field: backup_artifacts
Declare backup_artifacts: [list, of, paths] on any stage to automatically copy artifact files to .hpilot/backups/<stage_name>/<timestamp>/ after the stage completes successfully (passes post-run evaluation and valid artifact validation). Backups are best-effort — missing source files are skipped with a warning and do not abort the pipeline.
Example:
stages:
- name: Spec
backup_artifacts:
- .hpilot/artifacts/spec.md
- .hpilot/artifacts/plan.mdBehavior:
- A stage with
backup_artifacts: []or without the field performs no backup. - Paths must be relative children of the task workspace and must not contain
... - Paths resolve against the submitting task's workspace in both standalone and daemon mode. Sources or backup destinations that escape through symbolic links are skipped.
- Each successful stage completion creates a new timestamped backup directory (format:
YYYY-MM-DDTHH-MM-SS, UTC). Previous backups are preserved — no overwrite. .hpilot/backups/is never wiped by the pipeline's artifact reset..hpilot/artifacts/cleanup is skipped when files are present, preserving pre-written or seeded artifacts across pipeline restarts.- Backup occurs only after successful stage completion — failures or retries do not trigger a backup.
See the full reference in Pipeline Authoring Guide for daemon-mode behavior and edge cases.
Stage Field: keep_artifacts
Declare keep_artifacts: [list, of, paths] on any stage to block it if the named artifacts are missing during post-run evaluation. Harness Pilot checks Path.exists() before allowing the stage to complete. Missing files produce a block decision with a remediation message directing the agent to recreate them.
See the full reference in Pipeline Authoring Guide for path rules, deduplication, daemon-mode behavior, and failure-before-teardown isolation.
Stage Field: cleanup
Declare cleanup: [list, of, paths] on any stage to sweep files at the declared paths before the lifecycle before hook and stage executor. For directories, all contents are removed recursively while preserving the directory itself; regular files and symlinks are removed directly. A deletion failure fails the attempt and skips both lifecycle hooks and the executor. Use cleanup on stages that produce their own artifacts and need a clean slate. Avoid it on stages that depend on upstream artifacts.
Cleanup paths must be relative children of the workspace root. The workspace root itself (.), absolute paths, and paths containing .. are rejected.
Example:
stages:
- name: Implement
cleanup:
- .hpilot/artifacts
- .hpilot/backupsSee the full reference in Pipeline Authoring Guide for path validation rules, interaction with keep_artifacts, and safety warnings.
Stage Fields: max_iterations and max_iterations_next_stage
Set max_iterations on a stage to cap how many times it may be visited (including contract route-backs). The counter increments on fresh visits only (not on retries), never resets on success, and triggers forced routing when reached. After a successful, contract-valid completion at the configured count, the pipeline forces a route to max_iterations_next_stage instead of following normal contract routing unless the selected contract route sets ignore_max_iterations: true. The ordinary limit route suppresses contract routing, top-level next_stage, outgoing injections, and reset_iterations for that completion; an ignoring route instead follows the normal successful-completion path with its injections and resets intact. Default is 0 (disabled). Stages with max_iterations > 0 log the current iteration count at stage start (e.g., iteration 1/5) in both stderr output and JSON logs, and include iteration_count and max_iterations in stage-start events. Omitting max_iterations_next_stage is accepted without a warning and means sequential advance for non-ignoring routes. The route option never resets or decrements the visit counter and is inert when max_iterations is disabled.
Example:
stages:
- name: Review Code
max_retries: 3
max_iterations: 5
max_iterations_next_stage: VerifySee the full reference in Pipeline Authoring Guide for iteration counting semantics, fallback behavior, and interaction with end_stage_name.
Stage Field: reset_iterations
Add reset_iterations to a stage to reset the visit counters of named downstream stages after this stage completes successfully. This is useful in review loops where a broader delivery validation stage should give downstream review stages a fresh iteration budget.
Example:
stages:
- name: Review Plan
max_iterations: 3
max_iterations_next_stage: Implement
reset_iterations:
- Review Code
- Review Docs
contract:
routes:
APPROVED:
next_stage: Review Code
CHANGES_MADE:
next_stage: ImplementWhen Review Plan completes successfully, the visit counters for Review Code and Review Docs are reset to 0. The next visit to either stage logs iteration 1, giving that stage a fresh max_iterations budget.
Validation rules:
- Entries must reference existing stage names (case-sensitive). Unknown targets are rejected at config time.
- A stage cannot include its own name in
reset_iterations(self-reset is invalid). - Duplicate entries are deduplicated in order.
- Absent or empty lists are no-ops.
- Resets visit counters only; target stages keep their current failure retry counts (
max_retries).
See the full reference in Pipeline Authoring Guide for runtime semantics, logging, and event details.
Global Instructions: instructions
Use the optional top-level instructions string in hpilot.yaml for short, durable execution-context rules that must reach every harness-backed stage spawned by Harness Pilot. The field is opt-in; an absent, null, empty, or whitespace-only value adds nothing and preserves the existing stage prompts byte for byte. Other value types are invalid.
instructions: |
You are running as an agent launched by Harness Pilot.
Do not create, edit, move, or delete files under `.proposals/`.
stages:
- name: Plan
prompt: Create the implementation plan.
- name: Implement
prompt: Implement the approved plan.Harness Pilot places the global <instructions> block before the stage prompt on every attempt and routed revisit. When the stage uses the default prompt, its stage instruction and objective appear in separate <instructions> and <request> blocks. Harness Pilot then appends any routed <handoff>, <read_only_paths>, retry feedback, and <contract_guidance>, in that order. It leaves a blank line between generated blocks and a blank line just inside each tag. Text from the stage template and objective keeps its internal formatting.
After an execution failure, a fresh retry carries the details in <retry_feedback> and a resumed retry uses <continuation>. A contract error produces <correction_feedback> followed by <contract_guidance> on either kind of retry. Feedback sent within an active session also uses <correction_feedback>.
The field applies only to harness-backed stages launched by Harness Pilot. A command stage receives its configured shell command unchanged, and a chat opened directly in the same repository outside Harness Pilot does not receive these instructions. Use AGENTS.md for repository-wide guidance that should also reach interactive chats. hpilot validate --show-guidance displays the effective global instructions once before per-stage contract guidance, the full text is printed once at pipeline start, and the run log records a GlobalInstructions entry with their length and digest once per stage visit without copying the full text on every retry.
instructions is advisory prompt context, not a permission boundary. A model can disobey it. Use per-stage read_only_paths for supported write detection or native denial.
Global Config: disabled_skills
Add a top-level disabled_skills list in hpilot.yaml to selectively disable project-local agent skills before a pipeline run. This prevents skill sets that conflict with Harness Pilot's own workflow and contract enforcement from interfering with autonomous execution.
disabled_skills:
# Individual skill directory names (not skill set names)
- brainstorming
- speckit-specify
- openspec-proposeValidation rules:
- Each entry must be a string matching the exact directory name installed under the agent's project-local skills directory (e.g.,
.claude/skills/,.agents/skills/). - Entries must not contain
/or\(path separators) and must not be.or..(directory traversal). Invalid entries cause Harness Pilot to exit with an error at startup. - Skill set names like
superpowers,speckit, oropenspecare not valid entries — use individual skill directory names instead.
Behavior:
- At pipeline start, Harness Pilot first restores any skills left behind by a previous unclean shutdown, then moves each listed skill from the project-local skills directory to
.hpilot/backups/skills/<adapter>/(where<adapter>isclaudeorcodex;opencodeandcursorhave no project-local skills directories and are skipped). - After the pipeline finishes (success, failure, or interrupt), all moved skills are restored to their original locations.
- Global skills directories (
~/.claude/skills/, etc.) are never touched. - The default scaffolds (
simpleandspeckit) includedisabled_skillslisting every individual skill directory name from the superpowers, speckit, and openspec skill sets.
Adapter directory mapping:
| Adapter | Project-local skills directory |
|---|---|
claude | .claude/skills/ |
codex | .agents/skills/ |
opencode | None (OpenCode uses .opencode/agents/ for its own agent definitions, which does not map to Harness Pilot's skills concept) |
cursor | None (Cursor has no project-local skills directory) |
See the full reference in Runtime and Daemon — User Guide for the skill disable/restore lifecycle.
Stage Config: read_only_paths
Add a per-stage read_only_paths list in hpilot.yaml to block write-tool calls targeting matching file paths during that stage and inject a read-only-paths section into the stage prompt so the agent knows which paths are off-limits upfront. This prevents coding agents from modifying source code or config files during design stages where only specs and artifacts should be written, while allowing full write access during implementation stages.
stages:
- name: Plan
read_only_paths:
- "src/**"
- "pyproject.toml"
- "tests/**"
cleanup:
- .hpilot/artifacts
max_retries: 5
next_stage: Review PlanBehavior:
- When a stage has
read_only_pathsset, Claude, Cursor, Codex, and Antigravity share one Git-backed guard. OpenCode uses ordered native and session permission rules plus programmatic MCP write admission through a process-local configuration overlay. - The Git-backed guard protects tracked and untracked files visible to Git. Git-ignored paths are intentionally outside its scope.
- A pattern with an ignored or uncovered static prefix produces a warning that names the pattern and is skipped. Other covered patterns remain active.
- Detected changes fail the attempt and remain in the working tree; Harness Pilot never restores or deletes them.
- Independent nested repositories are resolved from the protected prefix, even when an outer repository ignores them.
- During nested repository discovery, permission-denied subdirectories are skipped only when Git confirms they are ignored. Accessible ignored trees are still searched for independent repositories. Permission failures for non-ignored directories, directly selected scan roots, or protected Git-visible files still abort the guard; the guard cannot protect repositories hidden inside an inaccessible ignored directory.
- When
read_only_pathsis empty or absent for a stage, no adapter-level read-only enforcement is active for that stage. - Adapter-level read-only enforcement is per-stage: stages with
read_only_pathsget write protection; stages without it run without enforcement. - When
read_only_pathsis non-empty, the stage prompt includes a<read_only_paths>block listing each pattern and directing the agent to leave matching files untouched. - Post-run verifier evaluation continues to work independently.
Validation rules:
- Each entry must be a non-empty, relative path string. Patterns use path-segment glob matching:
*matches within one path segment, while**matches zero or more path segments. For example,src/*.pymatchessrc/foo.py,src/**/*.pyalso matchessrc/sub/bar.py, andsrc/**matches everything undersrc/. - Absolute paths and paths containing
..are rejected at config validation time. - Patterns are resolved relative to the workspace root.
- If a
read_only_pathspattern matches akeep_artifactsentry for the same stage, a warning is emitted because enforcement may block writes to files the stage expects to be present.
Migration: The top-level read_only_paths key and the previous protected_paths key are no longer accepted. If either is present, a validation error is raised with a migration hint. Move read_only_paths into individual stage definitions in your hpilot.yaml.
See the full reference in Pipeline Authoring Guide for the field schema, matching semantics, and interaction with other stage fields.