TECHNOLOGY

Promptfoo trace assertions: fast selected spans do not prove an expected operation happened

In this article
THE QUICK TAKE

A timing assertion over selected spans needs a separate existence check when the operation itself is required.

Distinguish an answer from execution evidence

An agent can claim to have searched a dataset without the expected retrieval operation appearing in its execution trace. Promptfoo’s trace assertions can inspect recorded operations rather than relying on answer text. Define whether the requirement concerns a claimed action, an instrumented call or a successful application outcome. These are different observations, and a trace span alone does not establish that its payload was correct or useful.

Verify collection and case correlation

The tracing guide describes collecting trace data for an evaluation. Before writing thresholds, confirm that the inspected trace belongs to the current test and contains the relevant application boundary. A successful request can produce no usable trace when propagation or export is broken. Conversely, unrelated background spans can make an operation appear present. Inspect a diagnostic case with a known operation and compare its trace identity with the evaluation result.

Check selection semantics explicitly

Trace assertions select spans by name patterns and optional attributes. The deterministic-metric reference distinguishes case-insensitive name globbing from exact, type-sensitive attribute matching. Similar-looking tool names do not guarantee a match when an attribute is missing or encoded differently. Retain the selected span set during setup. A filter intended to measure retrieval can otherwise select nothing or include unrelated work while still looking reasonable in a compact configuration file.

Require presence independently of speed

The documentation recommends a minimum span-count assertion when matching operations must exist. A duration or error check is not a substitute for that existence requirement. Also inspect percentile units: the documented percentile scale is percentage-based rather than a fractional probability. The assertion configuration determines how these checks combine into a verdict. Keep operation presence, duration and correctness as separately explainable properties instead of collapsing them into a single reassuring timing number.

Test absent and misidentified operations

Use fixtures containing the expected call, no call and a similarly named unrelated call. Confirm that presence fails where intended and that timing includes only the selected population. The guides to agent budget accounting and mandatory assertion rules provide related controls. Accept the evaluation when trace correlation, selection and existence jointly explain the result, preserving the difference between a fast observed operation and an operation that never happened.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles