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
| Field | Type | Required | Description |
|---|---|---|---|
after | identifier | Yes | The agent whose output triggers this gate |
before | identifier | No | The agent that runs after approval |
run | string | Yes | Instructions shown to the human reviewer |
checks | list | No | Automated checks to run before human review |
retry | number | No | Times the originating agent can retry on rejection |
on-fail | identifier | No | halt (default) or bounce-back |
behavior | identifier | No | blocking (default) or advisory |
On-Fail Strategies
| Strategy | Description |
|---|---|
halt | Stop the entire topology if the gate is rejected |
bounce-back | Send 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
| Behavior | Description |
|---|---|
blocking | Flow pauses until the gate is resolved (default) |
advisory | Gate 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-gatepattern to use gates. - Gates with
on-fail: bounce-backpair well withretryto give agents a chance to fix issues. - Use
behavior: advisoryfor non-critical reviews that should not block the pipeline. - Every gate needs both
afterandrunat minimum.