AgenTopology

Gates

Add human-in-the-loop approval checkpoints between agents

Gates

The gates block defines human approval checkpoints in your topology. Gates pause execution until a human reviews and approves the work, providing a safety net for high-stakes operations.

Basic Syntax

gates {
  review-gate {
    after: writer
    before: deployer
    run: "Review the generated code before deployment"
  }
}

Field Reference

FieldTypeRequiredDescription
afteridentifierYesThe agent whose output triggers this gate
beforeidentifierNoThe agent that runs after approval
runstringYesInstructions shown to the human reviewer
checkslistNoAutomated checks to run before human review
retrynumberNoTimes the originating agent can retry on rejection
on-failidentifierNohalt (default) or bounce-back
behavioridentifierNoblocking (default) or advisory

On-Fail Strategies

StrategyDescription
haltStop the entire topology if the gate is rejected
bounce-backSend work back to the after agent for revision
gates {
  deploy-check {
    after: builder
    before: deployer
    run: "Verify build artifacts are correct"
    on-fail: bounce-back
    retry: 2
  }
}

With bounce-back, the builder agent gets another chance (up to retry times) before the topology halts.

Behavior

BehaviorDescription
blockingFlow pauses until the gate is resolved (default)
advisoryGate logs a warning but does not block execution
gates {
  style-review {
    after: writer
    before: publisher
    run: "Check writing style and tone"
    behavior: advisory
  }
}

Automated Checks

Use checks to run validations before presenting work to the human:

gates {
  quality-gate {
    after: coder
    before: reviewer
    run: "Review code changes"
    checks: [lint-pass, tests-pass]
  }
}

If automated checks fail, the gate rejects without requiring human intervention.

Auto-Injection into Flow

When you declare a gate with after and before, AgenTopology automatically injects the gate into the flow between those two agents. You do not need to reference the gate in the flow block.

topology deploy-pipeline : [pipeline, human-gate] {
  agent builder   { model: sonnet  tools: [Bash] }
  agent deployer  { model: opus    tools: [Bash] }

  flow {
    builder -> deployer
  }

  gates {
    deploy-approval {
      after: builder
      before: deployer
      run: "Approve deployment to production"
    }
  }
}

The gate is automatically inserted between builder and deployer in the flow.

Tips

  • The topology must declare the human-gate pattern to use gates.
  • Gates with on-fail: bounce-back pair well with retry to give agents a chance to fix issues.
  • Use behavior: advisory for non-critical reviews that should not block the pipeline.
  • Every gate needs both after and run at minimum.

On this page