# `Nous.Eval.Optimizer.AgentAdapter`
[🔗](https://github.com/nyo16/nous/blob/v0.21.1/lib/nous/eval/optimizer/agent_adapter.ex#L1)

The default `Nous.Eval.Optimizer.Adapter`: evaluates a candidate profile
by running the eval task with `Nous.Eval.run/2`, the candidate applied to
every agent the task builds (`profile:`) and the batch selected by case id
(`cases:`).

## Options (`adapter: {Nous.Eval.Optimizer.AgentAdapter, opts}`)

  * `:parallelism`, `:timeout`, `:scorer_timeout`, `:max_trace_events`,
    `:max_trace_bytes` - passed to every `Nous.Eval.run/2`

`k`, the seed and the budget of each evaluation come from the optimizer.

## The reference agent

`c:Nous.Eval.Optimizer.Adapter.agent/1` is the agent the task builds for its first case (sample 0,
no seed), with the task's `setup/1` state and deps; `setup/1` and
`teardown/1` run around building it. Profiles are sealed against it, so
a task whose agents differ in base text between cases cannot be
optimized as one profile: such a profile fails to apply (`:stale`) and
the affected samples are errors.

## Reflective records

One record per train case, from its lowest-scoring sample (ties: lowest
index): the case input, the agent's output or error, the tool calls of
the trace and one feedback entry per score. A case whose samples all have
scorer errors yields no record: the reflector must not learn from a
broken instrument.

Under `:diagnostic` a feedback entry carries the scorer's name, `passed?`,
value and reason, the paths of mismatched arguments or output fields
(never the expected values), the names of expected tools that were not
called, and a judge's critique. A reason or critique that quotes the
case's `expected` values or a scorer option (a rubric, a reference, the
phrases a `Contains` looks for) is withheld (`"withheld (quotes the
expected answer or a rubric)"`). Under `:with_expected` the record of a
train case also carries its `expected` map, and only scorer-option quotes
(rubrics) are withheld.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
