Agent Architecture/Subagents & Agent Teams
Advanced12 min

Quality Gates for Agent Teams

Hooks on agent team events — TeammateIdle, TaskCompleted, TaskCreated — let you enforce quality standards automatically. When a hook exits with code 2, it sends feedback to the teammate, which must address the issue before the event can proceed.

Quick Reference

  • TeammateIdle: fires when a teammate is about to go idle — use to enforce output standards
  • TaskCompleted: fires when a task is marked done — use to run acceptance tests
  • TaskCreated: fires when a new task is added — use to enforce task format
  • Exit code 2 rejects the event and sends stderr as feedback to the teammate
  • The pattern: hook → validate → pass (exit 0) or reject with feedback (exit 2)
  • Quality gates are automatic enforcement — not agent-to-agent messaging
  • Test hook scripts manually before deploying to real team runs
  • Known limitation: task lag can cause TaskCompleted hooks to fire late or not at all

Quality Gates vs Communication

Gates Are Automatic Enforcement

Quality gates are hooks that fire on team events and can block those events from proceeding. They are not agent-to-agent messages — they are automatic validators that run before a teammate finishes or a task closes. The teammate receives the hook's stderr output as feedback and must address it before proceeding.

Without quality gates, a teammate can mark a task complete even if tests fail, the output is missing, or the code violates project standards. Quality gates close this gap: a task cannot be marked complete until the gate's validation script passes.

HookFires WhenUse For
TeammateIdleA teammate finishes a turn and is about to go idleEnforce output standards before a teammate stops working
TaskCompletedA teammate marks a task doneRun acceptance tests — block completion if tests fail
TaskCreatedA new task is added to the Shared Task ListEnforce task format or prevent invalid scope