Skip to main content

Function Signature

Description

A convenience wrapper around run_discovery designed for the common case where:
  • The initial solution is a plain string (not a file path)
  • The evaluator is a Python callable function (not a file path)
This function provides a simpler interface for programmatic use cases where you want to evolve a string-based solution using an in-memory evaluator function.

Parameters

Callable[[str], Dict[str, Any]]
required
A callable function that evaluates a program and returns a metrics dictionary.Function signature: (solution: str) -> Dict[str, Any]The function receives the program as a string and must return a dictionary containing evaluation metrics. The score is extracted using the combined_score key or by aggregating other numeric metrics.
Optional[str]
Starting solution as a plain string. If None, the LLM generates a solution from scratch.Default: None
int
Maximum number of iterations to run.Default: 100
Search algorithm name.Options:
  • "topk" - Top-K sampling
  • "adaevolve" - Adaptive Evolution
  • "evox" - EvoX backend
  • "openevolve_native" - OpenEvolve native
Default: None (uses config file)
Optional[str]
Model name(s), comma-separated.Examples:
  • "gpt-5"
  • "gpt-5,gemini/gemini-3-pro"
Default: None (uses config file)
Any
Additional keyword arguments passed to run_discovery.Common options:
  • config: Configuration file path or Config object
  • output_dir: Directory for results
  • system_prompt: Domain-specific context for the LLM
  • agentic: Enable agentic mode
  • api_base: Custom API endpoint
  • cleanup: Remove temporary files after completion

Returns

DiscoveryResult
Result object containing:

Examples

Basic Usage

Starting from Scratch

Multi-Objective Optimization

With Custom Configuration

Different Search Algorithms

Error Handling

Invalid Evaluator Return Type

Evaluator Timeout

Notes

  • This function is a thin wrapper around run_discovery for convenience
  • The evaluator function receives the solution as a string (not a file path)
  • The evaluator must return a dictionary; the score is derived from:
    • combined_score key (if present), or
    • Aggregation of other numeric values
  • Use run_discovery directly if you need more control or file-based workflows
  • The evaluator function is automatically converted to a file-based evaluator internally

See Also