Skip to main content

Overview

Strategy presets control the balance between repair, optimization, and innovation in evolution cycles. By setting EVOLVE_STRATEGY, you can adapt the evolver’s behavior to match your system’s maturity and stability needs.

Available Strategies

The evolver includes seven built-in strategy presets:

balanced (default)

EVOLVE_STRATEGY=balanced node index.js
  • Repair: 20%
  • Optimize: 30%
  • Innovate: 50%
  • Repair Loop Threshold: 50%
Use when: Normal operation with steady growth and acceptable stability. Description: Balanced strategy prioritizes new features while maintaining reasonable stability. It switches to forced innovation if 50% of the last 8 cycles were repairs (to break repair loops).

innovate

EVOLVE_STRATEGY=innovate node index.js
  • Repair: 5%
  • Optimize: 15%
  • Innovate: 80%
  • Repair Loop Threshold: 30%
Use when: System is stable and you want to maximize new capabilities. Description: Innovation-focused strategy for mature, well-tested systems. Aggressively pursues new features and capabilities. Triggers circuit breaker early (30% repair ratio) to prevent getting stuck in fix cycles.
Use innovate after a successful hardening phase when you want to expand capabilities rapidly.

harden

EVOLVE_STRATEGY=harden node index.js
  • Repair: 40%
  • Optimize: 40%
  • Innovate: 20%
  • Repair Loop Threshold: 70%
Use when: After major changes, or when stability is the top priority. Description: Focuses on robustness, validation, and performance optimization. Minimal innovation. Tolerates higher repair ratios (70%) before forcing innovation.
Run harden strategy after introducing new features to stabilize the system before the next innovation phase.

repair-only

EVOLVE_STRATEGY=repair-only node index.js
  • Repair: 80%
  • Optimize: 20%
  • Innovate: 0%
  • Repair Loop Threshold: 100%
Use when: Emergency mode with critical bugs or failures. Description: Pure repair mode. No innovation allowed. Focuses entirely on fixing existing issues. Use when the system is broken and needs urgent stabilization.
repair-only disables innovation entirely. Only use temporarily during critical failures.

early-stabilize

EVOLVE_STRATEGY=early-stabilize node index.js
  • Repair: 60%
  • Optimize: 25%
  • Innovate: 15%
  • Repair Loop Threshold: 80%
Use when: First cycles of a new agent or after major refactoring. Description: Prioritizes fixing existing issues before innovating. Automatically selected for the first 5 evolution cycles if no explicit strategy is set.
This is the recommended strategy for new projects. Let the system stabilize before pushing for innovation.

steady-state

EVOLVE_STRATEGY=steady-state node index.js
  • Repair: 60%
  • Optimize: 30%
  • Innovate: 10%
  • Repair Loop Threshold: 90%
Use when: Evolution has saturated; system is mature. Description: Maintenance mode for saturated systems. Minimal innovation. Focuses on maintaining existing capabilities and incremental improvements. Automatically selected when evolution_saturation or force_steady_state signals are detected.
steady-state is auto-selected in loop mode when saturation signals appear. The evolver will also increase sleep intervals by 5-10x.

auto

EVOLVE_STRATEGY=auto node index.js
Use when: You want the evolver to choose the best strategy automatically. Description: Adaptive strategy selection based on:
  • Cycle count (first 5 cycles → early-stabilize)
  • Saturation signals → steady-state
  • Otherwise → balanced
This is the default behavior when no EVOLVE_STRATEGY is set.

Strategy Selection Logic

Auto-Detection Heuristics

When EVOLVE_STRATEGY is unset or auto, the evolver uses these rules:
1

Check Cycle Count

If cycle count is 1-5:
strategy = 'early-stabilize';
Rationale: New systems need stabilization before innovation.
2

Check Saturation Signals

If signals include evolution_saturation or force_steady_state:
strategy = 'steady-state';
Rationale: Mature systems benefit from low-frequency maintenance.
3

Default to Balanced

Otherwise:
strategy = 'balanced';

Backward Compatibility

The legacy FORCE_INNOVATION flag is supported:
FORCE_INNOVATION=true node index.js
This maps to EVOLVE_STRATEGY=innovate.

Repair Loop Circuit Breaker

What is a Repair Loop?

A repair loop occurs when:
  1. Evolution detects a bug and applies a repair
  2. The repair introduces a new bug or fails validation
  3. The next cycle detects the new bug and repairs again
  4. The cycle repeats indefinitely

Circuit Breaker Mechanism

Each strategy defines a repairLoopThreshold (percentage of repair cycles in the last 8 runs that triggers forced innovation):
const lastEightCycles = getRecentCycles(8);
const repairCount = lastEightCycles.filter(c => c.intent === 'repair').length;
const repairRatio = repairCount / lastEightCycles.length;

if (repairRatio >= strategy.repairLoopThreshold) {
  console.log('[Circuit Breaker] Forcing innovation to break repair loop.');
  intent = 'innovate';  // Override to innovation
}

Example

With balanced strategy (50% threshold):
  • Last 8 cycles: ['repair', 'repair', 'repair', 'repair', 'optimize', 'repair', 'repair', 'repair']
  • Repair ratio: 7/8 = 87.5%
  • Trigger: 87.5% > 50% → Force innovation
[Circuit Breaker] Repair loop detected (7/8 cycles). Forcing innovation.
[Strategy] Overriding intent: repair → innovate
If innovation also fails, the evolver may enter a failure loop. Use repair-only strategy and manual intervention to stabilize.

Strategy in GEP Prompt

The selected strategy is injected into the GEP protocol prompt:
{
  "strategy": {
    "name": "balanced",
    "label": "Balanced",
    "description": "Normal operation. Steady growth with stability.",
    "allocations": {
      "repair": 0.20,
      "optimize": 0.30,
      "innovate": 0.50
    }
  },
  "mutation": {
    "category": "innovate",
    "risk_level": "medium",
    "rationale": "System is stable. Pursuing new capability: async job queue."
  }
}
The LLM interprets these allocations as intent weights when generating changes.

When to Use Each Strategy

ScenarioStrategyRationale
New agent, first 5 cyclesearly-stabilizeFix existing issues before innovating
After major refactorhardenEnsure stability before new features
Stable system, want growthinnovateMaximize capability expansion
Production with occasional issuesbalancedMaintain steady progress
Critical bugs in productionrepair-onlyEmergency stabilization
Mature agent with saturation signalssteady-stateLow-frequency maintenance
Unsure what to useautoLet the evolver decide

Strategy + Loop Mode

Strategies are especially useful in loop mode:
EVOLVE_STRATEGY=early-stabilize node index.js --loop
In loop mode, the evolver will apply the strategy continuously, adapting sleep intervals and behavior based on signals.

Custom Strategies

To add custom strategies, edit src/gep/strategy.js:
var STRATEGIES = {
  // ... existing strategies
  
  'custom-aggressive': {
    repair: 0.10,
    optimize: 0.10,
    innovate: 0.80,
    repairLoopThreshold: 0.20,
    label: 'Custom Aggressive',
    description: 'Custom strategy for experimental projects.',
  },
};
Then use:
EVOLVE_STRATEGY=custom-aggressive node index.js
Modifying strategy.js is considered self-modification. Set EVOLVE_ALLOW_SELF_MODIFY=true to allow the evolver to edit strategy definitions autonomously.

Viewing Active Strategy

The evolver logs the active strategy at startup:
[Strategy] Using strategy: balanced (Balanced)
[Strategy] Allocations: repair=20%, optimize=30%, innovate=50%
[Strategy] Repair loop threshold: 50%

Best Practices

  1. Start conservative: Use early-stabilize or balanced for new projects
  2. Match system maturity: Young systems need repair focus; mature systems can innovate
  3. Monitor repair ratios: If >60% of cycles are repairs, consider repair-only mode temporarily
  4. Trust auto-detection: The auto strategy works well for most cases
  5. Override deliberately: Only set explicit strategies when you have a clear reason
  6. Review circuit breaker logs: Understand why forced innovation was triggered

Troubleshooting

Strategy Not Applied

Problem: Evolver ignores EVOLVE_STRATEGY setting. Solution: Check environment variable is exported:
export EVOLVE_STRATEGY=innovate
node index.js

Stuck in Repair Loop

Problem: Every cycle is a repair, even with low repairLoopThreshold. Solution: Check recent cycles to understand the pattern:
node index.js asset-log --last=10
If validation is failing repeatedly, the issue may be in the Genes themselves, not the strategy.

Innovation Not Happening

Problem: Using innovate strategy but getting repairs. Solution: Strategies are intent allocations, not guarantees. If signals indicate critical bugs, the evolver may override to repair mode:
[Signals] Critical error detected. Overriding strategy: innovate → repair

Next Steps

Loop Mode

Apply strategies in continuous evolution

Review Mode

Inspect strategy decisions before applying

Running Evolver

Execute evolution with custom strategies

Operations

Monitor strategy effectiveness

Build docs developers (and LLMs) love