ExAgent. Eval. Online
(ExAgent v3.0.0)
View Source
Sample already confirmed terminals with an existing ExAgent.Eval evaluator.
Stability — Stable.
Start a supervised queue for one trusted scope and evaluator version. Obtain
its local handle once, then use offer/3 after the runtime acknowledgement.
A queue admits samples without calling its owner or a Store. The evaluator
runs in a separate task and receives a bounded view. For C7 receipts the worker
first checks the exact final record by reading it. Evaluation never runs the
target or dispatches its tools.
The default is content-free. Even with content: true the evaluator only
receives text explicitly authorized in an offer. Tool evidence carries the
declared name, opaque call reference and status. Results and errors export
without text, arguments, tool results or evaluator explanations.
A custom evaluator receives the usual case and output fields. Its result
view contains :run_id and :status, with scope and source in the case's
metadata. It can receive failed or cancelled runs, including a
:cancelled_before_start terminal for a queued turn with a reserved run
ID and a confirmed :cancelled event for an active or paused Server turn.
A cancellation with status :uncertain needs reconciliation before grading.
Graded text is optional.
Summary
Types
The bounded outcome supplied to a custom Online evaluator. Its case input,
expected answer and output come from the content authorized in offer/3.
See ExAgent.Eval.Case.from_run/2 to project it into a regression case.
Functions
Returns a specification to start this module under a supervisor.
Return a handle for fast local admission. Resolve it again after restarting the queue.
Offer a confirmed result to this queue. Do this after the target returns,
from a Server terminal event consumer, or after receiving a Session turn
acknowledgement. Pass {:session, reply} with the result of
ExAgent.Session.chat/4. For a turn the host commits separately, use
{:session, reply, outcome} with the turn acknowledgement and run outcome
or {:continuation, reference}. The worker checks exact C7 references.
Start a queue. Required options are :scope (a trusted identifier or nil)
and :evaluator. The queue uses the evaluator's version by default.
Pass :version to set it explicitly or to use an unversioned evaluator.
Change the version whenever evaluator behavior changes.
Types
@opaque handle()
@type outcome() :: {:ok, ExAgent.Result.t()} | {:error, ExAgent.RunError.t() | term()}
@type sample() :: %{ case: ExAgent.Eval.Case.t(), output: String.t() | nil, result: %{run_id: String.t(), status: atom()}, error: atom() | nil, online: %{ budget: map(), transcript: String.t() | nil, tools: [map()], tools_complete: boolean() } }
The bounded outcome supplied to a custom Online evaluator. Its case input,
expected answer and output come from the content authorized in offer/3.
See ExAgent.Eval.Case.from_run/2 to project it into a regression case.
@type terminal() :: {:run, outcome()} | {:server, outcome() | ExAgent.Event.t() | {:ok, ExAgent.Server.cancelled_admission_receipt()}} | {:session, outcome()} | {:session, {:ok, term(), term()}, outcome() | {:continuation, map()}} | {:continuation, map()}
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec handle(GenServer.server()) :: handle()
Return a handle for fast local admission. Resolve it again after restarting the queue.
@spec offer(handle(), terminal(), keyword()) :: {:ok, :enqueued | :not_sampled | :duplicate} | {:error, atom()}
Offer a confirmed result to this queue. Do this after the target returns,
from a Server terminal event consumer, or after receiving a Session turn
acknowledgement. Pass {:session, reply} with the result of
ExAgent.Session.chat/4. For a turn the host commits separately, use
{:session, reply, outcome} with the turn acknowledgement and run outcome
or {:continuation, reference}. The worker checks exact C7 references.
To recover a queued cancellation after a Server restart, offer
{:server, reply} with the {:ok, receipt} from Server.receipt/3.
The receipt must confirm :cancelled_before_start in the queue's scope.
For an active cancellation, offer the confirmed Server event. The partial
run reply only certifies interruption of the worker.
Returns {:ok, :enqueued | :not_sampled | :duplicate} or {:error, reason}.
:full means this sample was shed. :unconfirmed_terminal means the input
was a pause, provisional failure or missing acknowledgement. A later C7
read can discard an enqueued sample when its receipt cannot be confirmed.
Durable grading also emits a discard if it cannot confirm an export claim.
The queue remembers that sample in its bounded duplicate window.
:contentoptionally supplies a map of authorized UTF-8:input,:output,:expectedand:transcriptstrings.:toolsoptionally supplies{:complete | :partial, observations}. Pass each:tool_call_finishedEvent or terminal[:exagent, :tool, :stop]observation of the run once. A repeated provider ID can be a new call. Only the first 64 observations are retained. Use:completefor a complete capture. When omitted, C7 journal evidence is partial.:trace_contextdefaults to the caller's OTel span context. Pass a context captured in the evaluated operation when enqueueing across a process boundary.:response_idcan carry an explicitly authorized provider completion ID.
Call from the trusted host. Server terminal Events must use the queue's
:scope. A C7 receipt and any accompanying tool Events use the namespace
of the configured source Store. Bind native results and tool-stop telemetry
to the correct scope before offering them.
@spec start_link(keyword()) :: GenServer.on_start()
Start a queue. Required options are :scope (a trusted identifier or nil)
and :evaluator. The queue uses the evaluator's version by default.
Pass :version to set it explicitly or to use an unversioned evaluator.
Change the version whenever evaluator behavior changes.
:sample_ratedefaults to0.01. Use1.0for every run in the scope.:capacitydefaults to 64, including the active sample.:seen_capacitydefaults to 4096 remembered keys after completion.:timeout_msdefaults to 5000 per evaluation. The built-in judge gets one reviewer attempt and a:judge_max_tokensoutput limit (512 by default).:contentdefaults to false. Authorized text has a combined:max_content_byteslimit (16384 by default).:storeis the authorized source Store for C7 receipts. A namespace supplied by the receipt must match this descriptor.:grading_backenddefaults to:memory. For Jobs use{:durable, jobs, expires_at_ms}with the queue's scope as the Jobs namespace and an absolute Unix millisecond expiry. The first admission fixes the deadline for this evaluation. ApplyExAgent.Jobs.Durable.migration_sql/0for durable grading.:oteloptionally receives an OTLP/HTTP JSON logs request with the named evaluation event. The callback runs in a background task. Return:okafter confirming dispatch and{:error, reason}otherwise. The[:exagent, :eval, :online, :delivery]event reports:dispatchedor:delivery_unconfirmedusing the result's ID.
:name accepts the same registrations as a GenServer. Use non-secret
identifiers for the scope, evaluator and version.