Function Signature
Description
The main entry point for running a discovery process. This function accepts file paths or inline strings for the initial program and evaluator, wires up configuration, and returns aDiscoveryResult containing the best solution found.
Parameters
File path or callable function
(program_path) -> metrics_dict that evaluates program performance.- File path: Path to a Python script that defines an
evaluate()function - Callable: Python function that accepts a program path and returns a metrics dictionary
Starting solution for the discovery process. Can be:
- File path: Path to a file containing the initial program
- Inline string: Source code as a string
- List of strings: Source code split into lines
- None: LLM generates a solution from scratch
NoneModel name(s), comma-separated. Overrides config file settings.Examples:
"gpt-5""gpt-5,gemini/gemini-3-pro"
None (uses config file)Maximum number of iterations to run. Overrides
config.max_iterations.Default: None (uses config file)Search algorithm name. Overrides config file settings.Native algorithms:
"adaevolve"- Adaptive multi-island evolutionary search"evox"- Self-evolving optimization"topk"- Top-K selection"beam_search"- Beam search with diversity"best_of_n"- Generate N variants per iteration"openevolve_native"- MAP-Elites + island-based search"gepa_native"- Pareto-efficient search with reflective prompting
--extra external):"openevolve"- OpenEvolve backend"gepa"- GEPA backend"shinkaevolve"- ShinkaEvolve backend
None (uses config file)Configuration for the discovery process.
- YAML path: Path to a YAML configuration file
- Config object: Pre-built
Configinstance - None: Use default configuration
NoneEnable agentic mode. The codebase root is automatically derived from
initial_program.Default: FalseDirectory where results, logs, and checkpoints are written. If
None, a temporary directory is created.Default: NoneDomain-specific context provided to the LLM for better solution generation.Default:
NoneBase URL for an OpenAI-compatible API endpoint.Default:
NoneRemove temporary files after the run completes.Default:
TrueReturns
Result object containing:
Examples
Basic Usage with File Paths
Using a Callable Evaluator
Inline String Program
Starting from Scratch (No Initial Program)
Using Custom Configuration
Multiple Models
Agentic Mode
Error Handling
Missing Model Configuration
Missing External Package
Invalid Evaluator
Notes
- The function runs asynchronously internally but presents a synchronous interface
- Results are automatically checkpointed during the run
- Use
cleanup=Falseto preserve temporary files and intermediate results - The
output_dirwill contain:best/- Best program foundcheckpoints/- Periodic checkpointslogs/- Execution logs
- Initial program is optional; the LLM can generate solutions from scratch with a good
system_prompt
See Also
- discover_solution - Convenience wrapper for string solutions
- Runner - Lower-level discovery runner class
- DiscoveryResult - Result object details