openevolve icon indicating copy to clipboard operation
openevolve copied to clipboard

EVOLVE-BLOCK-START and EVOLVE-BLOCK-END markers do not work

Open xwqsl opened this issue 9 months ago • 1 comments

I was optimizing a c program where a c file has many functions, I only want to optimize a single function in the file. I tried several marks to let openevolve optimize only the function. such as:

// #EVOLVE-BLOCK-START/END // # EVOLVE-BLOCK-START/END // EVOLVE-BLOCK-START/END //EVOLVE-BLOCK-START/END

but all fails. I find openevolve will also change other functions in the file in the subsequent iterations.

I wonder how the EVOLVE-BLOCK-START/END is implemented in openevolve and how it can be used for program language other than python. I find a function parse_evolve_blocks in openevolve/utils/code_utils.py. I think it may related to the feature but I don't see any calls to parse_evolve_blocks.

xwqsl avatar Mar 02 '26 01:03 xwqsl

The markers currently only serve as soft hints to the LLM via prompt instructions, with no programmatic enforcement that mutations stay within the marked regions.

A proper fix would need to:

  1. Call parse_evolve_blocks in code_utils.py after the LLM generates a diff and validate that changes only target lines within evolve blocks
  2. Reject or revert mutations that touch code outside the markers
  3. Support comment syntax beyond Python (// for C/C++, etc.)

Would you be interested in submitting a PR for this? We'd appreciate the contribution.

codelion avatar Mar 02 '26 04:03 codelion