Documentation ยท v1.7.0 ยท Python 3.9โ€“3.13

The undo button for AI agents.

Arm the airbag for your coding agent, record and rewind your own agents, replay verified runs without model calls, and gate the next change in CI.

Quick start

The base install is local-first and needs no model key, hosted account, or framework.

terminal
pip install ai-agent-vcr

vcr airbag install
python examples/basic_usage.py
vcr tui .vcr/<session-id>.vcr

Five-minute quickstart โ†’ ยท All docs โ†’

Package name: install ai-agent-vcr. The similarly named agent-vcr package on PyPI is a different project.

Undo anything your coding agent did

Agents' built-in rewind only tracks their own edit tools. The airbag snapshots your project into a private store outside it before every tool call, so rm -rf, git reset --hard or a bad migration on a local SQLite file can be undone. Commands a snapshot cannot undo โ€” server databases, cloud deletions, force-pushes โ€” are stopped for a human.

terminal
pip install ai-agent-vcr
vcr airbag install          # hooks for every agent on your PATH

# ...the agent runs `rm -rf .`...
vcr undo                    # files, .env and .git are back
vcr redo                    # changed your mind
vcr airbag check "psql -h prod -c 'DROP TABLE users'"   # โš  irreversible

Airbag guide: every agent, every command, every limit โ†’

Record a state transition

The recorder is the framework-neutral boundary. A session contains ordered JSONL frames for nodes, model calls, tools, errors, and checkpoints.

agent.py
from agent_vcr import VCRPlayer, VCRRecorder

recorder = VCRRecorder(output_dir=".vcr")
recorder.start_session("support-triage")
recorder.record_step(
    "classify",
    {"status": "new"},
    {"status": "classified", "priority": "high"},
)
recording = recorder.save()

player = VCRPlayer.load(recording, strict=True)
print(player.goto_frame(0))
print(player.verify_integrity())

Full recording, resume, bundle, and privacy guide โ†’

Rollback state and files together

ACIDWorkspace combines isolated Git savepoints with private, per-savepoint local-file escrow.

Tracked contentRestored from the selected Git savepoint commit.
Local contentEligible untracked/ignored files restored byte-for-byte with modes and symlink targets.
Secret boundaryEscrow bytes stay under .git/vcr-escrow, outside Git objects and VCR recordings.
Issue #2 guarantee: a modified or deleted pre-existing .env is restored at rollback, while later hallucinated local files are removed. Oversized, excluded, and special files are preserved but cannot be reconstructed.
  • Blobs are immutable and content-addressed as blobs/<sha256>.
  • Escrow directories use 0700; regular blobs use 0600.
  • Paths containing .., absolute paths, and resolved-parent symlink escapes are rejected.
  • Rollback can run repeatedly before commit; shared blob references stay valid.

Full transaction lifecycle, limits, and threat boundary โ†’

Ghost Replay without silent drift

A golden run is selected by the normalized task plus an optional identity covering model, prompt, code, tools, dependencies, environment, and caller-defined fields.

replay.py
from agent_vcr.golden_cache import GoldenRunCache

cache = GoldenRunCache()
identity = cache.build_identity(
    model="provider/model@revision",
    prompt_hash="sha256:prompt",
    code_commit="0123456789abcdef",
    tool_schema_hash="sha256:tools",
)
cache.save_golden_run("triage ticket", recorder, identity=identity)
outputs, ledger = cache.replay("triage ticket", identity=identity)

Nested identity JSON uses canonical sorted-key serialization. Key-order changes do not cause false misses; actual identity changes do.

Gate changes with recorded evidence

Generate candidates with the code under review, then compare them with versioned baseline cases. The gate itself makes no model calls.

terminal
vcr dataset create refunds
vcr dataset add refunds \
  --task "refund a duplicate payment" \
  --case-name duplicate-payment \
  --vcr .vcr/reviewed/refund.vcr

vcr ci run \
  --dataset refunds \
  --candidates .vcr/candidates \
  --fail-on degraded \
  --report agent-ci-report.json \
  --markdown agent-ci-report.md

Full dataset, candidate, and GitHub Action guide โ†’

Connect your agent runtime

Native adaptersLangGraph nodes, CrewAI callbacks, OpenHands Sentinel, and ACIDWorkspace.
Claude CodeInstall lifecycle hooks with vcr init --claude-code.
Custom runtimesMap lifecycle events to record_step, record_llm_call, record_tool_call, and record_error.

Full framework integration guide โ†’

Production building blocks

  • Workflow engine โ€” durable runs, resume, schedules, approvals, retries, and saga compensation.
  • SuperAgent โ€” validated plans, policy, budgets, tool schemas, and output verification.
  • Dashboard and self-hosted store โ€” terminal debugger, local web UI, scoped project tokens.
  • FAQ โ€” what it is, what it isn't, and how it compares.
  • Sentinel โ€” local AST quality analysis and optional OpenHands feedback.
  • Railway foundation โ€” optional auth/billing control plane with an explicit multitenancy boundary.
  • Benchmark dashboard โ€” measured history and local regression ceilings.
External effects are outside Git. Agent VCR cannot undo email, payments, database writes, or arbitrary APIs. Use approvals before consequential tools and explicit compensation where reversal is possible.