Quality Gates

Type: Task completion validation criteria

Definition

Quality gates are explicit validation criteria that must pass before a task is marked complete. They are defined in AGENTS.md and applied by the Router before accepting sub-agent output. A minimal gate checks: output file exists, file is non-empty, content addresses the original request. More rigorous gates add linting, testing, or review passes. Gates prevent broken, empty, or irrelevant output from propagating through the pipeline — quality over speed is the core principle.

How It Works

The Router applies a quality gate after each sub-agent completes its work but before marking the task done. The minimal gate has three checks: does the output file exist? is it non-empty? does the content actually address what was requested? If any check fails, the task is not complete — it goes back for revision or triggers RALPH escalation.

More rigorous gates depend on the task type. For code tasks, gates might include: file passes lint (pylint, eslint), unit tests pass, no hardcoded secrets. For research tasks: minimum number of credible sources, findings are summarized, not just raw output. For design tasks: mockups are present, within specified format, named correctly.

The gate criteria should be defined upfront in AGENTS.md as part of the task type configuration. When spawning a sub-agent, the Router includes the relevant gate criteria in the task description so the sub-agent knows what's expected. This is better than checking after the fact — clear expectations produce better output.

Gates are not optional. "Quality over speed" is a core principle — it's better to fail fast and fix than to ship broken work. If a gate fails, the Router should not move past it. If a sub-agent consistently produces gate-failing output, that's an agent bug — fix the agent, not the gate (PIP-05 Gate Failure Rule).

Key Properties

  • Three minimal checks — output file exists, file is non-empty, content addresses original request
  • Task-type-specific rigor — code tasks add lint/test gates; research tasks add source count gates
  • Defined in AGENTS.md — gate criteria are part of the agent configuration, not ad-hoc
  • Router-applied — the Router validates output before marking task complete
  • Gate failure = revision or escalation — broken output goes back or triggers RALPH
  • Fix agent, not gate — consistently failing gates indicate agent configuration problem (PIP-05)
  • kelly-router — the Router applies quality gates to sub-agent output
  • ralph-protocol — failed gates can trigger RALPH escalation if revision doesn't resolve the issue
  • agents-md — quality gate criteria are defined in AGENTS.md alongside routing rules

Source Chapters