Turn a captured failure into a local, reviewable replay. RunLedger imports a supported incident JSON document or one selected case from a RunLedger JSONL run, redacts sensitive values, and preserves the order of tool calls and responses.
Use your active Python environment. Incident commands require RunLedger 0.3.0 or later. Existing pipx users can run pipx upgrade runledger instead. Source and example files remain an optional download; pip installs the CLI.
Map your export to the documented incident JSON format. Keep the original file private. The CLI writes a new sanitized bundle and redaction report; it does not upload the trace.
Review the sanitized input, ordered events, supplied effects, and redaction report. Known credentials, identifiers, personal fields, and free-form text are handled by the local policy. Add paths for your schema; automatic redaction cannot guarantee that every sensitive value is removed.
Use the guide's JSONL adapter example or your own trusted local command. The command is supplied by you, never loaded from the incident bundle. Recorded tool responses are consumed in order; changed or extra calls stop replay.
The command above uses POSIX quoting. Follow the guide's Python runner for Windows. Reproduction can succeed while a business rule still fails: the failure was faithfully reproduced. Add --gate when CI must fail on that business-rule failure.
Replay regression.json with your adapter and --gate in CI. Use a fresh output directory for every run. The incident guide documents schema, supported assertions, exit codes, and redaction behavior.
The replay boundary matters
Replay freezes the captured tool responses. It does not reconstruct missing external state or model calls outside your adapter, and the effect ledger is evidence supplied by the export. Redaction can change data-dependent behavior. An unrecorded branch is a divergence, not proof that a fix is safe. Use stateful scenarios below to test changed actions against a modeled world.
NEW
Support-agent scenario pack
Test consequential behavior in a local, stateful simulation: a refund can commit even when the tool returns a timeout. RunLedger checks the committed effects separately from the response the agent receives.
The verification compares the unsafe and fixed policies against fresh copies of the same simulated world. The five cases cover a successful refund, timeout before commitment, timeout after commitment, a declined refund, and missing approval.
Prefer the portable demo without installing a package?
Download the standalone ZIP above, extract it, and run python run_demo.py verify --out results from its folder. It uses only the Python standard library. For the remaining examples, replace runledger scenario with python run_demo.py.
2Reproduce the failure
Expected failure: duplicate refundTerminal
runledger scenario run --scenario timeout-after-commit --agent unsafe --out broken
The unsafe retry uses a new operation key after the response times out. Two $49 refunds commit, and the business-rule checks fail. This command deliberately exits with code 1.
3Check the fix
Reuse the operation keyTerminal
runledger scenario run --scenario timeout-after-commit --agent fixed --out fixed
The fixed policy reuses the same operation key. The simulated tool returns the existing refund instead of committing another. One $49 refund is recorded, the checks pass, and the command exits with code 0.
4Keep the failure as a regression case
The unsafe run writes a synthetic incident bundle with the scenario, effects, trace, and simulator fingerprints. Reproduce it, save the case, and check the fixed policy against it:
Reproduce and promote the recorded incidentTerminal
reproduce exits 0 when the recorded failure matches. That confirms reproduction; it does not mean the unsafe policy passed. Inspect the example incident JSON.
5Connect your own agent
Use your own JSONL adapter with the pip-installed CLI, or download the source and working adapter example. Extract the example files separately and follow the custom-agent instructions in the pack guide. Example scripts are not installed by pip; an editable source install is optional.
Know the boundary
This pack checks deterministic policies against simulated tools and synthetic data. Its success rule checks structured status and a refund receipt, not arbitrary reply text. It does not call a model, issue payments, export customer incidents, or prove a live integration is safe. The same PyPI CLI also provides the record/replay workflow below.
01
Quickstart
Run these commands in a new, empty project directory. The demo uses a local built-in tool and a small Python agent; it does not call a model service.
Before you start
Use Python 3.9 or later, preferably in a virtual environment. RunLedger selects an available Python launcher for its generated agent. The commands below install or upgrade the CLI; scenario and incident features require version 0.3.0 or later.
1Install the CLI
Install or upgrade RunLedgerTerminal
python -m pip install --upgrade runledger
Using pipx? Run pipx install runledger for a new installation, or pipx upgrade runledger for an existing one.
Create a Python virtual environment
Use one of these sequences if you do not have an active environment. Keep it active for the remaining steps; activation makes the python and runledger commands available.
Use the exact folder printed in step 3, for example runledger_out/demo/20261027-120000-abc123. The example is a placeholder, not a folder to create. If the path contains spaces, wrap it in double quotes.
init already creates a starter baseline. Promoting the recorded run makes it the reference for subsequent checks.
5Replay the same case
Replay against the baselineTerminal
runledger run ./evals/demo --mode replay --baseline baselines/demo.json
You should see PASS again. Tool responses now come from the recorded cassette. Open the report.html inside the newly printed artifacts directory in your browser.
Case t1 fails and the process exits with code 1. The passing baseline also detects the drop in pass rate.
Restore the demo: remove "next_steps" from the schema's required list and replay again. The case should pass. Keep the passing baseline; do not promote the failing run as a fix.
03
Add the check to CI
Commit the demo agent, suite, cases, cassettes, and passing baseline to your repository. Save this workflow as .github/workflows/runledger.yml.
A nonzero exit code fails the workflow. To block merging, configure your repository's branch protection or ruleset to require the agent-check check. RunLedger does not change those settings automatically.
For your own agent, add its dependencies to the install step and adjust the suite path. Commit the passing schema first, then open a PR that adds next_steps to reproduce the failing check.
The agent command, cases, tool registry, assertions, and budgets in suite.yaml.
Case
A task input with a cassette and any case-specific assertions.
Cassette
Recorded tool calls and responses. Replay uses these responses without calling the live tool.
Baseline
A known-good summary used to check configured regression thresholds.
For model-graded quality scores, keep your evaluation framework. RunLedger supplies deterministic tool replay and pass/fail contracts. Read the comparison.
05
Assertions and budgets
Start with the conditions that should stop a merge. These fields match the generated demo's output-schema check, tool-call limits, and pass-rate threshold.
Every run writes a separate directory under runledger_out/demo/. Use the exact directory printed by the command, rather than guessing the latest filename.
report.html
Open in a browser for case results, failure details, and the recorded trace.
summary.json
Structured metrics and regression results; also used when promoting a baseline.
junit.xml
Test results for CI systems that support JUnit.
run.jsonl
The event log for inspecting individual tool calls and outputs.
07
Troubleshooting
“Suite file not found”
Run commands from the project directory where you used runledger init. The generated suite is ./evals/demo, not ./evals.
“Target already exists”
Use a new empty directory for this walkthrough. You do not need to initialize the suite again before each run.
Python or RunLedger cannot be found
Activate the virtual environment used for installation, or check that pipx's application directory and the python command are on PATH.
A replay fails after changing tool calls
A cassette describes a specific interaction. Inspect the mismatch, and re-record intentionally changed tool behavior before reviewing and promoting a new baseline.
Next step
Connect your own agent
Learn the agent protocol, suite configuration, and integration options.