Flight recorder for LLM agents: trace every call, replay runs deterministically, diff runs to find where behavior diverged.
Project description
AgentRewind
Flight recorder for LLM agents. Trace every LLM and tool call an agent makes, replay a run deterministically (no API calls, no cost, no nondeterminism), and diff two runs to find exactly where their behavior diverged.
"It worked yesterday — why is it different today?" is the defining debugging problem of agent development. Tracing tools show you what happened; AgentRewind also lets you re-execute what happened and compare runs structurally.
Install
pip install llm-run-recorder # core (stdlib-only)
pip install 'llm-run-recorder[server]' # + web trace viewer
Trace
import agentrewind as al
@al.traced(kind="tool")
def search(query: str) -> str:
...
with al.trace("research-agent"):
plan = call_llm(...) # record with al.record_llm_call(...) or a Recorder
evidence = search(plan.query)
Traces (span tree, inputs/outputs, latency, token counts, errors) are stored in a local
SQLite db at ~/.agentrewind/traces.db — no account, no server required.
Replay
Wrap your provider call in a Recorder. Responses are cached by a canonical request
fingerprint; in replay mode the whole agent run re-executes deterministically and offline:
from agentrewind.replay import Recorder
llm = Recorder(call_openai, mode="record") # live run, responses cached
llm = Recorder(call_openai, mode="replay") # deterministic re-run, zero API calls
llm = Recorder(call_openai, mode="auto") # replay on hit, record on miss
Or instrument an SDK client in place — existing code keeps calling it exactly as before:
import agentrewind as al
client = al.instrument(OpenAI(), mode="auto") # or Anthropic()
client.chat.completions.create(model="gpt-4o", messages=[...]) # traced + replayable
(Prefer explicit wrappers? agentrewind.providers.OpenAIChat / AnthropicMessages do the
same without monkey-patching.)
Streaming is captured too: Recorder.call_stream / acall_stream pass chunks through
live while recording them, and replay re-streams the identical chunks offline.
Requests containing volatile fields (timestamps, request ids) can be normalized before
fingerprinting with Recorder(..., canonicalize=strip_volatile) so they still replay.
Async agents are supported throughout: @al.traced works on async def functions
(context propagates through awaits and asyncio.gather), and Recorder.acall is the
awaitable variant for async provider clients.
Diff
$ agentrewind diff 3f2a91 8c17d0
2 divergence(s); first divergence is where the runs split:
1. [input] /llm:mock-4o — inputs differ
left : {"messages":[{"content":"decide next step",...
right: {"messages":[{"content":"decide the next step",...
2. [output] /tool:search — outputs differ
The diff walks both span trees in parallel and reports structure, input, and output divergences in execution order — entry #1 is where the runs first split.
CLI & viewer
agentrewind list # recent runs
agentrewind show <trace-id> # span tree with latencies
agentrewind diff <run1> <run2> # structural diff (exit code 2 if runs differ)
agentrewind serve # web viewer at http://127.0.0.1:4317
The web viewer shows the span waterfall per run, and lets you select any two runs to see
a side-by-side divergence view (/api/diff/{a}/{b} for programmatic access).
Try the demo (offline, no API key)
python examples/research_agent.py # records two runs with a seeded regression
agentrewind diff <run1> <run2> # pinpoints the prompt change that caused it
Development
pip install -e '.[dev]'
pytest
ruff check .
Note for macOS: if this repo lives in an iCloud-synced folder (e.g. ~/Documents), create
your virtualenv outside it (e.g. ~/.venvs/agentrewind) — the file provider marks files in
dot-directories as hidden, and Python ≥3.13 skips hidden .pth files, which breaks
editable installs.
MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_run_recorder-0.2.0.tar.gz.
File metadata
- Download URL: llm_run_recorder-0.2.0.tar.gz
- Upload date:
- Size: 276.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6609124f300e17139bf4a2cfb0dfea911ba9f4ff72825b0c9aeebffec3fc180c
|
|
| MD5 |
67371b7f8a529f43c94a3418b0565526
|
|
| BLAKE2b-256 |
16366bff2930b084395ccbae94418210b2d24aa73e290ba50ac1dd9ea279acf5
|
Provenance
The following attestation bundles were made for llm_run_recorder-0.2.0.tar.gz:
Publisher:
release.yml on Shravya29M/agentrewind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_run_recorder-0.2.0.tar.gz -
Subject digest:
6609124f300e17139bf4a2cfb0dfea911ba9f4ff72825b0c9aeebffec3fc180c - Sigstore transparency entry: 2148308917
- Sigstore integration time:
-
Permalink:
Shravya29M/agentrewind@c5b534f933679b48f5fbb220cd45b0af732f54a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Shravya29M
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c5b534f933679b48f5fbb220cd45b0af732f54a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_run_recorder-0.2.0-py3-none-any.whl.
File metadata
- Download URL: llm_run_recorder-0.2.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df73dc640eb5c1e730cf815bb32c02fc51991013f439d7e198db9b9546db0de6
|
|
| MD5 |
4aacc37c33d43ac02cf234ae9c65d1e4
|
|
| BLAKE2b-256 |
98e9cc0ae3e217ea63124b8c6599cd941a0f2116c3027a21f85d803309bda9c3
|
Provenance
The following attestation bundles were made for llm_run_recorder-0.2.0-py3-none-any.whl:
Publisher:
release.yml on Shravya29M/agentrewind
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_run_recorder-0.2.0-py3-none-any.whl -
Subject digest:
df73dc640eb5c1e730cf815bb32c02fc51991013f439d7e198db9b9546db0de6 - Sigstore transparency entry: 2148308918
- Sigstore integration time:
-
Permalink:
Shravya29M/agentrewind@c5b534f933679b48f5fbb220cd45b0af732f54a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Shravya29M
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c5b534f933679b48f5fbb220cd45b0af732f54a8 -
Trigger Event:
push
-
Statement type: