Orkestra
GitHub

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

  1. The agent completes its work and produces an artifact.
  2. The gate script runs in the Trak’s worktree.
  3. Exit 0 — the gate passes. The artifact proceeds to human review.
  4. Non-zero exit — the gate fails. The script’s output (stdout and stderr) is sent back to the agent as feedback. The agent retries.
  5. The loop continues until the gate passes. There is no retry limit — the loop is unbounded. To break a stuck gate, use ork trak skip to advance past the stage, ork trak send-to-stage to reroute, or ork trak restart to 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, or biome check?
  • Tests — does the test suite pass?
  • Type checking — does tsc or mypy succeed?

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:

VariableDescription
ORKESTRA_WORKTREE_PATHAbsolute path to the Trak’s worktree
ORKESTRA_PROJECT_ROOTAbsolute path to the project root
ORKESTRA_TASK_IDThe Trak ID
ORKESTRA_TASK_TITLEThe Trak title
ORKESTRA_BASE_BRANCHThe branch the Trak was created from
ORKESTRA_BRANCHThe Trak’s git branch name
ORKESTRA_PARENT_IDParent 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.