GEPA runs a tight optimization loop:
- evaluate the seed candidate
- choose a candidate to mutate
- sample a minibatch from the training set
- build a reflective dataset from traces
- propose a new candidate
- evaluate the proposal
- accept or reject it
- repeat until a stop condition triggers
The selector is where exploration and exploitation are balanced.
GEPA.Strategies.CandidateSelector.Paretosamples from the current Pareto frontGEPA.Strategies.CandidateSelector.CurrentBestalways selects the top candidateGEPA.Strategies.CandidateSelector.TopKParetosamples from the top-k front membersGEPA.Strategies.CandidateSelector.EpsilonGreedyexplores with a decaying epsilon
EpsilonGreedy is stateful: it carries the current epsilon forward across selections and can be reset back to its initial value.
GEPA can produce proposals in three ways:
- the adapter implements
propose_new_texts/3or/4 GEPA.Proposer.InstructionProposalcalls an LLM with a reflective datasetGEPA.Proposer.Mergecombines related parents when merge mode is enabled
Instruction proposal supports custom templates and structured output. For native structured output, pass a hosted ReqLLM client such as GEPA.LLM.req_llm(:openai), :gemini, or :anthropic as :reflection_llm. Local ASM clients can be used for text proposals, but structured output is capability-gated off there.
Adapter-owned proposal callbacks are task-adapter callbacks. They are separate from the LLM adapter/provider selection used by GEPA.LLM. Merge mode is scheduled separately and can be turned off entirely.
GEPA.Strategies.Acceptance controls when a proposal replaces the current candidate. The common modes are:
- strict improvement
- improvement or equal
- a custom function or module
The engine evaluates the proposal on the sampled minibatch first, then applies the configured acceptance rule.
The built-in stop conditions cover:
- call budgets
- proposal budgets
- reflection-cost budgets
- timeouts
- score thresholds
- no-improvement patience
- tracked-candidate limits
- explicit signal or file stops
You can compose multiple conditions with GEPA.StopCondition.Composite.
When :run_dir is configured, GEPA persists state and can resume later. The state includes candidate history, Pareto fronts, adapter state, and the validation schema version needed to reload safely.
GEPA.Progressprints a terminal progress line when enabledGEPA.Callbacksexposes synchronous lifecycle eventsGEPA.Trackingforwards scalar metrics and summary data to an external backendGEPA.Telemetryemits a stable event schema for handlers that prefer Telemetry over callbacks
These layers sit on top of the engine. They do not change candidate semantics, but they make long runs observable and restartable.