Agent VCR
The undo button for AI agents. Undo anything your coding agent did — including rm -rf
from the shell — record and rewind agent runs, replay verified work without model calls, and
gate agent regressions in CI.
pip install ai-agent-vcr
vcr airbag install # hooks for every coding agent on your PATH
vcr undo # the agent deleted something? bring it back
No model key, account, or framework required. Everything stays on your machine.
Why
Coding agents run shell commands. The built-in "rewind" in agent tools only tracks the agent's
own file-edit tool — Claude Code's docs say file changes made by Bash are not tracked, and
Gemini CLI's checkpoints cover only its edit tools. So rm -rf, git reset --hard,
sed -i, a migration against your local SQLite file, or an over-eager "cleanup" can destroy
work that no undo button sees.
Agent VCR's airbag snapshots your project before every tool call — shell commands
included — and vcr undo restores it. Commands a snapshot cannot undo (remote databases,
terraform destroy, force-pushes, npm publish) are stopped so a human can confirm.
The airbag in 30 seconds
$ vcr airbag install claude
✓ 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 5 files — back to snapshot #1.
+ .claude/settings.json
+ .env
+ .gitignore
+ src/billing.py
+ .git/
Changed your mind? `vcr redo`
Your uncommitted edits, your git-ignored .env, and your git history are back. Try it
yourself without an agent: examples/airbag_demo.sh,
or classify any command:
$ 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
Supported agents
| Agent | Install | Commands a snapshot cannot undo |
|---|---|---|
| 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) |
What it protects: tracked and untracked files, small ignored "precious" files (.env*,
SQLite databases — copied consistently even while open), and your .git when a command would
delete or damage it. Snapshots live in a private git store outside the project, so deleting
the project cannot delete them, and your own .git is never touched.
What it cannot undo: anything outside the project, server databases, cloud resources,
pushed commits, sent requests. Those are stopped for confirmation. Details and limits:
docs/airbag.md.
| Command | |
|---|---|
vcr undo [N] · vcr redo |
undo / redo the last agent action that changed files |
vcr rewind · vcr rewind 12 |
timeline of snapshots · restore snapshot #12 |
vcr airbag check "<cmd>" |
classify a command without running it |
vcr airbag allow |
approve a stopped command for one retry |
vcr airbag status · vcr airbag gc |
installed hooks and store · delete old snapshots |
More than an undo button
Record and time-travel agent runs
Every step — state in, state out, tool calls, model calls, cost, latency, errors — is 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 a run from any frame, edit state, and resume; compare frames; open a recording in the
terminal debugger with vcr path/to/run.vcr.
Roll back files and state together in your own agent
ACIDWorkspace gives Python agents transactions over a git repository: savepoints pair a git
commit with the agent's state, rollback restores both, and pre-existing untracked files such as
.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)
Ghost Replay and Agent CI
Save a verified run as a golden run keyed by model, prompt hash, code commit and tool schema; replay it with zero model calls, re-run only changed steps, and see what you saved. Turn golden runs into datasets and fail a pull request on behavioral, cost, token or latency regressions:
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
A reusable GitHub Action is included (action.yml).
Sentinel
An AST quality guard for agent-written Python: syntax errors, complexity and length spikes,
duplicate functions across files. sentinel scan . in CI, or attach it to an OpenHands run.
Framework integrations
from agent_vcr import VCRRecorder
recorder = VCRRecorder()
recorder.start_session("my-run") # ... run your agent ..., then recorder.save()
# 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 (before or after compile)
from agent_vcr.integrations.langgraph import VCRLangGraph
graph = VCRLangGraph(recorder).wrap_graph(builder)
# CrewAI
from agent_vcr.integrations.crewai import VCRCrewAI, VCRCrewCallback
result = VCRCrewAI(recorder).kickoff(crew) # or: with VCRCrewCallback(recorder): crew.kickoff()
# 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)
Any other framework: call record_step, record_llm_call, record_tool_call, record_error
and record_checkpoint from its lifecycle hooks, or forward frames live with
VCRRecorder(on_frame_recorded=...). Guides:
docs/integrations.
Architecture
coding agents ──hooks/plugins──► airbag ──► shadow git store (outside the project)
(Claude Code, Codex, …) │ └─ vcr undo / redo / rewind
▼
frameworks ──callbacks──► recorder ──► .vcr JSONL (execution/v1) ──► player
(LangGraph, CrewAI, …) ▲ │
│ Ghost Replay ◄┘──► Agent CI
ACIDWorkspace (git transactions + escrow)
| Layer | Status |
|---|---|
Recording kernel (recorder, player, execution/v1 schema) |
stable — old recordings always load |
| Airbag, ACID workspace, Sentinel | stable API |
| Ghost Replay, datasets, Agent CI, 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 |
The full package map and design notes are in docs/architecture.md.
Install what you need
pip install ai-agent-vcr # core: recorder, player, airbag, replay, CI
pip install "ai-agent-vcr[tui]" # terminal debugger
pip install "ai-agent-vcr[dashboard]" # local dashboard and server
pip install "ai-agent-vcr[langgraph]" # LangGraph integration
pip install "ai-agent-vcr[crewai]" # CrewAI integration
pip install "ai-agent-vcr[all]" # everything optional
Python 3.9–3.13. The airbag and ACID workspace need git on PATH.
Where it fits
Agent VCR is an intervention tool, not an observability platform. LangSmith, Langfuse, Phoenix and AgentOps observe and evaluate model calls; Agent VCR lets you go back — files, state and history — after an agent changed them. They work well together. It cannot make third-party side effects (emails, payments, cloud APIs) transactional; it stops those for confirmation.
Documentation
- Airbag — per-agent support, commands, limits
- Recording, time travel and Ghost Replay
- ACID workspace rollback
- Agent CI regression gates
- Integrations
- Architecture
- All docs · Live site · Examples · Changelog
Contributing
Issues and pull requests are welcome — new agent integrations especially. See
CONTRIBUTING.md (including
Adding an agent to the airbag), run make verify, and include a test with every change.
Please follow the Code of Conduct
and report vulnerabilities privately per SECURITY.md.
License
Metadata
Release files for ai-agent-vcr 1.6.0
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.6.0.tar.gz | 3.3 MB | Without provenance | Details for ai_agent_vcr-1.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_agent_vcr-1.6.0-py3-none-any.whl | Python 3 | none | any | Details for ai_agent_vcr-1.6.0-py3-none-any.whl |
Total release size: 3.7 MB
Release files / ai_agent_vcr-1.6.0.tar.gz
| Download URL | ai_agent_vcr-1.6.0.tar.gz |
|---|---|
| Size | 3.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97b69a066a2a0d5000b0dcdfac5ee7e2d3f62ce6455f62e02f61a88e20ffb9ac
|
|
BLAKE2b-256 checksum How to use checksums |
bbcca9adf6ed72dc08a93f23bb0da88112d01cafc029be5cf986c7495123955a
|
| 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.6.0-py3-none-any.whl
| Download URL | ai_agent_vcr-1.6.0-py3-none-any.whl |
|---|---|
| Size | 384.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f10c3a2d7de212c8ab71cc822cfaae5967b5b2da6257bbd7ea9e6473ffe081e
|
|
BLAKE2b-256 checksum How to use checksums |
d07b01f3ddaf7a387cc7fb723366b8dabdd8db05458a07a16855f3693a944229
|
| 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.6.0
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.