$ show algorithmicsuperintelligence/openevolve
OpenEvolve is an open-source evolutionary coding agent that uses large language models (LLMs) to iteratively improve programs. It implements a MAP-Elites quality-diversity algorithm with island-based evolution, supporting multiple LLM backends (OpenAI, Claude Code, etc.) and a cascade evaluation pattern. The system accepts a user-provided initial program and an evaluator script, then repeatedly mutates the program via LLM-generated SEARCH/REPLACE diffs or full rewrites, evaluates the fitness, and maintains a diverse population across feature dimensions. The core architecture is a library with a CLI entry point (`openevolve-run`), a high-level API (`run_evolution`, `evolve_function`, `evolve_code`), and a controller that orchestrates the evolution loop, prompt sampling, LLM inference, parallel evaluation, and database storage. The repository includes 20+ diverse examples ranging from algorithm optimization (AlgoTune, TSP, circle packing) to mathematical discovery (Heilbronn, kissing number) and hardware-specific kernel tuning (MLX Metal, MLIR). The codebase is well-structured with extensive unit and integration tests, typed configuration, and a modular design that separates concerns (evaluator, LLM, database, prompt templates). It is actively maintained with frequent commits and responsive issue triage.
The LLM identified 5 files worth highlighting for reuse:
Implements the core population store for the evolutionary algorithm, supporting MAP-Elites with multiple islands, per-island feature maps, adaptive binning, diversity caching with LRU eviction, and ring-topology migration. The `ProgramDatabase` class manages program storage, sampling with exploration/exploitation/random ratios, and checkpoint save/load. This is a self-contained implementation of the quality-diversity algorithm that could be extracted and reused in other evolutionary frameworks with minimal changes to the interface.
Provides a hierarchical configuration system using Python dataclasses with YAML loading, environment variable substitution (`${VAR}`), and backward compatibility for deprecated fields. The `Config` class nests sub-configs for LLM, database, evaluator, prompt, and process parallelism. The `from_yaml` and `from_dict` methods enable flexible configuration that can be safely serialized/deserialized. This pattern is reusable across any Python project needing structured, type-safe configuration.
Contains utilities for parsing SEARCH/REPLACE blocks from LLM outputs, applying diffs to source code, extracting evolvable code regions (delimited by EVOLVE-BLOCK markers), and summarizing changes. The `split_diffs_by_target` function separates code diffs from meta-description changes. The `_format_block_lines` helper truncates long diffs for concise logging. These functions are standalone and could be reused in any code-generation pipeline requiring structured diff application.
Implements an LLM ensemble with weighted sampling across multiple providers (OpenAI, Claude Code, etc.). The `LLMEnsemble` class maintains a registry of backends, supports fallback and retry, and propagates configuration to individual models. The ensemble can be used independently as a multi-model generation system, providing a clean interface for load balancing and redundancy.
Provides reusable async utilities including `TaskPool` (semaphore-based concurrency limiter), `run_in_executor` (bridge sync functions to async context), and `run_sync_with_timeout` (timeout wrapper using asyncio). These generic patterns solve common problems in async Python applications and can be extracted without modification to other projects needing managed concurrency.