Add Prompt Meta-Evolution#393
Open
fangchenli wants to merge 4 commits intoalgorithmicsuperintelligence:mainfrom
Open
Add Prompt Meta-Evolution#393fangchenli wants to merge 4 commits intoalgorithmicsuperintelligence:mainfrom
fangchenli wants to merge 4 commits intoalgorithmicsuperintelligence:mainfrom
Conversation
## Problem
When diff-based evolution is enabled, the "Previous Attempts" section
of prompts shows changes like:
Change 1: Replace 15 lines with 18 lines
This gives the LLM no visibility into what the actual edits were,
making it harder to:
- Learn from successful patterns
- Avoid repeating failed exact matches
- Understand what format produces valid SEARCH blocks
This contributes to the high rate of "apply diff fail" errors
(see issue algorithmicsuperintelligence#346) where SEARCH patterns don't exactly match the
original code.
## Solution
Update `format_diff_summary()` to show actual content for multi-line
blocks:
Change 1: Replace:
def old_function():
return False
with:
def new_function():
return True
Single-line changes remain compact:
Change 1: 'x = 1' to 'x = 2'
Add `_format_block_lines()` helper with configurable truncation limits.
## Configuration
New options in `prompt:` config section:
```yaml
prompt:
diff_summary_max_line_len: 100 # Truncate lines longer than this
diff_summary_max_lines: 30 # Max lines per SEARCH/REPLACE block
```
## Files Changed
- `openevolve/config.py` - Add PromptConfig options
- `openevolve/utils/code_utils.py` - Update format_diff_summary
- `openevolve/iteration.py` - Pass config to format_diff_summary
- `openevolve/process_parallel.py` - Pass config to format_diff_summary
- `tests/test_code_utils.py` - Add tests for new behavior
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements meta-evolution of prompt templates inspired by the Darwin Gödel Machine paper. The system maintains an archive of prompt templates, tracks their success rates, and evolves them over time to improve mutation quality. Key features: - PromptTemplate dataclass with success/improvement tracking - PromptArchive for managing template population with sampling - Configurable scoring weights for template quality assessment - Automatic template evolution at configurable intervals - Checkpoint persistence for prompt archives - Validation to ensure scoring weights sum to 1.0 New config options under `prompt_meta_evolution`: - enabled: Master switch (default: false) - archive_size: Max templates to keep - evolution_interval: Iterations between evolutions - exploration_rate: Random sampling probability - score_weight_*: Configurable scoring formula weights Closes algorithmicsuperintelligence#170 Related to algorithmicsuperintelligence#53 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Simplify async event loop handling using asyncio.run() - Add scoring config persistence in checkpoint serialization - Document exploration bonus formula with clear comment - Add test for scoring config serialization round-trip Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #170
Implements meta-evolution of prompt templates. The system maintains an archive of prompt templates, tracks their empirical success rates, and evolves them over time using LLM to improve mutation quality.
The scoring formula:
math score = w_success × success_rate + w_improvement × improvement_rate + w_fitness × normalized_deltaThe weights are controlled in the config.
Unittests added and also tested with the
function_minimizationexample.