Open source · Apache-2.0 · Python 3.13+

A flight recorder
for AI agents.

Record any agent run as a tamper-evident, replayable log. Reproduce non-deterministic failures exactly — then diff two runs to find where, and why, they diverged.

$ pip install retrace-ai
Every source of non-determinism

Sealed into one hash-linked trace.

Agents fail in multi-step causal chains, not single calls. Retrace captures every non-deterministic input at the httpx transport layer — so replay reconstructs the exact path.

LLM completions incl. streaming SSE Tool results @retrace.tool Retrieval RAG context Clock reads time.time RNG draws random
The loop

Record → replay → diff.

Distributed-systems record/replay rigor — event sourcing, deterministic replay, hash-linked logs, causal tracing — applied to the agent-reliability problem.

01 / RECORD

retrace.record()

Wrap a run in one with block. Auto-wraps httpx, so it's the only code change. Every LLM, tool, clock and RNG source lands in an append-only, hash-linked .flight trace; large payloads spill to a content-addressed blob store.

02 / REPLAY

retrace.replay()

Re-run your real agent code with every recorded response served from the log. The network is sealed — zero API calls, zero side effects — and the exact execution path reconstructs, byte for byte.

03 / DIFF

retrace diff

Align two traces, find the first causal divergence, and classify it — model drift, tool error, context corruption, retrieval drift — showing the propagation chain from root to the symptom you actually saw.

event 6 · http.response
model returns AI-020
root cause
──▶
event 9 · tool.call
book_flight(AI-020)
propagates
──▶
event 12 · tool.result
booking mismatch
symptom
What's in the box

More than a cassette.

The full loop works today: capture, sealed replay, causal diff, and the tooling to put it in CI.

Tamper-evident trace

Append-only, SHA-256 hash-linked .flight log with an offline verify(). An open, language-neutral spec.

Network-sealed replay

A replay that can't match a request fails loud — it never silently hits the network or returns a live value.

Causal diff

Aligns runs, isolates the first divergence, separates root cause from downstream symptom.

Cross-version diff

Names a PROMPT_CHANGE across code versions with difflib similarity grading and inline edits.

Semantic LLM layer

Derives a clean provider / model / messages / usage view straight from the raw http.* events.

OpenTelemetry bridge

Emits GenAI-convention spans, so a trace drops into the observability stack you already run.

Time-travel viewer

A self-contained console: gauges, span waterfall, step inspector, hash chain, run-vs-run diff.

pytest plugin

Record once, replay in CI. A run that diverges from the golden trace fails the build with guidance.

Live

Time-travel through a trace.

The viewer is one self-contained HTML file — no build, no server. Open it, load a trace exported with retrace export, and step through every event with the run-vs-run diff mode.

Open the viewer →
Retrace pinning the root cause of a non-deterministic agent failure to a single event.