🎬 Session Recording

Time-travel debugger with full state resume

3-Layer Capture Full State Resume Conversation Restore
🎬

Capture. Replay. Resume.

Record complete DevDuck sessions with full conversation state. Resume from any snapshot with your entire context restoredβ€”like hitting pause and play on your AI agent.

πŸ”¬ Three-Layer Capture Architecture

Session recording captures events at three distinct layers, giving you complete observability into agent behavior.

πŸ’Ύ sys OS-level events: file I/O operations, network requests, environment access file.open, http.get
πŸ”§ tool Tool invocations: shell commands, file edits, API calls with timing tool.call, tool.result
πŸ€– agent Agent behavior: messages, state snapshots, session lifecycle message, snapshot.created

⚑ Quick Start

Command Line

# Start with recording enabled
devduck --record

# Record a one-shot query
devduck --record "create a web scraper"

# Resume from a recorded session
devduck --resume ~/Desktop/session-20260202-231359.zip

# Resume from specific snapshot
devduck --resume session.zip --snapshot 2

# Resume and continue with new query
devduck --resume session.zip --snapshot 2 "continue from here"

Interactive REPL

# In DevDuck REPL:
record              # Start recording
# ... do your work ...
record              # Stop and export ZIP

Tool API

# Start recording
session_recorder(action="start")

# Create state snapshot with description
session_recorder(action="snapshot", description="after API setup")

# Check recording status
session_recorder(action="status")

# Export without stopping
session_recorder(action="export", output_path="~/Desktop/checkpoint.zip")

# Stop recording and export
session_recorder(action="stop")

πŸ’Ύ Full State Resume

The killer feature: snapshots capture your complete conversation state, allowing you to resume exactly where you left off.

πŸš€ Resume Capabilities

Unlike simple event logs, DevDuck snapshots store the actual agent.messages array, system prompt, and query contextβ€”enabling true session continuation.

resume_from_snapshot(id, agent)
Restore agent state from snapshot. Messages are injected back into agent context.
resume_and_continue(id, query, agent)
Resume from snapshot AND immediately run a new query with full context.
replay_events(callback)
Step through recorded events with optional callback for each event.

Python Resume API

from devduck import load_session, resume_session, list_sessions

# List all recorded sessions
sessions = list_sessions()
for s in sessions:
    print(f"{s['name']} - {s['size_kb']:.1f}KB - {s['modified']}")

# Quick resume from latest snapshot
result = resume_session("~/Desktop/session.zip")
print(f"Restored {result['messages_restored']} messages")

# Load session for inspection
session = load_session("session.zip")
print(session)  # LoadedSession(id=..., events=14, snapshots=3)

# Explore session data
print(session.metadata)
print(f"Duration: {session.duration}s")
print(f"Resumable: {session.has_pkl}")

# Get events by layer
sys_events = session.get_events_by_layer("sys")
tool_events = session.get_events_by_layer("tool")
agent_events = session.get_events_by_layer("agent")

# Resume from specific snapshot with agent
result = session.resume_from_snapshot(2, agent=devduck.agent)
print(f"Messages restored: {result['messages_restored']}")
print(f"Working directory: {result['cwd']}")

# Resume AND continue with new query
result = session.resume_and_continue(
    snapshot_id=2,
    new_query="continue from where we left off",
    agent=devduck.agent
)
print(result['agent_result'])

πŸ“Έ What Snapshots Capture

Each snapshot is a complete checkpoint of agent state at that moment in time.

agent_messages
Full conversation history for context restoration
system_prompt
The exact system prompt at snapshot time
last_query
Most recent user query for context
last_result
Agent's last response (truncated)
model_info
Model type, ID, and provider details
tools_loaded
List of active tools at snapshot
cwd
Working directory (auto-restored on resume)
env_vars_redacted
Environment with sensitive values masked

πŸ“‹ Recording Actions

Action Description Parameters
start Begin a new recording session session_id (optional)
stop Stop recording and export to ZIP output_path (optional)
snapshot Create state checkpoint with full context description (optional)
status Show recording status and stats β€”
export Export current session without stopping output_path (optional)
list List all saved recordings β€”

πŸ“¦ Export Format

Sessions are exported as ZIP archives containing structured data for analysis, replay, and resume.

πŸ“ session-20260202-231359.zip
πŸ“„ events.jsonl # All events in JSON Lines format
πŸ“„ snapshots.json # State checkpoints with messages
πŸ“„ metadata.json # Session info, timing, platform
πŸ“„ session.pkl # Serialized state (dill/pickle)

Event Structure

{
  "timestamp_ns": 1738539876420000000,
  "layer": "tool",
  "event_type": "tool.call",
  "data": {
    "name": "shell",
    "args": {"command": "ls -la"}
  },
  "trace_id": null
}

Snapshot Structure

{
  "timestamp": 1738539876.42,
  "snapshot_id": 2,
  "agent_messages_count": 12,
  "agent_messages": [
    {"role": "user", "content": "..."},
    {"role": "assistant", "content": "..."}
  ],
  "system_prompt": "πŸ¦† You are DevDuck...",
  "last_query": "read the file and update it",
  "last_result": "Done! I've updated...",
  "model_info": {
    "type": "BedrockModel",
    "model_id": "claude-opus-4-5",
    "provider": "bedrock"
  },
  "tools_loaded": ["shell", "editor", "file_read"],
  "cwd": "/Users/cagatay/project"
}

✨ Features

πŸ’¬

Conversation Restore

Full agent.messages captured in snapshots. Resume with complete context.

⚑

Ring Buffer Design

10K event capacity with O(1) writes. Minimal performance overhead.

πŸ”’

Auto Redaction

API keys, tokens, and secrets automatically masked in exports.

πŸ”Œ

Automatic Hooks

File I/O and network calls instrumented when recording is active.

πŸ“

CWD Restoration

Working directory automatically restored on snapshot resume.

🎯

Context Injection

Recent events automatically added to agent context during recording.

πŸ”„ Example Workflow

Start Recording

devduck --record or type record in REPL

Work Normally

All tool calls, messages, and file operations captured automatically

Snapshots Auto-Created

Before/after each agent query with full conversation state

Stop & Export

Type record again or use session_recorder(action="stop")

Analyze in Player

Open Session Player and drop the ZIP file

Resume Anytime

devduck --resume session.zip --snapshot 2

πŸ“‚ Storage Location

# Default recording directory
/tmp/devduck/recordings/
β”œβ”€β”€ session-20260202-224751.zip
β”œβ”€β”€ session-20260202-231359.zip
└── ...

# List recordings via tool
session_recorder(action="list")

# Export to custom location
session_recorder(action="stop", output_path="~/Desktop/my-session.zip")

# Python API
from devduck import list_sessions
for s in list_sessions():
    print(f"{s['name']} - {s['modified']}")

πŸ’‘ Use Cases

πŸ›

Debugging

Step through exactly what the agent did when something went wrong.

⏸️

Pause & Resume

Stop working mid-task and resume later with full context restored.

πŸ“Š

Analysis

Study tool usage patterns, timing, and optimize workflows.

πŸ”€

Branching

Resume from an earlier snapshot to try a different approach.

πŸ“š

Documentation

Create reproducible examples of complex agent interactions.

πŸ§ͺ

Testing

Capture sessions for regression testing and comparison.