Skip to main content

Retrace

CI PyPI License: Apache-2.0 Python

A deterministic record / replay + causal-diff "flight recorder" for AI agents.

Record any agent run as a tamper-evident, replayable event log; reproduce failures exactly; diff two runs to find where — and why — they diverged.

Project site · Live viewer — time-travel through a trace in your browser, no install.

Built by Arnab Pal.

Status: pre-alpha (0.1.0). Record → replay → verify, streaming (SSE) capture, the causal diff (incl. cross-version), zero-code-change auto-wrap (sync + async), a semantic LLM layer, an OpenTelemetry bridge, a time-travel viewer, and a pytest regression plugin all work. Architecture and design docs live in plan/.

Retrace pinning the root cause of a non-deterministic agent failure to one event
Two runs of the same agent diverge — retrace diff pins the root cause to one event and shows the propagation chain.

Why

AI agents are non-deterministic: the same input can take wildly different execution paths, and failures live in multi-step causal chains, not single calls — so you can't snapshot-and-replay them. There's no framework-agnostic, open standard for capturing an agent run and reproducing it.

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

What it does

  • retrace record — capture every source of non-determinism (LLM completions, tool results, retrieval, clock, RNG) at the httpx transport layer + a @retrace.tool decorator, into an append-only, hash-linked .flight trace. Auto-wraps httpx clients, so wrapping a run in with retrace.record(...) is the only code change; large payloads spill to a content-addressed blob store.
  • retrace replay — re-run your real agent code with every recorded response served from the log, so the exact path reconstructs with zero API calls and zero side effects.
  • retrace diff — align two traces, find the first causal divergence, and classify it: model-output drift / tool error / context corruption / retrieval drift / nondeterministic input — showing the propagation chain from root to the symptom you saw. (docs)

Install

pip install retrace-ai          # the import name is `retrace`

Try it

# record + replay a tiny agent offline, then inspect/verify the trace
python examples/weather_agent.py /tmp/weather.flight
python -m retrace.cli inspect /tmp/weather.flight
python -m retrace.cli verify  /tmp/weather.flight

# record two runs where the model drifts, then diff to find the root cause
python examples/flaky_agent.py /tmp/golden.flight /tmp/prod.flight
python -m retrace.cli diff /tmp/golden.flight /tmp/prod.flight

# export a trace and open viewer/index.html in a browser to time-travel through it
python -m retrace.cli export /tmp/weather.flight

Documentation

Full docs live in docs/: getting started, concepts, guide, diffing, testing, observability, integrations, API reference, CLI, trace format, limitations, and FAQ.

The .flight trace format is a language-neutral open standard — see SPEC.md and schema/flight-event.schema.json. The prior art the design builds on (rr, deterministic replay, Certificate Transparency, JCS, sequence/tree diffing, causal attribution) is collected in REFERENCES.md.

Design

Doc Covers
plan/00-overview.md Problem, locked decisions, module map, MVP definition-of-done
plan/01-capture-replay.md Capture + deterministic replay engine
plan/02-trace-format.md The open .flight trace-format spec
plan/03-causal-diff.md Causal divergence diff + classification
plan/10-mvp-roadmap.md Phased build plan (P0–P5)

Contributing

Contributions are welcome — see CONTRIBUTING.md for setup, the test workflow, and the load-bearing invariants. Please also read the CODE_OF_CONDUCT.md. Found a security issue? See SECURITY.md (please don't open a public issue). Release history is in CHANGELOG.md.

License

Apache-2.0 — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

retrace_ai-0.1.0.tar.gz (209.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

retrace_ai-0.1.0-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file retrace_ai-0.1.0.tar.gz.

File metadata

  • Download URL: retrace_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 209.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for retrace_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06182946332b9cc0d4a3aebbb1ab7b376a5d078f4b78db3a52a9bc7eb2ff4ea8
MD5 ac4641bd4deca6bedcf39c556360709e
BLAKE2b-256 ebbd6ba30e28532c5d1ceb6c12f19e18669dbbaf856ca318102cafafeeac346e

See more details on using hashes here.

File details

Details for the file retrace_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: retrace_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for retrace_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17d72154fa8e54f7b66f3cc1f48243b776bc986da0b6041b0752d64a4cc92679
MD5 ee3d703394653f227823173987134000
BLAKE2b-256 624fd84ef22afadb24b8726b47a1d5976b64e7599dd9c404e5bb6652230478d9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page