Skip to main content

The DVR for AI Agents - Record, visualize, and time-travel through agent execution

Project description

๐Ÿ“ผ Agent VCR

CI Benchmarks codecov PyPI version License: MIT

Time-travel debugging for AI agents.

๐Ÿ“– Documentation โ€ข ๐Ÿš€ Examples


๐Ÿ›‘ The Problem

Building multi-step AI agents (like LangGraph or CrewAI) is painfully slow.

When your agent fails on step 8 out of 10, traditional observability tools only tell you what went wrong. To fix it, you have to patch the prompt or code and re-run all 10 steps from the beginning.

Every typo or logic error costs you minutes of waiting and dollars in wasted LLM tokens.

๐Ÿ’ก The Solution

Agent VCR makes debugging instant.

We record your agent's state at every step. When a failure happens, you simply rewind to the failing step, edit the state to fix the bug, and resume execution from that exact point.

LangSmith and LangFuse show you what happened. Agent VCR lets you change it.

  • ๐Ÿ”Œ Plug & Play: 1-line integration with LangGraph and others.
  • ๐Ÿš€ Zero Overhead: <5ms latency penalty per step.
  • ๐Ÿ“ No Vendor Lock-in: Stores runs locally as git-friendly JSONL.
  • ๐Ÿ”„ Async Native: Built from the ground up for modern asyncio agents.

๐Ÿ”ฅ Quick Start

pip install ai-agent-vcr
from agent_vcr import VCRRecorder, VCRPlayer

# 1. Record your agent (One-time setup)
recorder = VCRRecorder()
recorder.start_session("bug_hunt")
# ... your agent code runs here ...
recorder.save()

# 2. Time-Travel & Fix (The magic part)
player = VCRPlayer.load(".vcr/bug_hunt.vcr")

state = player.goto_frame(2)    # Jump back to step 2
state["prompt"] = "Fixed!"      # Fix the bad state
player.resume(from_frame=2)     # Resume execution from step 2

Features

  • ๐Ÿ”ด Real-Time Live Streaming โ€” Watch your agent execute live via WebSocket, pushed instantly from the recorder.
  • โฎ๏ธ Time Travel โ€” Jump back to any step, inspect the full state and history.
  • โœ๏ธ Interactive TUI Debugger โ€” Launch vcr-tui to navigate execution. Press e to edit state directly.
  • ๐Ÿš€ State Injection & Resume โ€” Hit r in the TUI to resume your agent from the exact edited state.
  • ๐ŸŒˆ Visual Diffs โ€” See state mutations color-coded (green/red for additions/removals) for every step.
  • ๐ŸŒณ DAG Visualization โ€” See parallel execution branches and search/filter nodes easily.
  • ๐Ÿ”Œ Framework Agnostic โ€” 1-line plug-and-play with LangGraph, CrewAI, or raw Python.
  • ๐Ÿ“ Git-Friendly Format โ€” JSONL files, version controllable, append-only efficiency.
  • โšก Production Performance โ€” <5ms overhead per frame. Async-native for modern stacks.

Who Is This For?

If you are... Agent VCR helps you...
An AI engineer debugging LangGraph agents Rewind to the exact failing step, fix state, and resume โ€” no re-running the whole chain
A team lead reviewing agent behavior Compare two execution paths side-by-side with full state diffs
A researcher iterating on prompts Fork from any step, change the prompt, and see how downstream behavior changes
Building production agents Record every execution in JSONL for audit trails and regression testing

How Does It Compare?

Feature Agent VCR LangSmith LangFuse Arize Phoenix
Record execution traces โœ… โœ… โœ… โœ…
Time-travel to any step โœ… โŒ โŒ โŒ
Edit state & resume โœ… โŒ โŒ โŒ
Fork from any frame โœ… โŒ โŒ โŒ
Compare execution runs โœ… โœ… โš ๏ธ โš ๏ธ
Self-hosted / local-first โœ… โŒ โœ… โœ…
Git-friendly format (JSONL) โœ… โŒ โŒ โŒ
Framework agnostic โœ… โš ๏ธ LangChain โœ… โœ…
Zero external dependencies โœ… โŒ Cloud โŒ Cloud โœ…
Setup lines 3 ~15 ~10 ~10

Framework Integrations

LangGraph

from langgraph.graph import StateGraph
from agent_vcr import VCRRecorder
from agent_vcr.integrations.langgraph import VCRLangGraph

# Your existing LangGraph code
graph = StateGraph()
graph.add_node("planner", planner_node)
graph.add_node("coder", coder_node)
graph.add_edge("planner", "coder")

# Add VCR recording with one line
recorder = VCRRecorder()
graph = VCRLangGraph(recorder).wrap_graph(graph)

# Run normally โ€” recording happens automatically
result = graph.invoke({"query": "Build a todo app"})

Raw Python

from agent_vcr.integrations.langgraph import vcr_record

recorder = VCRRecorder()

@vcr_record(recorder, node_name="my_function")
def my_function(data):
    return process(data)

# Each call is automatically recorded
result = my_function({"key": "value"})

CrewAI

Agent VCR hooks directly into CrewAI's step_callback and task_callback for 100% accurate, automatically-captured agent thought/action frames.

from crewai import Crew, Agent, Task
from agent_vcr import VCRRecorder
from agent_vcr.integrations.crewai import VCRCrewAI, vcr_task

recorder = VCRRecorder()
recorder.start_session("crew_debug_run")

# Option 1: Wrap the whole crew (auto-records EVERY thought, tool call, and task)
crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task])
vcr_crew = VCRCrewAI(recorder)
result = vcr_crew.kickoff(crew)

recorder.save()

# Option 2: Decorate individual standalone task or tool functions
@vcr_task(recorder, task_name="research_step")
def research(context: dict) -> str:
    return "findings..."

Install with:

pip install "ai-agent-vcr[crewai]"

See examples/crewai_integration.py for a full runnable demo.


Storage Format

Agent VCR uses JSONL (JSON Lines) for storage:

{"type": "session", "data": {"session_id": "abc123", "created_at": "2024-01-01T00:00:00Z", ...}}
{"type": "frame", "data": {"frame_id": "...", "node_name": "planner", "input_state": {...}, "output_state": {...}, ...}}
{"type": "frame", "data": {...}}

Benefits:

  • โœ… Human-readable
  • โœ… Git-diffable
  • โœ… Append-only (efficient for streaming)
  • โœ… Line-by-line parsing (no need to load entire file)

Performance

Performance is continuously benchmarked in CI to ensure <5ms recording overhead.

To run the reproducible benchmarks on your own hardware:

pytest tests/benchmarks/ -v

API Reference

VCRRecorder

class VCRRecorder:
def start_session(
    self,
    session_id: str = None,
    parent_session_id: str = None,
    forked_from_frame: int = None,
    metadata: dict = None,
    tags: list[str] = None,
) -> Session

def record_step(
    self,
    node_name: str,
    input_state: dict,
    output_state: dict,
    metadata: FrameMetadata = None,
    frame_type: FrameType = FrameType.NODE_EXECUTION,
) -> Frame

def record_llm_call(...)
def record_tool_call(...)
def record_error(...)
def save(self) -> Path
def fork(self, from_frame: int, ...) -> VCRRecorder

VCRPlayer

class VCRPlayer:
@classmethod
def load(cls, filepath: str) -> VCRPlayer

def goto_frame(self, index: int) -> dict
def get_frame(self, index: int) -> Frame
def list_nodes(self) -> list[str]
def get_errors(self) -> list[Frame]
def compare_frames(self, a: int, b: int) -> dict
def resume(self, agent_callable: Callable, config: ResumeConfig) -> str
def export_state(self, frame_index: int) -> dict

ResumeConfig

class ResumeConfig:
from_frame: int              # Frame to resume from
new_session_id: str = None   # Optional ID for forked session
state_overrides: dict = {}   # State changes to apply
mode: ResumeMode = FORK      # FORK, REPLAY, or MOCK
skip_nodes: list[str] = []   # Nodes to skip during replay
inject_mocks: dict = {}      # Mock values for dependencies

Examples

See the examples/ directory for:

Run an example:

python examples/time_travel_demo.py

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Development Setup

git clone https://github.com/agent-vcr/agent-vcr.git
cd agent-vcr
pip install -e ".[dev]"

Running Tests

# Unit tests
pytest tests/unit/ -v

# Integration tests
pytest tests/integration/ -v

# E2E tests
pytest tests/e2e/ -v

# Benchmarks
pytest tests/benchmarks/ -v

# With coverage
pytest --cov=agent_vcr --cov-report=html

Roadmap

  • Core recording and playback
  • Time-travel resume
  • FastAPI server with WebSocket
  • LangGraph integration
  • Async recorder and player
  • Terminal TUI debugger (vcr-tui)
  • CI/CD integrations
  • React dashboard
  • CrewAI integration
  • AutoGen integration
  • Cloud storage backend
  • Collaborative debugging

License

MIT License โ€” see LICENSE for details.


Acknowledgments

Inspired by:

  • LangSmith โ€” For the observability paradigm
  • GDB โ€” For the time-travel debugging concept
  • Chrome DevTools โ€” For the UX patterns

Built with โค๏ธ by the Agent VCR community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_agent_vcr-0.3.0.tar.gz (60.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_agent_vcr-0.3.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file ai_agent_vcr-0.3.0.tar.gz.

File metadata

  • Download URL: ai_agent_vcr-0.3.0.tar.gz
  • Upload date:
  • Size: 60.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for ai_agent_vcr-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7b5c47b66a651b9aeab74fbeeb9a3a9722e85e0c79207137f1303f315b105f26
MD5 d3add2e2feedd1a877ae9e801634e648
BLAKE2b-256 f14b6cf835cfec529c245d76e71c6dda6ef32d2bac5b812e7d394305d4e7f1f9

See more details on using hashes here.

File details

Details for the file ai_agent_vcr-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ai_agent_vcr-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for ai_agent_vcr-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa8b818e40e9104819ffcba76af07b0b479464720c70053525e7b59c85b19591
MD5 c22e2bbb6bbc0a8402ac9b5ab3fd7867
BLAKE2b-256 733c4df7a69810c6be722ee6faebc62cb15a7fb0bec0d01d1929cc1883ab950e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page