Skip to main content

Eval Library

The Eval Library provides scenario-based testing for AI agents. You define test cases with expected outcomes, run them with behavioral variations injected, and measure how much the agent’s behavior shifts under pressure. This is how you answer the question: “Will my agent still do the right thing when conditions change?”

Creating Scenarios

A scenario defines a single testable behavior: given a specific input context, the agent should produce a specific output.
Each scenario is a contract: “given this input, the agent should produce this behavior.” The eval framework runs the scenario, captures the agent’s actual output, and compares it against the expected behavior.

Auto-Generating from Telemetry

Writing scenarios from scratch is useful but slow. The Eval Library can scan your agent’s OTel skill.invoke spans and auto-generate scenarios from real behavior. The system analyzes recent telemetry to identify:
  1. Recurring patterns — skills invoked frequently with consistent inputs
  2. Decision points — moments where the agent chose between multiple options
  3. Edge cases — unusual input combinations that produced successful outcomes
The response includes generated scenarios with confidence scores. Review and adjust before adding them to your library — auto-generated scenarios capture what the agent did, not necessarily what it should do.
Auto-generate is best used as a bootstrap. Generate 10-20 scenarios from a week of telemetry, then manually refine the expected behaviors to match your actual requirements.

Variation Types

Variations are behavioral injections that modify the system prompt to test agent susceptibility. Each variation applies a specific cognitive pressure to see if the agent’s output shifts. Variations are applied one at a time during evaluation runs, so you can isolate which pressures affect your agent and which it resists.

Running Evaluations

An evaluation run executes a scenario and captures the result. There are two types:

Baseline Run

Runs the scenario with no variation applied. This establishes the agent’s default behavior.

Variation Run

Runs the same scenario with one variation injected. The system then compares the output to both the expected behavior and the baseline. Two metrics are computed: A high match rate with low shift magnitude means the agent is robust. A low match rate or high shift magnitude under a specific variation means the agent is susceptible to that pressure.
A shift magnitude above 0.5 on a critical-risk scenario is flagged automatically and routed to the Review Queue for human inspection.

Test Matrix

For comprehensive coverage, the Eval Library supports factorial testing: every scenario crossed with every variation.
The matrix is visualized as a heatmap. Color scale:
  • Green (0.0 - 0.2) — No meaningful shift. Agent is robust.
  • Amber (0.2 - 0.5) — Moderate shift. Worth reviewing.
  • Red (0.5 - 1.0) — Critical shift. Agent behavior changed significantly.
Matrix runs can take several minutes depending on the number of scenarios and variations. The parallel flag enables concurrent execution. Results are available via the runs endpoint once complete.

Best Practices

  1. Start with 3-5 scenarios. Cover your agent’s most critical decision points first. Expand the library over time.
  2. Test one variation at a time first. Before running a full matrix, understand how individual variations affect your agent. This makes results easier to interpret.
  3. Review all flagged runs. Any run with shift magnitude above the threshold is routed to the Review Queue. Do not ignore these — they indicate real susceptibility.
  4. Use auto-generate to bootstrap. Generate scenarios from telemetry, then refine the expected behaviors manually. This is faster than writing every scenario from scratch.
  5. Re-run after agent updates. When you update your agent’s model, prompts, or tools, re-run the eval matrix to catch regressions.
  6. Set risk levels accurately. Critical-risk scenarios have stricter thresholds and are flagged more aggressively. Reserve critical for decisions with real consequences.

API Reference