Skip to content
aakash1552005Public

About

Deterministic flight recorder, $0 CI replay engine, and time-travel debugger for AI agents.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Latest commit

Β 

History

139 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ“Ό Rerunner

Deterministic flight recorder, replay engine, and CI test runner for AI agents.

CI Release PyPI Python Version GitHub Action License Code style: ruff Type Checked: mypy Docs

English Β· δΈ­ζ–‡ Β· ζ—₯本θͺž Β· ν•œκ΅­μ–΄ Β· EspaΓ±ol Β· Deutsch

Record your AI agent once. Replay forever in CI in 0ms with $0 API tokens.

# 1-Line Quickstart: install + wire Rerunner MCP into Claude Code, Cursor & Codex
pip install rerunner && rerunner setup --clients claude,cursor,codex

Rerunner Replay vs Live Latency

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  $ pytest tests/test_agent.py -v                                       β”‚
  β”‚                                                                        β”‚
  β”‚  tests/test_agent.py::test_rag_pipeline ....................... [100%] β”‚
  β”‚                                                                        β”‚
  β”‚  πŸ“Ό [rerunner] Loaded cassette: tests/cassettes/rag_eval.jsonl        β”‚
  β”‚  ⚑ Replayed: 8 LLM calls (OpenAI gpt-4o + Anthropic Claude 3.7)      β”‚
  β”‚  πŸ›‘οΈ PII Check: 0 leaks | Hash Chain: Verified [3a8f9c1b]              β”‚
  β”‚  ⏱️ Duration: 0.04s (Saved 18.4s of live network calls)               β”‚
  β”‚  πŸ’° Token Cost: $0.00 (Saved $0.24 API credits)                       β”‚
  β”‚                                                                        β”‚
  β”‚  ========================= 1 passed in 0.04s ========================= β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—οΈ Architecture

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                            AGENT APPLICATION                                β”‚
  β”‚    Claude Code Β· OpenAI Β· AutoGen Β· Semantic Kernel Β· LangGraph Β· MCP       β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚  (Zero-Touch Outbound Interception)
                                         β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                       RERUNNER ENGINE & TRANSPORTS                          β”‚
  β”‚     CassetteTransport Β· AsyncCassetteTransport Β· RerunnerMCPClient          β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚ [RECORD MODE]                     β”‚ [REPLAY MODE]
                     β–Ό                                   β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚         SECURITY & INTEGRITY         β”‚  β”‚       DETERMINISTIC RUNTIME       β”‚
  β”‚  β€’ PII & Luhn Credit Card Sanitizer  β”‚  β”‚  β€’ 0ms Network Latency            β”‚
  β”‚  β€’ Presidio & SSN Redaction          β”‚  β”‚  β€’ $0 API Token Costs             β”‚
  β”‚  β€’ Tamper-Evident SHA-256 Chaining   β”‚  β”‚  β€’ Fail-Closed Side-Effect Guard  β”‚
  β”‚  β€’ HMAC-SHA256 Digital Signature     β”‚  β”‚  β€’ Per-Key Cursor Replay Matching β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚                                          β”‚
                     β–Ό                                          β”‚
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚                      CASSETTE PERSISTENCE STORAGE                           β”‚
  β”‚       Streaming JSONL Β· Zstandard (.zst) Β· Gzip (.gz) Β· AWS S3 Β· GCS        β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ The Problem

Testing production AI agents and running them in Continuous Integration (CI) creates major bottlenecks:

  1. Flaky CI Builds: LLMs are non-deterministic. Small model drift breaks downstream assertions across pull requests.
  2. High API Costs: Running an 8-step agent across dozens of CI runs drains thousands of dollars in LLM API credits.
  3. Reproducibility & Debugging: When an agent fails at Step 5, you cannot reproduce the bug locally without re-running Steps 1 through 4 live.

Rerunner solves this by providing a lightweight cassette recorder that intercepts httpx, requests, and aiohttp traffic natively across the Anthropic Claude SDK, OpenAI SDK, Google GenAI SDK, Cohere SDK, AWS Bedrock, Model Context Protocol (MCP), Microsoft AutoGen, Semantic Kernel, and LangChain / LangGraph β€” plus a universal HTTP/SSE proxy (rerunner serve) for TypeScript, Go, Rust, and browser agents.


πŸš€ Key Features

  • $0 CI Replays: Record agent interactions to append-only JSONL cassettes and replay in CI with zero network latency and $0 token spend.
  • Model Context Protocol (MCP) Replay: Deterministically record and replay MCP tool invocations, prompts, and resources without launching local servers.
  • Official GitHub Action: Zero-config marketplace composite action (aakash1552005/rerunner@main) caching cassettes and reporting token savings directly on PRs.
  • CI Token & Cost Estimator: Built-in rerunner cost calculating avoided API dollar expenses and posting markdown summaries to $GITHUB_STEP_SUMMARY.
  • Fork-from-Step Replay: Replay steps 1..N from tape for free, and execute step N+1 live against the model with a modified prompt or code fix.
  • Fail-Closed Side-Effect Guard: The @side_effect decorator prevents destructive external actions (database updates, payments, webhooks) during replays.
  • Per-Key Cursor Matching: Accurately replays repeated identical requests and retry loops in recorded sequential order.
  • Streaming SSE Replay: Records text/event-stream chunks and replays token-by-token with simulated network latency (chunk_delay_ms).
  • JSON-Safe Secret Redaction: Automatically scrubs API keys, Bearer tokens, emails, phone numbers, and SSNs while strictly preserving JSON syntax.
  • Tamper-Evident Integrity: SHA-256 hash chaining detects accidental line edits, with optional HMAC-SHA256 digital signing.
  • Pytest Integration: Seamless @pytest.mark.rerunner marker and rerunner_transport fixture.
  • Pluggable Remote Storage: Store cassettes locally, in compressed formats (.jsonl.gz, .jsonl.zst), or directly in AWS S3 (s3://), Google Cloud Storage (gs://), and Microsoft Azure Blob Storage (az://, azure://).
  • Interactive Terminal Flight Deck: Visually scrub and inspect multi-turn agent execution steps, tokens, and cryptographic security audits via rerunner tui.

πŸ“Š Comparison

Feature rerunner vcrpy / pytest-recording respx LangGraph Checkpoints
Primary Focus Deterministic Agent CI Replay Generic HTTP recording Manual HTTPX mocking Orchestration State
LLM Streaming (SSE) Support βœ… Native SSE token stream replay ⚠️ Buffers raw byte stream ⚠️ Manual stream setup N/A
Fork-from-Step Execution βœ… Replay 1..N, execute live from N+1 ❌ No ❌ No ⚠️ Subgraph re-execution
Fail-Closed Side-Effect Guard βœ… Yes (@side_effect) ❌ No ❌ No ❌ No
Secret & URL Redaction βœ… Built-in JSON & URL redactor ⚠️ Custom filter functions ❌ No ❌ No
Pluggable Cloud Storage βœ… Local, S3, GCS, Azure Blob βœ… Local YAML βœ… In-memory ⚠️ Postgres / Redis required
Framework Agnostic βœ… Any HTTPX-based SDK βœ… HTTP socket level βœ… HTTPX ❌ Locked to LangGraph

⚑ Performance & Cost Reduction Benchmarks

Every AI agent test run in CI consumes live network round-trips and expensive model tokens. Rerunner eliminates both completely:

Metric Live LLM Calls (OpenAI/Anthropic) Rerunner Replay (Air-Gapped) Improvement
Average Step Latency ~350 ms 0.22 ms - 0.57 ms ⚑ 600x – 1,600x Faster
Token Cost ~$5.00 / 100k tokens $0.00 πŸ’° 100% Token Cost Reduction
Network Flakiness High (Rate limits, DNS, Outages) Zero (0 network calls) πŸ”’ 100% Deterministic
Side-Effect Risk High (Accidental DB mutations) Guarded (@side_effect) πŸ›‘οΈ Fail-Closed Safety

Measured on Python 3.12 across 10 sequential agent reasoning steps. Run locally with uv run python benchmarks/bench_replay_latency.py.


πŸ“š Runnable Cookbooks & Examples

Explore standalone, ready-to-run cookbooks in the examples/ directory:

Cookbook Framework Description
01_openai_quickstart.py OpenAI SDK End-to-end recording and replay of chat completions with zero network access.
02_anthropic_sse_streaming.py Anthropic Claude SDK Token-by-token Server-Sent Events (SSE) streaming replay with configurable latency pacing.
03_mcp_sqlite_replayer.py Model Context Protocol Deterministic MCP tool invocation record/replay without starting database servers.
04_chaos_fault_injection.py Chaos Engineering Simulating upstream HTTP 429 rate limits, exponential backoff, and agent model fallback.

πŸ” Scope & Limitations

  • Transport Layer: Rerunner intercepts httpx.BaseTransport and httpx.AsyncBaseTransport. This covers the official Python SDKs for Anthropic Claude, OpenAI, and Google GenAI.
  • Other HTTP Libraries: SDKs that rely exclusively on standard library urllib, requests, or raw gRPC (such as AWS Bedrock via boto3 or Vertex AI gRPC channels) require configuring custom HTTPX client wrappers or transport bridges.

πŸ“¦ Installation

# Standard installation
pip install rerunner

# With optional extras
pip install "rerunner[s3]"         # AWS S3 remote storage
pip install "rerunner[gcs]"        # Google Cloud Storage
pip install "rerunner[zstd]"       # Zstandard compression (.zst)
pip install "rerunner[all]"        # All storage & compression extras

πŸ› οΈ Quickstart

1. Recording an Agent Session

Rerunner transparently attaches to SDK clients via httpx.Client(transport=...):

import anthropic
import httpx
from rerunner import CassetteTransport

# 1. Record live interactions to a cassette
transport = CassetteTransport("session.jsonl", mode="record")
client = anthropic.Anthropic(http_client=httpx.Client(transport=transport))

response = client.messages.create(
    model="claude-3-7-sonnet-20250219",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Analyze quarterly revenue report."}],
)
print(response.content[0].text)

2. Deterministic $0 Replay in CI

# 2. Replay locally or in CI without spending API tokens or waiting on network
transport = CassetteTransport("session.jsonl", mode="replay")
client = anthropic.Anthropic(http_client=httpx.Client(transport=transport))

# Instant response, zero cost, completely reproducible
response = client.messages.create(
    model="claude-3-7-sonnet-20250219",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Analyze quarterly revenue report."}],
)

3. Forking from Step 3

from rerunner import fork

# Replay steps 1 through 3 from cassette; run step 4 live with your modified prompt
with fork("session.jsonl", step=3) as session:
    client = session.get_client()
    # Steps 1..3 replayed from tape
    # Step 4 executed live against model

4. Streaming SSE Replay

Rerunner records responses with text/event-stream headers as individual chunks and yields them through HTTPX's streaming interface during replay:

import httpx
import openai
from rerunner import CassetteTransport

transport = CassetteTransport("agent_run.jsonl", mode="replay", chunk_delay_ms=20)
client = openai.OpenAI(
    api_key="not-used-during-replay",
    http_client=httpx.Client(transport=transport),
)

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Summarize this report."}],
    stream=True,
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

πŸ›‘οΈ Guarding External Side-Effects

Use @side_effect to prevent destructive actions (database writes, notifications, payment charges) during replay:

from rerunner import side_effect


@side_effect(name="charge_customer")
def charge_card(user_id: str, amount: float) -> str:
    # Runs live during recording.
    # During replay, returns recorded result and never touches Stripe.
    # If no recorded call matches, fails closed by raising SideEffectError!
    return stripe.charge(user_id, amount)

πŸ§ͺ Pytest Integration

Mark your tests with @pytest.mark.rerunner:

import httpx
import openai
import pytest


@pytest.mark.rerunner("tests/fixtures/agent_run.jsonl")
def test_agent_decision(rerunner_transport):
    client = openai.OpenAI(http_client=httpx.Client(transport=rerunner_transport))
    completion = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Evaluate risk factor"}],
    )
    assert "low risk" in completion.choices[0].message.content.lower()

Run tests from the terminal:

# Run test suite in replay mode (0 network calls, $0 token cost)
pytest

# Re-record cassettes when prompts change intentionally
pytest --rerunner-record

⚑ 1-Line Client Wrappers

Wrap existing SDK clients directly:

import anthropic
import openai
from rerunner.integrations import wrap_anthropic, wrap_openai

# Wrap Anthropic Claude client (sync or async)
client_claude = wrap_anthropic(anthropic.Anthropic(), "agent_run.jsonl", mode="replay")

# Wrap OpenAI client (sync or async)
client_openai = wrap_openai(openai.OpenAI(), "agent_run.jsonl", mode="replay")

Cohere (pip install "rerunner[cohere]") works the same way, for cohere.Client, cohere.ClientV2 and their async variants:

import cohere
from rerunner.integrations import wrap_cohere

client_cohere = wrap_cohere(cohere.ClientV2(), "agent_run.jsonl", mode="replay")

1-Line Framework Adapters

πŸ€– Model Context Protocol (MCP) Replay

Record and replay MCP tool invocations, prompts, and resources without spinning up local servers or subprocesses:

from rerunner.integrations import RerunnerMCPClient, record_mcp_tool

# 1. Context manager for MCP tool calls
with RerunnerMCPClient("cassettes/mcp_agent.jsonl", mode="replay") as mcp:
    result = mcp.call_tool("read_file", {"path": "/workspace/data.json"})


# 2. Or decorate Python functions as deterministic MCP tools
@record_mcp_tool(name="fetch_weather")
def fetch_weather(city: str) -> dict: ...

🀝 Microsoft AutoGen (AG2)

from autogen import AssistantAgent
from rerunner.integrations import wrap_autogen_agent

assistant = AssistantAgent("assistant", llm_config=llm_config)
wrap_autogen_agent(assistant, "cassettes/autogen_debate.jsonl", mode="replay")

🧠 Microsoft Semantic Kernel

import semantic_kernel as sk
from rerunner.integrations import wrap_semantic_kernel

kernel = sk.Kernel()
# ... configure connectors ...
wrap_semantic_kernel(kernel, "cassettes/sk_flight.jsonl", mode="replay")

πŸ›‘οΈ AWS Bedrock

from rerunner.integrations import wrap_bedrock_client

# Direct HTTP client configured for Amazon Bedrock
client = wrap_bedrock_client(bedrock_client, "cassettes/bedrock.jsonl", mode="replay")

πŸ¦œοΈπŸ”— LangChain & LangGraph State Checkpointing

# 1. Multi-Agent State Checkpointing for LangGraph
from rerunner.integrations.langgraph import RerunnerCheckpointer, wrap_langgraph_graph

# Deterministically record or replay multi-agent cyclic decision graphs
app = wrap_langgraph_graph(workflow.compile(), "cassettes/langgraph.jsonl", mode="replay")
output = app.invoke({"messages": [("user", "Summarize research paper")]})

# 2. Or wrap LangChain chat models directly
from langchain_openai import ChatOpenAI
from rerunner.integrations import wrap_langchain_model

llm = wrap_langchain_model(ChatOpenAI(model="gpt-4o"), "cassettes/langchain.jsonl", mode="replay")

# 3. Or callback handler for graph nodes
from rerunner.integrations import RerunnerCallbackHandler

handler = RerunnerCallbackHandler("cassettes/langchain_callbacks.jsonl", mode="replay")
graph.invoke({"input": "research quantum computing"}, config={"callbacks": [handler]})

⚑ Official GitHub Action

Add zero-latency deterministic caching and automated token savings reports to your GitHub Actions CI with 3 lines:

- name: Checkout Code
  uses: actions/checkout@v4

- name: Rerunner CI Replay & Cache
  uses: aakash1552005/rerunner@main
  with:
    cassette-dir: 'tests/cassettes'
    report-savings: 'true'

Optionally enable a recorded cost regression gate by preparing a trusted baseline directory (for example, cassettes from the base commit in a separate checkout) and candidate cassettes before invoking the action:

For example, in a pull request job after checking out the candidate and installing Rerunner:

- uses: actions/checkout@v4
  with:
    ref: ${{ github.event.pull_request.base.sha }}
    path: .rerunner-baseline
    persist-credentials: false

- uses: aakash1552005/rerunner@main
  with:
    cassette-dir: 'tests/cassettes'
    cost-baseline-dir: '.rerunner-baseline/tests/cassettes'
    cost-tolerance-pct: '15'

The opt-in gate runs before cassette cache restoration. It compares mean recorded tokens and estimated USD per cassette, using the same current pricing configuration for both sets. Keep the workload and relative cassette paths identical; matching paths do not prove semantic equivalence, so the caller must ensure the scenarios are comparable. For an enforced policy, keep the baseline, comparator and pricing configuration trusted by the caller. All HTTP responses must have explicit, valid recorded input and output token counts with consistent totals (including separately reported cache tokens). Total-only usage, mixed non-model HTTP traffic, unsupported streaming usage formats, corrupt or missing cassettes make the comparison unavailable rather than treating missing data as zero or using blended rates for incomplete usage. Nonzero nested cache hits (prompt_tokens_details.cached_tokens or input_tokens_details.cached_tokens) are rejected: the existing estimator does not price these included input tokens correctly. Explicit zero nested hits are accepted. Custom pricing must specify both numeric, finite, non-negative rates; incomplete, invalid or conflicting entries fail the gate instead of silently falling back. This stricter validation applies only to cost regression, not to the existing savings reports. No model requests are made. USD values are estimates (including reference-rate fallbacks), not actual billed costs or offline replay costs.

The gate writes a Markdown comparison to the GitHub step summary and exits nonzero if either metric increases by more than the tolerance (exact threshold is allowed; estimated USD comparisons allow relative floating-point noise of 1e-12 at the boundary). A positive value against a measured zero baseline is a regression with no defined percentage. Missing or invalid comparisons also fail the gate. Without the baseline input the original action behavior is unchanged. Run locally with rerunner cost-regression .rerunner-baseline/tests/cassettes tests/cassettes --tolerance-pct 15.

Automatically renders an executive savings table directly on your GitHub Actions summary:

Metric Offline Replay Live API Estimate Savings / Benefit
Total Steps Replayed 124 124 100% Deterministic
HTTP / Model Calls 88 88 Zero flaky fails
Tokens Replayed 142,500 142,500 100% Token Savings
Estimated Cost $0.00 ~$0.7125 Saved ~$0.7125
CI Execution Time 0.8s ~48.2s ~47.4s Faster

πŸ”’ Automated Secret & URL Sanitization

Rerunner automatically redacts sensitive data before persisting cassettes:

  • Anthropic Keys (sk-ant-...) $\rightarrow$ [REDACTED_ANTHROPIC_KEY]
  • OpenAI Keys (sk-proj-..., sk-...) $\rightarrow$ [REDACTED_OPENAI_KEY]
  • Google API Keys (AIza...) $\rightarrow$ [REDACTED_GOOGLE_API_KEY]
  • URL Query Parameters (?key=..., ?api_key=..., ?token=...) $\rightarrow$ [REDACTED_API_KEY]
  • Authorization Headers (Bearer ...) $\rightarrow$ Bearer [REDACTED_TOKEN]
  • Credit Cards (validated with Luhn checksum) $\rightarrow$ [REDACTED_CREDIT_CARD]
  • JSON Structure Preservation: Numeric fields (like "created": 1730000000) remain valid numbers.
  • Streamed Responses: SSE chunks are checked against the sanitized joined text, so a value split across network chunks is still redacted. The placeholder lands in the chunk where enough of the value has arrived to recognise it (normally the chunk where it completes), earlier fragments become empty chunks, other chunks are untouched, and chunk counts stay aligned with recorded delays.
  • Colliding Keys: when two JSON keys sanitize to the same placeholder, later ones get a #2, #3 suffix so no record is dropped. Names of keys that are not redacted are never reused for a suffix.

Optional Sether backend

Install the sether extra to run Sether detectors after the built-in patterns. Nothing changes unless pii_redactor is set, and sether is never imported on the default path.

pip install "rerunner[sether]"
from rerunner import CassetteTransport, SetherRedactor

transport = CassetteTransport(
    "cassettes/support_agent.jsonl",
    mode="record",
    pii_redactor=SetherRedactor(),
)

Session, record() and fork() accept the same pii_redactor argument.

  • Entities: EMAIL_ADDRESS, PHONE_NUMBER, CREDIT_CARD and US_SSN, emitting the same [REDACTED_*] placeholders. IP_ADDRESS stays on the built-in version-aware regex. Select a subset with SetherRedactor(entities=[...]).
  • What it adds: international + phone numbers for any country, Luhn-valid 13 to 19 digit cards (for example 15-digit Amex), and emails whose TLD is longer than seven characters. US_SSN adds nothing beyond the built-in pattern and is accepted for entity selection only.
  • Phone regions: PHONE_NUMBER matches international numbers only by default. SetherRedactor(phone_regions=["NG", "GB"]) also matches national formats for those countries (ISO 3166-1 alpha-2), at the cost of more false positives on bare 10-digit identifiers.

πŸ’» CLI Commands

# Calculate CI cost reductions, token savings, and generate GitHub step summaries
rerunner cost tests/cassettes --ci-summary

# Audit system dependencies, environment variables, and active transports
rerunner doctor

# Audit recorded cassettes for broken hash chains and unredacted secrets
rerunner doctor session.jsonl session.jsonl.zst session.jsonl.gz

# Scrub secrets and re-sign cryptographic SHA-256 hash chains across existing cassettes
rerunner scrub session.jsonl

# Preserve supported PII formats using deterministic synthetic values
rerunner scrub session.jsonl --pseudonymize --output synthetic.jsonl

# Launch interactive terminal flight deck to visually inspect multi-turn agent steps
rerunner tui session.jsonl

# Inspect cassette details, step sequences, and metadata
rerunner inspect session.jsonl

# Compare prompt and response divergences between two cassettes with drift detection
rerunner diff session_v1.jsonl session_v2.jsonl --fail-on-drift

# Verify cryptographic SHA-256 and HMAC-SHA256 integrity chains
rerunner verify session.jsonl

# Export cassette into OpenTelemetry (OTel) OTLP trace JSON format
rerunner export-otel session.jsonl -o session.otel.json

# Export recorded conversations into fine-tuning & evaluation datasets (OpenAI / ShareGPT / Alpaca)
rerunner export-eval session.jsonl -o session.eval.jsonl --format openai

# Visually play back agent execution steps in terminal with Rich styling
rerunner play session.jsonl

# Export a self-contained interactive HTML flight trace (zero CDN)
rerunner inspect session.jsonl --export-html trace.html

# Start cross-language HTTP/SSE replay proxy for TypeScript, Go, Rust, or Docker agents
rerunner serve session.jsonl --mode replay --port 8080

# Replay 50 concurrent copies of a recorded HTTP session locally
rerunner load-gen session.jsonl --concurrency 50 --json

# Start stdio MCP server or auto-configure Claude Code, Cursor, and Codex
rerunner mcp
rerunner setup --clients claude,cursor,codex

# Merge sharded cassettes into one re-numbered, SHA-256-chained cassette
rerunner merge shard1.jsonl shard2.jsonl -o combined.jsonl

# Generate Ed25519 keys and sign/verify a cassette Merkle root
rerunner keygen -o .keys
rerunner sign session.jsonl --private-key .keys/rerunner_ed25519.key

In a color-capable terminal, rerunner diff highlights added steps in green and removed steps in red. Redirected output stays plain; set NO_COLOR=1 to disable colors in the terminal.

With --pseudonymize, scrub replaces recognized emails, UUIDs, US SSNs and Luhn-valid 16-digit card strings with deterministic synthetic values. Emails use the reserved documentation domain example.org so Pydantic EmailStr accepts them. Credentials, sensitive headers, query parameters and matching payload keys, plus custom redaction patterns still use redaction; unsupported PII continues to use existing redaction where detected. The default scrub mode is unchanged.

Use RERUNNER_PSEUDONYM_SEED with a private, high-entropy seed for sensitive work; --seed is useful for synthetic tests but is visible in command history and process arguments. Without a seed the existing public default is used. Pseudonymization is not anonymization, and the strict leak scanner intentionally continues to flag PII-shaped synthetic values. Review the output before sharing. The original request matching keys are retained, as in ordinary scrub, so replay with the original test requests remains possible; this does not re-key requests for a new pseudonymized input corpus. --dry-run does not write output.

Synthetic load generation

rerunner load-gen replays the HTTP interactions of a local, integrity-checked cassette once per concurrent session (1–100). Each session uses an independent replay-only mock proxy bound to loopback, preserving the order of its HTTP requests and isolating its replay cursors. No provider requests or redirects are made, recorded request headers are not forwarded, and tool executions or side effects are not performed. Non-HTTP steps are counted as skipped. Unsupported HTTP methods or base64 responses are rejected before the run. Strict request matching is used: a cassette whose sanitized request no longer matches its recorded key is reported as a replay mismatch.

Use --timeout to set the socket I/O timeout in seconds (default: 10). The report contains request counts, HTTP errors (non-2xx recorded responses), replay mismatches, transport errors, end-to-end throughput (including mock server startup and shutdown), and nearest-rank p50/p95 request latency. The latency includes the complete response read, including streamed content; recorded timing is not simulated. Use --json for CI automation. The command exits nonzero on invalid input or any failed request. This measures the local replay stack, not the live provider or the agent's decision-making performance.

Pre-commit cassette security audit

Install pre-commit, then add the official hook to your project's .pre-commit-config.yaml:

repos:
  - repo: https://github.com/aakash1552005/rerunner
    rev: v0.3.2
    hooks:
      - id: rerunner-doctor

Run pre-commit install to check staged .jsonl, .zst, and .gz cassettes before commits. The hook exits nonzero if any cassette cannot be loaded, fails its SHA-256 integrity chain, or contains patterns matching unredacted API keys or PII. Set RERUNNER_HMAC_KEY when verifying HMAC-signed cassettes; without that key, the check is SHA-256 integrity only and does not provide HMAC-based tamper resistance. The check reports issues but never edits cassettes.


🀝 Contributing & Community

We are building a welcoming, world-class community for agent reliability and deterministic testing:


Condensed cassette audits

Use rerunner doctor session.jsonl session.jsonl.gz --summary-only (or -s) for aggregate CI output instead of per-cassette detail.

The summary reports Total Cassettes, Passed, Failed, and Compromised. Failed includes invalid integrity, detected sensitive data, and missing/unreadable files. Compromised is a subset of Failed: an inspected cassette with invalid integrity or detected secrets/PII; missing/unreadable files are not presumed compromised. Any failure returns exit code 1. With no cassette paths, the original environment diagnostic is displayed, even with -s.

πŸ“œ License

Rerunner is licensed under the Apache 2.0 License.

About

Deterministic flight recorder, $0 CI replay engine, and time-travel debugger for AI agents.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages