Skip to main content

Convergence

Convergence is the process by which AgentGate determines when an agent has successfully completed a task. Instead of simply running a fixed number of iterations, convergence strategies intelligently decide when to continue iterating, when to stop, and how to interpret progress.

What Is Convergence

Traditional automation runs for a predetermined number of attempts. Convergence goes further by:
  • Detecting completion: Recognizing when the agent has achieved the desired state
  • Measuring progress: Tracking improvements across iterations
  • Preventing loops: Identifying when the agent is stuck in repetitive behavior
  • Optimizing cost: Stopping when further iterations are unlikely to help

Convergence Strategies

AgentGate supports five convergence strategies:
Run exactly N iterationsThe simplest strategy. Runs a predetermined number of iterations regardless of outcome.
Best for:
  • Simple tasks with predictable completion
  • Cost-controlled environments
  • Testing and debugging
Limitations:
  • May waste iterations on already-completed tasks
  • May stop before completion on complex tasks

Configuration Options

Strategy-Specific Options

Resource Limits

Every convergence configuration should include limits:
Always set maxIterations to prevent runaway costs. The default of 100 may be too high for your use case.

Convergence State

During execution, AgentGate tracks convergence state:
You can query this state via the API:

Convergence Decisions

Each iteration ends with a convergence decision:

Progress Metrics

AgentGate calculates progress metrics across iterations:

Choosing a Strategy

Use fixed when:
  • You have a well-understood task
  • Cost predictability is important
  • You’re testing or debugging
  • Tasks typically complete in 1-3 iterations
Use hybrid when:
  • Tasks have variable complexity
  • You want to balance cost and completion
  • Progress is measurable through gates
  • Most common choice for production
Use ralph when:
  • Tasks are complex or open-ended
  • Agent needs flexibility to explore
  • Loop detection is important
  • You trust the agent’s judgment
Use manual when:
  • Changes require human approval
  • Learning how the agent behaves
  • Compliance requires oversight
  • High-risk or sensitive code

Convergence with Gates

Convergence strategies work with gates to determine completion:

Gate Interaction

  1. All gates pass → Task complete, stop iterating
  2. Some gates fail with iterate → Generate feedback, continue
  3. Any gate fails with stop → Task failed, stop immediately
  4. Limits reached → Task failed, stop with partial results

Best Practices

1

Start with Hybrid

For most tasks, hybrid provides the best balance. Start with conservative settings and adjust based on results.
2

Set Reasonable Limits

Always set limits to control costs. Consider your task complexity:
3

Monitor Progress

Use the strategy state API to monitor convergence:
4

Adjust Based on Results

After completing several tasks, review convergence patterns:
  • Tasks completing too early? Lower progressThreshold
  • Wasting iterations? Raise progressThreshold
  • Loop detection triggering? Adjust convergenceThreshold

TaskSpec

Configure convergence within TaskSpec

Gates

Define verification checkpoints

Runs

Monitor iteration progress

Best Practices

Optimize convergence settings