Expand description
§trace-diff
Diff two agent traces semantically.
A “step” is { type, key, payload }. The diff walks both traces in
order; aligned positions are compared by (type, key). The result
lists steps that are Added, Removed, or Changed. Timestamps
and noisy ids are not compared.
Use this in agent regression suites: capture a baseline trace once,
re-run the agent, diff the new trace against the baseline. Any
Changed step is something worth looking at.
§Example
use trace_diff::{diff, Step, Change};
use serde_json::json;
let base = vec![
Step { kind: "tool_call".into(), key: "read".into(), payload: json!({"path": "a.txt"}) },
Step { kind: "tool_call".into(), key: "write".into(), payload: json!({"path": "out.txt"}) },
];
let new = vec![
Step { kind: "tool_call".into(), key: "read".into(), payload: json!({"path": "a.txt"}) },
Step { kind: "tool_call".into(), key: "write".into(), payload: json!({"path": "out.NEW.txt"}) },
];
let changes = diff(&base, &new);
assert!(matches!(changes[0], Change::Changed { .. }));Structs§
- Step
- One step in a trace.
Enums§
- Change
- A single change.
Functions§
- diff
- Diff
baseagainstnew. Returns one entry per detected change.