Skip to main content

Documentation Index

Fetch the complete documentation index at: https://gump.build/docs/llms.txt

Use this file to discover all available pages before exploring further.

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

- name: impl
  type: code
  run:
    agent: claude-haiku
    guard:
      max_turns: 30
      max_budget: 2.00
  gate: [compile, test]

Available guards

GuardDescription
max_turnsKill if turns exceed a threshold
max_budgetKill if estimated cost exceeds a dollar amount
max_tokensKill if tokens consumed exceed a threshold
max_timeKill if wall-clock duration exceeds a threshold. Alias: timeout
no_writeKill if the agent writes files outside .gump/out/
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

  1. The agent is killed immediately
  2. The worktree is reset to the pre-step state (mutations undone)
  3. Partial metrics are collected (tokens spent, cost so far, turns completed)
  4. The gate runs (it will fail)
  5. Retry applies — same flow as a gate failure
A guard_triggered event is emitted in the ledger with the guard name, reason, and partial metrics.

Guards are reactive, not preventive

Guards react to agent behavior by parsing the NDJSON stream. There’s a small delay between the agent acting and the guard detecting it. File writes are caught and reverted via worktree reset. Network calls or other side effects outside the worktree cannot be undone.

Guards vs Gates

GatesGuards
WhenAfter the step finishesDuring execution
WhatCompile, test, lint, schema, validatorsTurn count, cost, tokens, time, file writes
MechanismShell commands, file checks, agent workflowsStream parsing, process kill
On failureRetry appliesRetry applies (via gate fail)
LLM involvedOnly for workflow validatorsNever