Skip to main content

Failure Handling

When a gate fails, the retry block determines what happens next. The retry relaunches the step from GET with the current state — which has changed (error context, gate results are now available).

Without retry

If a step has no retry, any gate failure is fatal — the run stops immediately.

Basic retry

Retry up to 3 attempts, everything same. The prompt resolves differently because {error}, {diff}, {gate.*} are now in the state.

Overrides

Each retry entry declares a condition and optional keyword overrides:
Reading: “From attempt 2, use a targeted prompt. From attempt 4, switch to Opus with a fresh session and reset worktree. At attempt 6, stop.”

Condition types

Each entry has exactly one condition: exit is mandatory — a retry without exit is a dry-run error.

Overridable keywords

Retry entries can override these keywords:
  • agent — switch to a different agent (escalation)
  • session — force new (automatic when agent changes)
  • worktreereset to git reset --hard + git clean -fd
  • prompt — replace the entire prompt (disables automatic retry context injection)

Sticky behavior

Overrides are sticky: an override activated at attempt N stays active for N+1, N+2, etc. A later entry overriding the same keyword replaces it.

Validator conditions

A workflow validator can be used as a retry condition — the “agent assess” pattern:
The validator is invoked at each retry evaluation. Its inputs are passed via with: (separate from the step overrides). If its output is true, the entry’s overrides apply.

What happens on retry

  1. The state is updated with error context ({error}, {diff}, {gate.*})
  2. Previous iteration keys are moved to prev namespace
  3. The step relaunches from GET with the updated state
  4. If worktree: reset is active, the worktree is reset to pre-step state
  5. If the prompt is not overridden, the context builder injects a retry section automatically
  6. If the prompt is overridden, no automatic injection — the developer controls everything

Safety validations