Browse documentation

Technical documentation / Reference

Session replay reuse

Prompt projection and agent execution share one bounded replay cache per AgentSession. The cache stores normalized replay output, diagnostics, a content fingerprint, the session path and file identity, and the in-process durable-write generation.

On Unix filesystems with stable high-resolution change metadata, an unchanged session reuses replay without rereading or reparsing JSONL. Durable appends and physical rotation advance the shared session generation. File identity, change metadata, and content fingerprints invalidate the cache after external append, truncation, replacement, partial-record completion, and same-size rewrites. Coarse-timestamp and non-Unix filesystems conservatively read a fingerprint before reuse to avoid stale replay without repeating JSON parsing or replay construction. A full replay read is accepted only when file identity and generation are stable before and after the read.

The cache is bounded to one replay per agent instance. Durable JSONL remains the source of truth. Replay diagnostics, event ordering, compaction cutoff behavior, bounded-history failures, and cancelled or failed partial assistant replay are unchanged.

Benchmark

Command:

cargo test --release --quiet --lib replay_snapshot_benchmark_growing_sessions -- --ignored --nocapture

Environment: macOS 27.0, Apple M5 Pro, Rust 1.98.0, baseline commit 61171e0ce. Fixture seed sequential-0.70; 1 warmup and 9 measured samples; 40 growing prompts per sample. The success threshold was chosen before implementation: optimized median wall time must be at least 25% lower than the forced-full-replay baseline.

MeasurementForced full replayShared replay
Median wall time39 ms18 ms
p95 wall time39 ms18 ms
Session scans8040
Bytes read8,046,0604,023,030
Lines/events parsed4,9202,460
Replay builds8040
Cache hits040

The baseline is a comparison harness, not a measured product regression.

Edit this page on GitHub ↗