Guards
Guards are live circuit breakers that monitor an agent during execution. While gates check after a step finishes, guards watch in real-time and kill the agent immediately if a condition is met.Declaring guards
Available guards
no_write is implicitly true for split and validate step types. Override with guard: { no_write: false } if needed.
timeout is an alias for max_time — if both are present, it’s a parsing error.
What happens when a guard triggers
- The agent is killed immediately
- The worktree is reset to the pre-step state (mutations undone)
- Partial metrics are collected (tokens spent, cost so far, turns completed)
- The gate runs (it will fail)
- Retry applies — same flow as a gate failure
guard_triggered event is emitted in the ledger with the guard name, reason, and partial metrics.