Skip to main content

Gates

Gates are verification checkpoints that determine whether agent-generated code meets your quality standards. They unify all verification mechanisms into a consistent interface: static checks, test execution, CI integration, human approval, and loop detection.

What Are Gates

Think of gates as quality control stations. Code must pass through each gate before being considered complete. Gates replace the older L0-L3 verification level concept with a more flexible, configurable system. Each gate defines:
  • What to check: The verification type and configuration
  • What to do on failure: Iterate, stop, or escalate
  • When to run: Conditions for gate execution

Gate Check Types

AgentGate supports five types of gate checks:
Run L0-L3 verification checksThe classic verification levels wrapped in a gate:
Verification Levels:
Start with L0 and L1 for fast feedback. Add L2 and L3 for comprehensive verification.

Failure Policies

When a gate fails, the failure policy determines what happens next:

Action Types

Retry Configuration

Feedback Options

Success Policies

Control what happens when a gate passes:

Gate Conditions

Control when gates run:

Condition Options

Gate Pipeline

Gates execute in sequence as a pipeline:
1

Check Condition

Evaluate if the gate should run based on condition.when and condition.skipIf.
2

Execute Check

Run the gate check (verification, CI, custom command, etc.).
3

Collect Results

Gather pass/fail status, failures, and details.
4

Generate Feedback

If failed with feedback: auto, create structured feedback for the agent.
5

Apply Policy

Execute failure or success policy (iterate, stop, continue).
6

Continue Pipeline

If not stopped, proceed to next gate.

Gate Feedback

When gates fail, AgentGate generates structured feedback for the agent:

Feedback Format

Common Gate Patterns

Basic Quality Gates

Security-First Gates

Progressive Gates

Human-in-the-Loop

Verification Levels (L0-L3)

For backward compatibility, here’s what each level checks:
Static checks that don’t execute code:
  • Required files: Ensure specific files exist
  • Forbidden patterns: Block secrets, keys, credentials
  • Schema validation: Validate JSON/YAML against schemas
  • Naming conventions: Enforce file/folder naming rules
Execute test commands:
  • Test execution: Run test suites
  • Exit code checking: Verify success/failure
  • Output capture: Collect stdout/stderr
  • Timeout enforcement: Prevent hanging tests
Functional testing with fixtures:
  • Fixture-based testing: Run against test data
  • Assertions: Check outputs match expectations
  • JSON schema validation: Validate API responses
  • File comparison: Compare output files
Structural validation:
  • File existence: Verify expected files created
  • Test coverage: Ensure minimum coverage
  • Pattern matching: Check code structure
  • Size limits: Prevent bloated changes

Best Practices

1

Order Gates by Speed

Run fast gates first to get quick feedback:
  1. L0 (contracts) - seconds
  2. L1 (tests) - seconds to minutes
  3. Custom commands - varies
  4. L2/L3 (blackbox/sanity) - minutes
  5. GitHub Actions - minutes to hours
2

Use Appropriate Actions

  • iterate for recoverable failures
  • stop for critical/security issues
  • escalate for warnings that need attention
3

Set Retry Limits

Prevent infinite loops by setting maxAttempts:
  • Lint/format: 10+ (usually quick fixes)
  • Tests: 5-10 (may need logic changes)
  • CI: 2-3 (external system, expensive)
4

Provide Context in Feedback

Custom commands should output helpful error messages that guide the agent to fix issues.

TaskSpec

Configure gates within TaskSpec

Convergence

How gates affect convergence decisions

Iterations

Understanding the iteration loop

Error Handling

Handle gate failures gracefully