Show actual SEARCH/REPLACE content in diff summaries#390
Merged
codelion merged 1 commit intoalgorithmicsuperintelligence:mainfrom Feb 4, 2026
Merged
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>
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.
Problem
When diff-based evolution is enabled, the "Previous Attempts" section of prompts shows changes like:
This gives the LLM no visibility into what the actual edits were, making it harder to:
This contributes to the high rate of "apply diff fail" errors (see issue #346) where SEARCH patterns don't exactly match the original code.
Solution
Update
format_diff_summary()to show actual content for multi-line blocks:Single-line changes remain compact:
Add
_format_block_lines()helper with configurable truncation limits.Configuration
New options in
prompt:config section:Files Changed
openevolve/config.py- Add PromptConfig optionsopenevolve/utils/code_utils.py- Update format_diff_summaryopenevolve/iteration.py- Pass config to format_diff_summaryopenevolve/process_parallel.py- Pass config to format_diff_summarytests/test_code_utils.py- Add tests for new behaviorSome files got reformatted, I'll leave those changes there.