Skip to main content

llmreplay

Deterministic replay debugger for LLM agents. Records LLM calls and tool executions to SQLite, replays from the log with no network calls.

from llmreplay import record, replay

# Record
with record("my_run", seed=42):
    response = client.chat.completions.create(...)

# Replay — zero network calls
session = replay("my_run")
for event in session.events():
    print(event.step, event.kind, event.payload)

Install

pip install llmreplay

Requirements: Python >= 3.10

What gets recorded

  • LLM requests/responses (OpenAI, Anthropic, Grok/xAI, Gemini)
  • Tool calls/results (via @record_tool decorator)
  • Random seeds (Python random, numpy)
  • Exceptions

Events are stored in ~/.llmreplay/<run_id>.db.

CLI

llmreplay list                    # List recorded runs
llmreplay view my_run             # Show all events
llmreplay view my_run --step 42   # Jump to step
llmreplay cost my_run             # Cost breakdown
llmreplay export my_run --json    # Export bug report
llmreplay web my_run              # Launch timeline UI

Features

Auto-instrumentation — OpenAI, Anthropic, Grok, Gemini, LangChain hooks install automatically within record() context.

Tool mocking — Record tool I/O with @record_tool, replay with ToolMocker:

from llmreplay import ToolMocker, EventStore

mocker = ToolMocker()
mocker.load(EventStore("my_run"))

@mocker.mock(name="fetch_price")
def fetch_price(ticker: str) -> dict: ...  # returns recorded result

Regression testing — Run recorded traces against updated code:

from llmreplay import RegressionSuite

suite = RegressionSuite()

@suite.case("run_001")
def check(original, session):
    return session.total_cost() <= original["total_cost_usd"] * 1.1

suite.run()

Fork/branch — Copy a trace up to a step for counterfactual debugging:

from llmreplay import fork
new_store = fork("broken_run", "fixed_run", at_step=50)

Fine-tuning export — Export prompt/response pairs:

from llmreplay import export_finetune_dataset
export_finetune_dataset(["run_001", "run_002"], "data.jsonl")

License

MIT

Metadata

Release files for llmreplay 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmreplay 0.1.2
File Size Uploaded
llmreplay-0.1.2.tar.gz 41.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llmreplay 0.1.2
File Interpreter ABI Platform
llmreplay-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 68.4 kB

Release files / llmreplay-0.1.2.tar.gz

Download URL llmreplay-0.1.2.tar.gz
Size 41.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d4a8c6bafbaeb2aa431d911c3787e423b42e8cf9911cdac78a089b654ee3d366
BLAKE2b-256 checksum
How to use checksums
7a6fbd79286e2a5e479c36920519f1ec61b2dede5aa9258c568bf94748760c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / llmreplay-0.1.2-py3-none-any.whl

Download URL llmreplay-0.1.2-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf16eea1ca094b49e61422cb35a36494fb6f124e9464e0eff2d4061a95a41005
BLAKE2b-256 checksum
How to use checksums
edbb46c23d948fdd46182d838d7f651521a8245c06adb10dc98d80d8ddba3eec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release 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