Skip to main content
When a detection bug is fixed, keep an example of the original behavior. Otherwise a later threshold or policy change can bring it back unnoticed. The repository’s labeled trace fixture and offline tests provide a starting point. You do not need a model API key to replay them.

Choose what the case should prove

Keep healthy and unhealthy behavior together. If you add an empty-result loop, also retain healthy polling where the tool repeats but the output advances. Write down the expected policy decision before tuning the implementation. Do not label every repeated call as stuck, or assume a continue decision proves that the agent answered correctly. Answer quality needs separate checks.

Add a labeled run

examples/v02_labeled_traces.json is a list of runs. Each includes a run_id, label, expected_decision, a short explanation in why, and the recorded steps. For example, a healthy polling case can look like this:
Append the case to the fixture’s existing list. Use a distinct ID and keep only the details needed to reproduce the behavior. Preserve tool results and caller information when they matter to the detection. label, why, and expected_decision are test annotations; the trace analyzer does not use them to choose its decision. The existing test compares the replayed final decision with expected_decision.

Replay and compare

From the source checkout:
The replay does not call the original tools or the model. If a decision differs, inspect the recorded results, detector signals in a live report, and the policy rules before changing the expected label. To inspect the same expected-decision comparison in Python:
Use dedicated tests for custom detector mixes, semantic embeddings, or callback exception propagation. The default offline trace replay does not cover those integration paths automatically.

Use check mode for a different question

A labeled fixture deliberately includes runs that should stop. Those are passing regression tests when the expected stop happens. Running this command against that same fixture will normally fail:
That is expected. check asks whether any run violates the selected failure rules; it does not compare results with expected_decision annotations. Use it to gate a collection of runs expected to meet your application’s pass/fail rules. Keep the two checks distinct: Saved-trace flags and exit codes explain how to select those failure rules. Contributing and maintenance explains how the repository runs its checks on pull requests.