Skip to content

Commit 1ffe515

Browse files
committed
Add repairs to docs
1 parent 640de0d commit 1ffe515

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ python scripts/visualizer.py --path examples/function_minimization/openevolve_ou
7575

7676
5. **Iteration (`openevolve/iteration.py`)**: Worker process that samples from islands, generates mutations via LLM, evaluates programs, and stores artifacts.
7777

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+
7880
### Key Architectural Patterns
7981

8082
- **Island-Based Evolution**: Multiple populations evolve separately with periodic migration
8183
- **MAP-Elites**: Maintains diversity by mapping programs to feature grid cells
8284
- **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
8386
- **Process Worker Pattern**: Each iteration runs in fresh process with database snapshot
8487
- **Double-Selection**: Programs for inspiration differ from those shown to LLM
8588
- **Lazy Migration**: Islands migrate based on generation counts, not iterations

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ evaluator:
468468
enable_artifacts: true # Error feedback to LLM
469469
cascade_evaluation: true # Multi-stage testing
470470
use_llm_feedback: true # AI code quality assessment
471+
repair_on_failure: true # LLM repair on EvaluatorRepairRequest
472+
max_repair_attempts: 2 # Retry limit per broken program
473+
repair_diff_based: false # true=SEARCH/REPLACE diffs, false=full rewrite
471474

472475
prompt:
473476
# Sophisticated inspiration system
@@ -720,6 +723,44 @@ return EvaluationResult(
720723

721724
This creates a **feedback loop** where each generation learns from previous mistakes!
722725

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+
def evaluate(program_path):
734+
result = compile(program_path)
735+
if result.returncode != 0:
736+
with open(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+
723764
## Visualization
724765
725766
**Real-time evolution tracking** with interactive web interface:

0 commit comments

Comments
 (0)