Nous.Eval.Optimizer.Reflector (nous v0.21.1)

Copy Markdown View Source

The model that proposes new component text: a tool-less Nous.Agent with structured output, run under its own trace with role: :reflector (so its events never land in an eval sample's trace).

Two channels

What Nous renders itself is outside any fence: the task for the reflector, the component keys it may change, case ids, scores and the scorer-authored parts of feedback (scorer name, pass/fail, value, reason). Everything the agent, its tools or its users produced (case inputs, outputs, tool arguments and results, argument paths, a judge's critique, and the current component text, which an earlier proposal wrote) goes inside a labelled random-boundary fence (Nous.Fence), one fresh boundary per call. Long spans are cut with an explicit …[truncated N bytes] marker. Scores are never read from text.

Output contract

The reflector returns %{"component" => key, "text" => text} updates (GEPA) or whole candidate maps (OPRO). A proposal naming a component that was not requested is rejected as a whole (:unrequested_component), an empty or blank text is rejected (:empty_proposal), and an unparseable answer is rejected (:unparseable). A rejected proposal still counts against the budget; raw text is never applied.

Options (reflector: on Nous.Eval.Optimizer.run/2)

A model string, or a keyword list:

  • :model - the reflector's model (required, e.g. "openai:gpt-4o")
  • :temperature - for GEPA reflection (default 0.7); OPRO always samples at 1.0
  • :max_span_bytes - the cut-off for each fenced span (default 2_000)
  • :model_opts - extra Nous.new/2 options (base_url:, api_key:)

Summary

Types

t()

@type t() :: %Nous.Eval.Optimizer.Reflector{
  generate_agent: Nous.Agent.t(),
  max_span_bytes: pos_integer(),
  model: String.t(),
  reflect_agent: Nous.Agent.t()
}