In this article
A stateful check evaluates the current trace together with its retained history, so the check instance is part of the experiment.
Define why the checker needs memory
Most evaluation checks can decide from the current trace. A requirement about duplication across a batch or an accumulated condition may need retained state. The stateful-check guide explains that this changes dependence on execution order and previous runs. State the population over which memory should accumulate before implementing the check. Otherwise, a test failure can reflect the lifetime of an evaluator object rather than the application’s intended behavior.
Share or recreate the instance deliberately
A check tracking previously seen outputs must use the same instance across the intended batch. Creating a new object for each scenario erases the comparison history. Conversely, reusing that instance across independent tests can carry unrelated state into a fresh experiment. Define initialization and reset boundaries explicitly. A fixture can create a fresh instance for independent tests, while a deliberately shared batch object preserves the broader condition the check was designed to measure.
Prefer trace evidence for local history
The dynamic-scenario guide describes interactions whose inputs or outputs depend on the evolving trace. When a requirement concerns an earlier turn in the same scenario, inspect that trace instead of duplicating its history in hidden checker state. This keeps the evidence attached to the evaluated interaction and makes replay easier to explain. Cross-scenario state should serve a requirement that genuinely extends beyond the current trace, rather than becoming an unnecessary second conversation store.
Account for order and concurrency
The library overview describes asynchronous behavioral tests. A shared mutable check used across concurrent scenarios needs a declared policy for when observations become visible to each other. For a duplicate detector, the identity of the first passing scenario can depend on completion order even when the batch-level conclusion is stable. Preserve both the intended invariant and execution evidence. Do not interpret a different failed row as a model regression without checking whether only arrival order changed.
Verify independent and shared runs
Use a diagnostic batch with a repeated output, then rerun it with a fresh checker and with deliberately retained state. Confirm the expected difference and inspect any cross-test contamination. The guides to conversation batch boundaries and saved suite replay provide related controls. Accept the design when object lifetime, reset behavior and batch scope explain the verdict, preserving the distinction between a reproducible application requirement and an accidental dependency on which other tests ran first.
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.