DOCUMENTATION / GET STARTED

From first replay to a failing CI check.

Run the included demo, save a passing baseline, and catch an intentional schema regression. Then use the same check in a pull request.

Python 3.9+No model API key neededSee the result first
On this page

NEW

Production incident imports

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.

1Install or upgrade from PyPI

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.

Install the current CLITerminal
python -m pip install --upgrade runledger
runledger incident --help

2Import and redact locally

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.

Incident JSONTerminal
runledger incident import incident.json --out sanitized
Import an existing RunLedger run.jsonl

Select one case and provide its business rules as documented in the guide. Replace CASE with the case ID in your trace.

RunLedger JSONL traceTerminal
runledger incident import run.jsonl --format runledger --case CASE --rules rules.json --out sanitized

3Inspect before sharing

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.

Inspect the imported evidenceTerminal
runledger incident inspect sanitized/incident.json --out inspection

4Replay your explicit adapter

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.

POSIX shell exampleTerminal
runledger incident replay sanitized/incident.json --agent-command '["python", "agent.py"]' --out replayed

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.

5Preserve the regression

Promote the incidentTerminal
runledger incident promote sanitized/incident.json --to regression.json

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.

1Install and verify

Use RunLedger 0.3.0 or later in a Python 3.9+ environment. The built-in scenarios need no account, model API key, or payment credentials.

Install and run all five scenariosTerminal
python -m pip install --upgrade runledger
runledger scenario verify --out results

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
runledger scenario reproduce broken/incident.json --out reproduced
runledger scenario promote broken/incident.json --to cases/refund-timeout.json
runledger scenario run --case cases/refund-timeout.json --agent fixed --out regression

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.

Windows PowerShellTerminal
mkdir runledger-quickstart
cd runledger-quickstart
py -3 -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install --upgrade runledger

If PowerShell blocks activation, open Command Prompt and run .venv\Scripts\activate.bat from the same directory, then install and continue there.

macOS / LinuxTerminal
mkdir runledger-quickstart
cd runledger-quickstart
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade runledger

2Create a working demo

Create the demo suiteTerminal
runledger init

This creates evals/demo/suite.yaml, an agent under evals/demo/agent/, a case, a cassette, and baselines/demo.json. Use ./evals/demo as the suite path.

3Record a passing run

Record tool responsesTerminal
runledger run ./evals/demo --mode record

The CLI should show PASS and print Artifacts written to: followed by a run directory. Keep that path for the next step.

Expected resultCase t1: PASS · process exit code 0

4Save that run as your baseline

Promote the passing runTerminal
runledger baseline promote --from RUN_DIR --to baselines/demo.json
Replace RUN_DIR before running

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.

Explore a real report without installing
02

Catch a regression

Make a small contract change while leaving the agent unchanged. Replace the contents of evals/demo/schema.json with this schema:

evals/demo/schema.jsonJSON
{
  "type": "object",
  "properties": {
    "category": { "type": "string" },
    "reply": { "type": "string" }
  },
  "required": ["category", "reply", "next_steps"]
}

Run the replay command from step 5 again. The agent still returns category and reply, so the new required field is missing.

Expected failureMissing required field: next_steps

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.

.github/workflows/runledger.ymlYAML
name: RunLedger
on:
  pull_request:
  workflow_dispatch:

jobs:
  agent-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - run: python -m pip install runledger
      - name: Replay and check the baseline
        run: runledger run ./evals/demo --mode replay --baseline baselines/demo.json
      - name: Save reports
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: runledger-report
          path: runledger_out/**
Make the check required

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.

04

Core concepts

Suite
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.

Suite assertions and budgetsYAML
assertions:
  - type: json_schema
    schema_path: schema.json

budgets:
  max_wall_ms: 20000
  max_tool_calls: 1
  max_tool_errors: 0

regression:
  min_pass_rate: 1.0

Other assertions include required fields and tool contracts: required tools, forbidden tools, and call order. See the reference for supported fields and enforcement details.

06

Read the artifacts

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.

Explore integrations