ExAgent. Case
(ExAgent v3.0.0)
View Source
ExUnit assertions for deterministic agent tests.
Stability — Stable.
Use this module in a test case with the same options as ExUnit.Case, or
import its helpers into an existing test module. See the
testing guide.
Summary
Functions
Use ExUnit.Case and import the agent helpers.
Assert {:estimated, cents}, {:partial, subtotal_cents} or :unknown.
Return the first matching event from a collected list, or fail the assertion.
Assert a successful terminal and compare its accepted output with ===.
Assert that the retained calls of this run include the named tool.
Assert any of :input, :output and :quality. For token counts use
{:complete, count}, {:partial, subtotal} or {:unknown, nil}.
The optional quality string is the accounting marker, for example "normalized".
Coverage follows ExAgent.Eval.Report, including interrupted attempts.
Decode a portable evaluation case. See ExAgent.Eval.Case.from_map/1.
Build a deterministic TestModel with a nonempty script of requests.
Use strings, tool-call batches, ExAgent.Message.Response structs or
ExAgent.Models.Test.stream/2 entries, as with ExAgent.Models.Test.
Encode a portable evaluation case. See ExAgent.Eval.Case.to_map/1.
Types
@type cost() :: {:estimated | :partial, non_neg_integer() | float()} | :unknown
@type count() :: {:complete | :partial, non_neg_integer()} | {:unknown, nil}
@type terminal() :: ExAgent.Result.t() | ExAgent.RunError.t() | {:ok | :result, ExAgent.Result.t()} | {:error, ExAgent.RunError.t()}
Functions
Use ExUnit.Case and import the agent helpers.
Assert {:estimated, cents}, {:partial, subtotal_cents} or :unknown.
Return the first matching event from a collected list, or fail the assertion.
Accepts ExAgent.Event structs and elements of ExAgent.run_stream/3. The
optional predicate receives the payload. For :child it receives a pair of
the child lineage and its stream element. Collect the stream once before
asserting on it.
Assert a successful terminal and compare its accepted output with ===.
Assert that the retained calls of this run include the named tool.
Options are :times for an exact count, :status for a matching tool return,
and :args for a predicate on the original arguments. See ExAgent.Eval.tool_called/2
for how batches, omitted parts and retries affect the evidence.
Assert any of :input, :output and :quality. For token counts use
{:complete, count}, {:partial, subtotal} or {:unknown, nil}.
The optional quality string is the accounting marker, for example "normalized".
Coverage follows ExAgent.Eval.Report, including interrupted attempts.
@spec from_map(map()) :: {:ok, ExAgent.Eval.Case.t()} | {:error, :invalid_case | :unsupported_case_version}
Decode a portable evaluation case. See ExAgent.Eval.Case.from_map/1.
@spec test_model([ExAgent.Models.Test.script_item()]) :: ExAgent.Models.Test.t()
Build a deterministic TestModel with a nonempty script of requests.
Use strings, tool-call batches, ExAgent.Message.Response structs or
ExAgent.Models.Test.stream/2 entries, as with ExAgent.Models.Test.
@spec to_map(ExAgent.Eval.Case.t()) :: {:ok, map()} | {:error, :invalid_case}
Encode a portable evaluation case. See ExAgent.Eval.Case.to_map/1.