Skip to main content

Module expect

Module expect 

Source
Expand description

The built-in assertion library: Expectation, a serde/RON-authored predicate over a run’s universal RunArtifacts.

This is what makes eval-core “pytest for agents”: the common case needs NO user-implemented Scorer. A test case is a prompt plus a list of Expectations asserting what the agent DID — which tools it called, with which parameters, and what it finally said or computed — scored by BuiltinScorer over the artifacts every harness already returns.

§RON authoring

Variants read cleanly as RON (the enum is #[derive(Deserialize)] with struct-style variants):

(
  name: "adds two numbers",
  instruction: "what is 2 + 2?",
  expect: [
    CalledToolWith(tool: "calculator", args: { "op": "add", "a": 2, "b": 2 }),
    FinalNumberEquals(value: 4.0),
  ],
)

Note the case has NO setup field — it defaults to () for the easy Agent path.

§Two matching rules to know

  • Args subset match (CalledToolWith): the expected args JSON must be a SUBSET of the actual call’s args — objects recurse key-by-key, every other JSON value (string/number/bool/null/array) must match exactly. So { "op": "add" } matches a call made with { "op": "add", "a": 2, "b": 2 }, but { "op": "sub" } does not. (Arrays are compared whole, not element-subset.)
  • Number extraction (FinalNumberEquals): the last number in final_text is taken as the agent’s answer (models typically end with the answer), then compared to value within tolerance (default 0.0 = exact). “Number” = an optionally-signed integer or decimal, with optional thousands separators stripped.

Enums§

Expectation
A single built-in assertion over a run’s RunArtifacts.