Agents don’t always get it right on the first pass. Gates catch failures and route work back for correction — without you having to watch.
A gate is attached to a stage. Orkestra supports two kinds:
- Automated gate — a shell script runs after the agent produces output. Exit zero passes; non-zero sends the output back to the agent as feedback and triggers a retry.
- Agentic gate — an AI agent evaluates the work and produces an approve or reject verdict. The Trak then pauses for human review before routing.
Automated gate: the retry loop
- The agent completes its work and produces an artifact.
- The gate script runs in the Trak’s worktree.
- Exit 0 — the gate passes. The artifact proceeds to human review.
- Non-zero exit — the gate fails. The script’s output (stdout and stderr) is sent back to the agent as feedback. The agent retries.
- The loop continues until the gate passes. There is no retry limit — the loop is unbounded. To break a stuck gate, use
ork trak skipto advance past the stage,ork trak send-to-stageto reroute, orork trak restartto start the stage fresh.
The agent session is resumed on each retry — the agent sees its full conversation history including every previous gate failure and the feedback it produced.
What gates check
Gates run whatever your project needs. The default checks.sh created by ork init is a template you replace with your project’s actual quality bar. Common uses:
- Build verification — does the code compile?
- Linting and formatting — does it pass
eslint,cargo clippy, orbiome check? - Tests — does the test suite pass?
- Type checking — does
tscormypysucceed?
Gates don’t need to do all of this. A gate that runs only the fastest checks keeps the feedback loop tight. Slower checks can be deferred to CI.
Environment variables
Gate scripts run in the Trak’s worktree and have access to these environment variables:
| Variable | Description |
|---|---|
ORKESTRA_WORKTREE_PATH | Absolute path to the Trak’s worktree |
ORKESTRA_PROJECT_ROOT | Absolute path to the project root |
ORKESTRA_TASK_ID | The Trak ID |
ORKESTRA_TASK_TITLE | The Trak title |
ORKESTRA_BASE_BRANCH | The branch the Trak was created from |
ORKESTRA_BRANCH | The Trak’s git branch name |
ORKESTRA_PARENT_ID | Parent Trak ID (only set for Subtraks) |
Agentic gate
Configure an agentic gate by setting gate: true on a stage. See the Workflow Reference for the full field specification.
The agent produces a structured verdict (approve or reject) with reasoning. On reject, the agent specifies which earlier stage to route back to. If the Trak is not in auto mode, a human must confirm the rejection before routing executes — they can also override and continue regardless of the verdict.
Constraints
- Gate scripts run in the Trak’s worktree directory, not the project root.
- A gate that times out is treated as a failure (non-zero exit).
- Gates run after the agent produces output — they do not interrupt mid-execution.
What’s next
See Capabilities to understand how stages can be extended with questions, agentic verdicts, and Subtrak decomposition.