Iterations and Verification
AgentGate uses an iterative process with multi-level verification to ensure generated code meets quality standards. This page explains how iterations work and what verification levels mean.The Iteration Process
When a run executes, it goes through multiple iterations:1
Code Generation
The AI agent analyzes the task and generates code changes.
2
Verification
Automated verification checks run against the generated code.
3
Feedback Loop
If verification fails, results feed back to the AI for improvement.
4
Repeat or Complete
Process repeats until verification passes or max iterations reached.
Why Multiple Iterations?
AI-generated code doesn’t always work on the first try. The iteration process:- Catches errors early through verification
- Provides feedback for the AI to improve
- Ensures quality through multiple checks
- Converges on working solutions
Verification Levels
AgentGate uses four verification levels, each progressively more thorough:L0: Contract Verification
What it checks:- Syntax correctness
- Type checking (for typed languages)
- Import resolution
- Basic linting
- Syntax errors
- Missing imports
- Type mismatches
L1: Test Verification
What it checks:- Unit test execution
- Test pass/fail status
- Code coverage thresholds
- Failing unit tests
- Below coverage threshold
- Test runtime errors
L2: Behavioral Verification
What it checks:- Integration test execution
- API contract compliance
- Cross-component interaction
- Integration test failures
- API response mismatches
- Database interaction errors
L3: Sanity Verification
What it checks:- End-to-end scenarios
- Performance thresholds
- Security scans
- Final quality checks
- E2E test failures
- Performance degradation
- Security vulnerabilities
Gate Plans
Gate plans configure which verification levels apply:Default Gate Plan
By default, all relevant verification levels run:- L0 always runs
- L1 runs if tests exist
- L2 runs if integration tests exist
- L3 runs for final validation
Custom Gate Plans
Configure verification for your needs:When to Customize
Quick Iterations
Quick Iterations
Use only L0 for rapid prototyping where speed matters more than comprehensive testing.
High Assurance
High Assurance
Use all levels (L0-L3) for production-critical code where quality is paramount.
Test-Focused
Test-Focused
Emphasize L1/L2 when the codebase has good test coverage you want to leverage.
Convergence
A run converges when verification passes at all required levels:Factors Affecting Convergence
| Factor | Impact |
|---|---|
| Task clarity | Clearer prompts converge faster |
| Codebase quality | Well-structured code helps AI |
| Test coverage | More tests provide better feedback |
| Task complexity | Complex tasks need more iterations |
Iteration Limits
Default Limit
The default maximum is 10 iterations.Configuring Limits
Set custom limits per work order:When Limits Are Reached
If max iterations reached without convergence:- Run status becomes
failed - Best partial result may be available
- You’re charged for completed iterations
Cost Implications
Each iteration incurs costs:- More iterations = higher cost
- Verification level affects iteration cost
- Failed iterations still cost credits
Cost Optimization
- Write clear, specific task prompts
- Use appropriate verification levels
- Start with lower iteration limits and increase if needed
- Break complex tasks into smaller work orders