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
Union[str, Path, Callable]
required
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
Optional[Union[str, Path, List[str]]]
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
NoneOptional[str]
Model name(s), comma-separated. Overrides config file settings.Examples:
"gpt-5""gpt-5,gemini/gemini-3-pro"
None (uses config file)Optional[int]
Maximum number of iterations to run. Overrides
config.max_iterations.Default: None (uses config file)Optional[str]
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)Union[str, Path, Config, None]
Configuration for the discovery process.
- YAML path: Path to a YAML configuration file
- Config object: Pre-built
Configinstance - None: Use default configuration
Nonebool
Enable agentic mode. The codebase root is automatically derived from
initial_program.Default: FalseOptional[str]
Directory where results, logs, and checkpoints are written. If
None, a temporary directory is created.Default: NoneOptional[str]
Domain-specific context provided to the LLM for better solution generation.Default:
NoneOptional[str]
Base URL for an OpenAI-compatible API endpoint.Default:
Nonebool
Remove temporary files after the run completes.Default:
TrueReturns
DiscoveryResult
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