Agent VCR
Ctrl+Z for AI agents.
Your coding agent just ran rm -rf. Or git reset --hard. Or DROP TABLE users on your dev
database. vcr undo brings it all back: files, .env, git history, even the rows.
pipx install ai-agent-vcr # or: uv tool install ai-agent-vcr
vcr airbag install # arms every coding agent on your PATH, in every project
vcr undo # oops? un-oops.
No API key. No account. No cloud. Everything stays on your machine. Works with Claude Code, Codex, Gemini CLI, Cursor, Copilot CLI, OpenHands, OpenCode, Cline and Devin, on Linux, macOS and Windows.
The problem
Coding agents don't just edit files: they run shell commands. And the "rewind" buttons built into agent tools only track the agent's own edit tool. Claude Code's docs say changes made through Bash aren't tracked; Gemini CLI's checkpoints cover only its edit tools.
So the scary stuff (rm -rf, sed -i, git clean -fdx, a migration against your local DB, an
over-eager "let me clean that up") is exactly what nothing can undo.
Agent VCR fixes that with an airbag: a snapshot of your project before every tool call,
shell commands included. vcr undo restores it. Commands no snapshot can undo
(force-pushes, terraform destroy, npm publish, a DROP on a remote database) are stopped
until a human says yes.
60-second tour
$ vcr airbag install claude
🛟 Airbag armed for 1 agent, user level: every project, nothing written into your repository.
✓ Claude Code ~/.claude/settings.json
# ... the agent decides to "clean up" and runs `rm -rf ~/code/myapp` ...
🛟 Agent VCR airbag: snapshot #1 saved before `rm -rf ~/code/myapp`. Undo with `vcr undo`.
$ vcr undo --project-dir ~/code/myapp
↩ Undid: rm -rf ~/code/myapp (claude, 12s ago)
restored 4 files — back to snapshot #1.
+ .env
+ .gitignore
+ src/billing.py
+ .git/
Changed your mind? `vcr redo`
Uncommitted edits, the git-ignored .env, and the whole git history: back. Want to see it
without an agent? Run
examples/airbag_demo.sh.
Want to know what the airbag thinks of a command before anyone runs it?
$ vcr airbag check "psql -h prod-db.internal -c 'DROP TABLE invoices'"
⚠ IRREVERSIBLE: cannot be undone by a snapshot — the airbag asks a human first
• SQL DROP on a remote database (prod-db.internal) — server data is not in your project files
What's in the box
| You type | What happens | |
|---|---|---|
| 🛟 Undo anything | vcr undo · vcr redo · vcr rewind 12 |
Files, .env, SQLite, git history, back to before any agent action |
| 🎯 Find what broke it | vcr bisect -- pytest -q |
Binary-searches the agent's actions and names the one that broke your tests. Zero tokens |
| 🐘 Rewind your local DB | AGENT_VCR_AIRBAG_DATABASES=... |
pg_dump before a destructive SQL command; vcr undo restores the rows too |
| 🔌 Give the agent a seatbelt | claude mcp add agent-vcr -- vcr mcp |
The agent checks risky commands and reads its own undo history over MCP |
| 📼 Record & time-travel | VCRRecorder / vcr run.vcr |
Every step of your own agent as a frame: inspect, fork, resume, diff |
| 👻 Replay for free | Ghost Replay | Re-run a verified run with zero model calls |
| 🧪 Test agents like code | @pytest.mark.agent_vcr |
Record once, replay forever, fail the test on behavior/cost/token regressions |
| 🚦 Gate PRs | vcr ci run + GitHub Action |
Block a pull request that makes your agent worse or pricier |
Supported agents
| Agent | Arm it | When a command can't be undone |
|---|---|---|
| Claude Code | vcr airbag install claude |
asks you |
| OpenAI Codex CLI | vcr airbag install codex |
blocked until vcr airbag allow |
| Gemini CLI | vcr airbag install gemini |
asks you (≥ 0.36) |
| Cursor (IDE + CLI) | vcr airbag install cursor |
blocked until vcr airbag allow |
| GitHub Copilot CLI | vcr airbag install copilot |
asks you |
| OpenHands | vcr airbag install openhands or the Python integration |
blocked, or asks with confirm=True |
| OpenCode 1.x | vcr airbag install opencode |
blocked until vcr airbag allow |
| Cline | vcr airbag install cline |
task stopped |
| Devin Local (ex-Windsurf) | vcr airbag install devin |
blocked until vcr airbag allow |
| Anything else | vcr airbag run -- aider |
snapshots every 2 s (no interception) |
The airbag never grants a permission your agent wouldn't have asked for. It only adds snapshots, and stops the things a snapshot can't fix.
How it works
agent wants to run a tool
│
▼
PreToolUse hook ─► classify: read · write · destructive · irreversible
│ │ │
│ snapshot the project ask a human / block
▼ (shadow git store, (force-push, prod DB,
tool runs outside your project) cloud deletes, publish)
│
vcr undo / redo / rewind / bisect
- Snapshots live outside your project (
~/.local/state/agent-vcr/airbag/…), in a private git store. Deleting the project can't delete them. Your own.gitis never written, except to put back one that was deleted or broken. - What gets captured: tracked and untracked files, small ignored "precious" files (
.env*, SQLite, copied consistently even while open), and your.gitbefore a command that would wreck it. Dependency trees (node_modules,.venv) are skipped; reinstall those. - Snapshots are cheap: content-addressed, and an unchanged tree reuses the last one.
- Every restore is undoable: the current state is snapshotted first, so
vcr redoworks.
Find the action that broke it: vcr bisect
Tests were green before the agent started. Forty tool calls later they're red and nothing is
committed. Which call did it? git bisect can't help: there are no commits. The airbag has
a snapshot before every call, so:
$ vcr bisect -- pytest -q
#4 (current) ✗ fail (0.4s)
#1 ✓ pass (0.3s)
#2 ✓ pass (0.3s)
#3 ✗ fail (0.3s)
🎯 First bad action: sed -i 's/round(sum(prices), 2)/int(sum(prices))/' billing.py
claude · Bash · snapshot #2 passes → #3 fails (4 test runs)
~ billing.py
Go back to just before it: vcr rewind 2
Each test run happens in a temporary checkout: your project is never touched. 100 actions take about 9 runs. Zero model tokens.
Rewind your local Postgres too
A file snapshot can't undo DROP TABLE: the data lives in the database server. For local dev
databases you name explicitly, the airbag runs pg_dump right before the destructive SQL:
export AGENT_VCR_AIRBAG_DATABASES=postgresql://localhost:5433/app_dev
vcr undo # files AND rows back
Only localhost, 127.0.0.1, ::1 and unix sockets are accepted; remote databases are never
dumped and still need a human. If the airbag can't be certain where a command connects
(ORM resets, -f script.sql, PGSERVICE, a \connect inside the SQL), it takes the dump
and still asks.
Give the agent its own seatbelt: vcr mcp
claude mcp add agent-vcr -- vcr mcp # Codex: codex mcp add agent-vcr -- vcr mcp
Now the agent can call airbag_check before a risky command, read its timeline, take a
snapshot, and preview an undo. Actually restoring files over MCP takes dry_run: false
and confirm: true, and only works on the project the server was started in.
→ docs/mcp.md
Building your own agent? Record it.
Every step (state in, state out, tool calls, model calls, cost, latency, errors) becomes a frame in an append-only JSONL file you can open, diff, bundle and replay.
from agent_vcr import VCRPlayer, VCRRecorder
recorder = VCRRecorder(output_dir=".vcr")
recorder.start_session("billing-fix")
recorder.record_step("planner", {"task": "add invoice status"}, {"plan": "migration first"})
recorder.record_checkpoint({"plan": "migration first"}, label="plan-approved")
path = recorder.save()
player = VCRPlayer.load(path)
player.goto_checkpoint("plan-approved") # jump to any frame or checkpoint
player.verify_integrity() # durability checks
Fork from any frame, edit state, resume. Open a recording in the terminal debugger with
vcr path/to/run.vcr. Long runs? VCRRecorder(max_cached_frames=1000) keeps memory flat.
Test agents like code (pytest plugin)
Records the first time, then replays with zero model calls, failing the test when behavior, cost or tokens regress:
@pytest.mark.agent_vcr(task="triage ticket t_123", identity={"model": "gpt-5"})
def test_triage(agent_vcr):
run = agent_vcr.run(triage) # 1st run: calls the agent; after: replays it
assert run.output["queue"] == "billing"
agent_vcr.assert_matches_golden(max_cost_usd=0.05)
AGENT_VCR_RECORD=none pytest in CI fails instead of spending tokens.
→ docs/pytest-plugin.md
Gate pull requests (Agent CI)
Turn verified runs into a dataset; fail the PR on behavioral, cost, token or latency regressions. Comes with a GitHub Action (action.yml).
vcr dataset create refunds
vcr dataset add refunds --task "refund a duplicate payment" --vcr .vcr/golden/refund.vcr
vcr ci run --dataset refunds --candidates .vcr/candidates --fail-on degraded
Transactions for your agent's workspace
ACIDWorkspace pairs each git savepoint with the agent's state. Rollback restores both, and
untracked files like .env are escrowed byte-for-byte outside git history.
from agent_vcr.integrations.openhands import ACIDWorkspace
with ACIDWorkspace("/path/to/repo") as ws: # begin() on enter
ws.savepoint({"phase": "planned"}, node_name="planner")
... # the agent works on an isolated branch
ws.rollback(to_frame_index=0) # rewind files + state to a savepoint
# clean exit → commit (merge); exception → abort (everything restored)
Sentinel
An AST guard for agent-written Python: syntax errors, complexity and length spikes, duplicate
functions. sentinel scan . in CI, or plug it into an OpenHands conversation: it stops the agent's next
move when an edit introduces a blocker (pre-existing mess is only a warning).
Framework integrations
# LangGraph: no graph changes, pass the callback per run …
from agent_vcr.integrations.langgraph import LangGraphCallback
app.invoke(inputs, config={"callbacks": [LangGraphCallback(recorder)]})
# … or wrap every node of a StateGraph
from agent_vcr.integrations.langgraph import VCRLangGraph
graph = VCRLangGraph(recorder).wrap_graph(builder)
# CrewAI
from agent_vcr.integrations.crewai import VCRCrewAI
result = VCRCrewAI(recorder).kickoff(crew)
# OpenHands SDK: snapshot before every action, block irreversible ones
from agent_vcr.integrations.openhands_airbag import AirbagCallback, protect
airbag = AirbagCallback()
conversation = Conversation(agent=agent, workspace=ws, callbacks=[airbag])
protect(conversation, airbag)
Anything else: call record_step, record_llm_call, record_tool_call, record_error and
record_checkpoint from your framework's hooks.
→ docs/integrations
What it can't do (honest section)
- Undo the outside world. Sent emails, payments, cloud resources, pushed commits, remote databases. Those get stopped for a human instead.
- Snapshot your dependency folders.
node_modules,.venvand build output are skipped on purpose; reinstall them. - Read every mind. The classifier reads POSIX shell. A command it doesn't recognise still gets a snapshot first, but an obfuscated or PowerShell-only danger may not be flagged as irreversible.
- Replace observability. LangSmith, Langfuse, Phoenix and AgentOps watch model calls; Agent VCR lets you go back. Use both.
Install
The vcr command (airbag, undo, bisect, MCP): install it once as a tool, so it works in
every project and stays out of your project's dependencies.
pipx install ai-agent-vcr # or: uv tool install ai-agent-vcr
pipx upgrade ai-agent-vcr # later: get the newest fixes
Plain pip install into the system Python is blocked on most current Linux distros and on
Homebrew Python ("externally-managed-environment"); pipx and uv are the clean way around it.
The Python library (recorder, replay, pytest plugin, integrations): add it to your project's virtual environment like any other dependency.
pip install ai-agent-vcr # core: recorder, replay, CI, pytest plugin
pip install "ai-agent-vcr[tui]" # terminal debugger
pip install "ai-agent-vcr[dashboard]" # local web dashboard and server
pip install "ai-agent-vcr[langgraph]" # LangGraph
pip install "ai-agent-vcr[crewai]" # CrewAI
pip install "ai-agent-vcr[openhands]" # OpenHands SDK 1.x (Python 3.12+)
pip install "ai-agent-vcr[all]" # everything
Python 3.9–3.13 on Linux, macOS and Windows, every one tested in CI on every change. The
airbag needs git on your PATH.
Stability
| Layer | Status |
|---|---|
| Airbag, bisect, MCP server, ACID workspace, Sentinel | stable API |
Recording kernel (recorder, player, execution/v1 schema) |
stable: old recordings always load |
| Ghost Replay, datasets, Agent CI, pytest plugin, bundles | stable |
| LangGraph / CrewAI / OpenHands / Claude Code integrations | stable, tested against the real libraries |
Dashboard and self-hosted store (vcr-server) |
supported |
| SuperAgent, workflows, sandbox, intelligence | experimental: APIs may change |
Package map and design notes: docs/architecture.md.
Docs
- Website · Documentation · 5-minute quickstart
- Airbag: every agent, every command, every limit
- MCP server · pytest plugin · Agent CI
- Recording, time travel and Ghost Replay · ACID workspace · Integrations
- FAQ · All docs · Examples · Changelog
Contributing
PRs welcome, new agent integrations especially. Read
CONTRIBUTING.md (it covers
Adding an agent to the airbag), run make verify, and ship a test with every change.
Be kind: Code of Conduct.
Found a security issue? Report it privately per
SECURITY.md.
License
Metadata
Release files for ai-agent-vcr 1.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ai_agent_vcr-1.7.1.tar.gz | 3.5 MB | Without provenance | Details for ai_agent_vcr-1.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_agent_vcr-1.7.1-py3-none-any.whl | Python 3 | none | any | Details for ai_agent_vcr-1.7.1-py3-none-any.whl |
Total release size: 4.0 MB
Release files / ai_agent_vcr-1.7.1.tar.gz
| Download URL | ai_agent_vcr-1.7.1.tar.gz |
|---|---|
| Size | 3.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
230db489fac2a2902216afbc1831babdebd4def85d668fbd1a88e34a7f95d6c1
|
|
BLAKE2b-256 checksum How to use checksums |
5b587b3dc7727c07dab6d0de2736679976226d387da654f6977d8b5a9b025c0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / ai_agent_vcr-1.7.1-py3-none-any.whl
| Download URL | ai_agent_vcr-1.7.1-py3-none-any.whl |
|---|---|
| Size | 484.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
573f59ef54d2f0e0eaa4f338e2ac66f611575e9c1bbe44b23577e9f4b94fb04a
|
|
BLAKE2b-256 checksum How to use checksums |
7416e5a5f147e760c59077a0ee0e9ac2f2aa5d3b54a128e6e1aa89d03c728430
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for ai-agent-vcr 1.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.