How Nous.Eval.Optimizer evaluates a candidate profile and turns the
result into evidence for the reflector (the GEPA adapter shape).
The default, Nous.Eval.Optimizer.AgentAdapter, runs the eval task with
Nous.Eval.run/2 and the candidate applied to every agent the task
builds. An adapter for another system implements the same five callbacks
and is passed as adapter: {module, opts}.
Contract
evaluate/3never raises per case: a case that crashed, timed out or errored is in the result with score0.0. It reports what it spent (metric_calls,tokens,cost) and the run status; the optimizer charges the spend whatever the status and uses only:completedevaluations for decisions.reflective_records/2builds records from train evaluations only and raisesArgumentErrorfor any other split: validation and test content never reaches the reflector, only their scores reach the optimizer. Records are rendered under the evaluation's feedback policy (see "Feedback policy" inNous.Eval.Optimizer).
Summary
Callbacks
The agent the profiles are written for, with its base text: component keys are validated and profiles sealed against it, and the guard filter receives it with each profile applied.
Every case the optimizer may draw batches from.
Evaluates profile on batch.
Prepares the adapter for task (no model call).
The reflector evidence for component_keys: %{key => [record]}.
Raises ArgumentError unless the evaluation's split is "train".
Types
@type batch() :: %{ case_ids: [String.t()], split: String.t(), k: pos_integer(), budget: keyword(), feedback: :diagnostic | :with_expected, seed: integer() | nil }
A batch to evaluate:
:case_ids- the cases:split- the split label recorded on the evaluation:k- samples per case:budget- the most this evaluation may spend ([max_tokens: n, max_cost: usd, max_samples: n], see "Budgets" inNous.Eval.run/2):feedback- the feedback policy for its reflective records:seed- the base seed (the same for every evaluation, so a parent and its child see the same sample seeds)
@type reflective_record() :: %{ :case_id => String.t(), :score => float(), :inputs => String.t(), :outputs => String.t(), :tool_calls => [map()], :feedback => [map()], optional(:expected) => map() }
One piece of reflector evidence, for one train case:
:case_id,:score- the case and its objective (from the scorer structs, never parsed from text):inputs- the case input as text (untrusted):outputs- the agent's output or error (untrusted):tool_calls-[%{name, arguments, outcome, result}]from the trace (untrusted):feedback- one map per score::scorer,:passed?,:value,:reason(trusted, scorer-authored),:paths(mismatched argument or output paths; untrusted),:missing_tools(expected tool names that were not called),:critique(a judge's critique; untrusted):expected- the case'sexpectedmap, present only under:with_expectedfor a train case
Callbacks
@callback agent(state :: term()) :: Nous.Agent.t()
The agent the profiles are written for, with its base text: component keys are validated and profiles sealed against it, and the guard filter receives it with each profile applied.
@callback cases(state :: term()) :: [Nous.Eval.Case.t()]
Every case the optimizer may draw batches from.
@callback evaluate(state :: term(), profile :: Nous.Profile.t(), batch()) :: {:ok, Nous.Eval.Optimizer.Evaluation.t()} | {:error, term()}
Evaluates profile on batch.
Prepares the adapter for task (no model call).
@callback reflective_records( Nous.Eval.Optimizer.Evaluation.t(), component_keys :: [String.t()] ) :: %{ required(String.t()) => [reflective_record()] }
The reflector evidence for component_keys: %{key => [record]}.
Raises ArgumentError unless the evaluation's split is "train".