You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
5.**Iteration (`openevolve/iteration.py`)**: Worker process that samples from islands, generates mutations via LLM, evaluates programs, and stores artifacts.
77
77
78
+
6.**Repair Subagent (`openevolve/evaluator.py`)**: When an evaluator raises `EvaluatorRepairRequest` (e.g. on compilation failure), the evaluator asks a dedicated LLM ensemble to fix the code and re-evaluates it. Configured via `EvaluatorConfig.repair_on_failure`, `max_repair_attempts`, and `repair_diff_based`. Uses `repair_models` from `LLMConfig` (falls back to `evaluator_models` then `models`). Repair history is stored as artifacts.
79
+
78
80
### Key Architectural Patterns
79
81
80
82
-**Island-Based Evolution**: Multiple populations evolve separately with periodic migration
81
83
-**MAP-Elites**: Maintains diversity by mapping programs to feature grid cells
82
84
-**Artifact System**: Side-channel for programs to return debugging data, stored as JSON or files
85
+
-**LLM Repair Loop**: Evaluators can raise `EvaluatorRepairRequest` to trigger LLM-based code repair before discarding broken programs
83
86
-**Process Worker Pattern**: Each iteration runs in fresh process with database snapshot
84
87
-**Double-Selection**: Programs for inspiration differ from those shown to LLM
85
88
-**Lazy Migration**: Islands migrate based on generation counts, not iterations
This creates a **feedback loop** where each generation learns from previous mistakes!
722
725
726
+
### LLM-Based Code Repair
727
+
728
+
When evolved code has a correctable error (e.g. a compilation failure), your evaluator can raise `EvaluatorRepairRequest` to trigger an automatic LLM repair attempt instead of discarding the program:
729
+
730
+
```python
731
+
from openevolve.evaluation_result import EvaluatorRepairRequest
732
+
733
+
defevaluate(program_path):
734
+
result =compile(program_path)
735
+
if result.returncode !=0:
736
+
withopen(program_path) as f:
737
+
code = f.read()
738
+
raise EvaluatorRepairRequest(
739
+
message="Compilation failed",
740
+
broken_code=code,
741
+
repair_context=result.stderr,
742
+
language="cpp",
743
+
fallback_metrics={"combined_score": 0.0}, # used if repair fails
744
+
)
745
+
# ... normal evaluation ...
746
+
```
747
+
748
+
Enable repair in your config:
749
+
750
+
```yaml
751
+
evaluator:
752
+
repair_on_failure: true
753
+
max_repair_attempts: 2
754
+
repair_diff_based: false # true for SEARCH/REPLACE diffs, false for full rewrite
755
+
756
+
llm:
757
+
repair_models: # optional — falls back to evaluator_models, then models
758
+
- name: "your-repair-model"
759
+
weight: 1.0
760
+
```
761
+
762
+
Repair history is stored in program artifacts and displayed in the visualizer.
763
+
723
764
## Visualization
724
765
725
766
**Real-time evolution tracking** with interactive web interface:
0 commit comments