# Total Recall: The Context Window as a Cache Over the Session Record: v7.5 → v7.6

From v7.5 (2 Jun) to v7.6 (14 Jun): 6,702 words to 8,208 words, 1,533 words in new or rewritten paragraphs and 27 taken out, 26 paragraphs changed.

## Change note of v7.6

**Adds reversible compression as prior art and eviction of skill catalogs**

About 1,500 new words. All three additions come from the paper's improvement notes of 13 June.

- New prior-art section on reversible compress-cache-retrieve systems, which the notes call the strongest convergent work.
- New section on metacognitive checks, naming a confidence gate before an answer is trusted.
- New result: pointer eviction also works on static content such as a skill catalog, with a measured token reduction.
- The token-cost comparison now includes in-place compression.

## Changed paragraphs

Marks: [-removed-] {+added+}.

### 2.4 Convergent Prior Art: Reversible Compress-Cache-Retrieve

{+### 2.4 Convergent Prior Art: Reversible Compress-Cache-Retrieve+}

### 2.4 Convergent Prior Art: Reversible Compress-Cache-Retrieve

{+The closest convergent system to Total Recall is **headroom** (Chopra, 24.7k stars, Apache-2.0), which arrives at this paper's core thesis from the opposite direction. headroom's **reversible CCR** (Compress-Cache-Retrieve) caches originals and has the LLM retrieve them on demand — structurally the same insight as treating the context window as a cache over a lossless store whose evicted content is recoverable via `recall(query)`. The two systems differ in *granularity* and *reversibility model*, and the difference is the substance of the comparison, not a footnote:+}

### 2.4 Convergent Prior Art: Reversible Compress-Cache-Retrieve

{+- **headroom compresses content in place.** It runs per-content-type, lossy-but-recoverable compressors — statistical JSON-array crushing (SmartCrusher), AST-aware code compression via tree-sitter, and dedicated log/diff/text handlers — and recovers the original through a cache lookup. A degraded-but-usable representation stays *addressable in context*. The cost is a recurring (smaller) re-read tax plus exposure to lossy-compressor error; the benefit is that the content never leaves the window. - **Total Recall evicts whole time-range spans behind a fixed-size pointer marker.** It removes the span from context entirely, leaves only a retrieval directive, and recovers via task-conditioned retrieval over a durable event store. The cost is an occasional pull; the benefit is byte-exact recovery and a per-turn footprint that does not grow with the evicted content.+}

### 2.4 Convergent Prior Art: Reversible Compress-Cache-Retrieve

{+Neither is strictly superior: headroom keeps a lossy proxy resident and addressable, Total Recall removes the span and guarantees exact recovery on demand. The two are also *composable* rather than mutually exclusive — a deployment could compress a span with headroom-style content-aware compressors before evicting it behind a Total Recall marker, paying headroom's compression cost only on spans likely to be re-touched and Total Recall's eviction discipline on the rest. headroom additionally ships a trained compression model (Kompress-v2-base) and proxy / MCP / library form factors; these are orthogonal to the storage invariants studied here but reinforce that in-place compression and pointer-eviction occupy adjacent, combinable points in the design space. We extend the steady-state cost comparison to include headroom's in-place model in §7.3, and adopt headroom's public-benchmark methodology as a shared evaluation yardstick in §11.+}

### 2.5 Metacognitive Verification Disciplines

{+### 2.5 Metacognitive Verification Disciplines+}

### 2.5 Metacognitive Verification Disciplines

{+A second class of recent work is relevant not to storage but to the *retrieval-trigger* problem this paper identifies as its binding limitation (§4.3, §11): deciding whether to query memory at all, and whether a returned result is good enough to accept. **doubt-driven-development**, shipped in addyosmani/agent-skills (Osmani, 56.8k stars), is a general claim-verification discipline with a concrete loop: **CLAIM → EXTRACT** (an artifact and contract, with reasoning stripped) **→ DOUBT** (a fresh-context adversarial reviewer re-examines the result) **→ RECONCILE** (findings classified against the artifact text) **→ STOP** (on trivial findings, a 3-cycle bound, or user override), gated by explicit non-trivial-decision criteria that decide when the loop engages at all. doubt-driven-development is memory-agnostic and addresses no storage concern, but it is the documented shape of the metacognitive gate this paper hands its retrieval-trigger problem to; we position it concretely against §4.3 and §11 rather than leaving that hand-off abstract. The same source contributes a second idea Total Recall can borrow: every skill there carries a "When NOT to use" anti-trigger and a "Loading Constraints" declaration of where it may load — a discipline that maps onto Total Recall's non-evictable-kind guarantees and motivates a *retrieval anti-trigger* (when *not* to fire `recall`), discussed in §11.+}

### 2.6 The Mechanisms That Surround Storage

### [-2.4-] {+2.6+} The Mechanisms That Surround Storage

### 4.3 The Upstream Dependency: Query Formulation

The completeness bound assumes the agent issues a query that actually matches how the knowledge was stored. In production this is the binding constraint, not storage. An agent that formulates a low-similarity query, accepts the weak result, and never escalates will miss content that is physically present and perfectly recoverable. Task-conditioned scoring improves *what is injected once a query is issued*; it does not decide *whether* to query or *whether the result is good enough*. The complementary mechanism is a confidence threshold below which the agent reformulates and retries with expanded queries before accepting failure — a metacognitive control loop that sits above storage and is out of scope here. {+This loop is not hypothetical: it has a documented shape in the ecosystem. doubt-driven-development (Osmani, addyosmani/agent-skills; §2.5) realizes exactly this control structure — a fresh-context adversarial re-examination (DOUBT) bounded by a stop rule (STOP: trivial findings, three cycles, or override) — and binds to precisely the interface+} Total Recall [-defines the interface that makes such a loop possible:-] {+exposes:+} `recall(query)` returns scored results with the similarity scores exposed, so a caller can gate on confidence and decide to retry. We return to this {+contract+} as a limitation in §11.

### 6.1 Beyond Conversation History: Pointer-Eviction of Static Capability Sets

{+### 6.1 Beyond Conversation History: Pointer-Eviction of Static Capability Sets+}

### 6.1 Beyond Conversation History: Pointer-Eviction of Static Capability Sets

{+The marker/recall pattern is not specific to evicted *dialogue*. Any always-loaded block whose content is reachable on demand — skills, tool schemas, workspace files — can be replaced by a resident *router pointer* plus an on-demand fetch, and the per-turn footprint argument of §7.2–§7.3 transfers unchanged. A static capability set behaves, for the purposes of the context budget, exactly like a temporal event stream: a fixed-size resident anchor stands in for a larger body that is materialized only when needed.+}

### 6.1 Beyond Conversation History: Pointer-Eviction of Static Capability Sets

{+We observed this directly. A 44-skill capability catalog (Haines, coreyhaines31/marketingskills) was collapsed by the same principle the paper applies to dialogue: instead of keeping roughly 915 tokens of always-loaded skill descriptions resident, a single ~130-token router "skill" was kept in context and the 44 framework bodies were made reachable on demand, with only the winning entry injected per turn. This is structurally identical to keeping a time-range marker resident while the evicted span is reachable via `recall` — a router pointer in place of an evicted span, with the same "occasional pull, no recurring recap tax" economics of §7.3. The result was a ~7× reduction in always-resident tokens (915 → 130) with zero loss of reachability across all 44 entries.+}

### 6.1 Beyond Conversation History: Pointer-Eviction of Static Capability Sets

{+We present this as a qualitative generalization, not a controlled accuracy benchmark: it was an engineering application with one hard token-footprint number, not a recall/precision study. Its significance for this paper is twofold. First, it is evidence that pointer-eviction generalizes from a temporal event stream to a static capability set. Second, it implies that Context Anatomy (§9.6) — which already itemizes `skillBytes` and `toolSchemaBytes` as distinct prompt slices — exposes eviction headroom in slices the paper otherwise treats as fixed overhead.+}

### 7.3 Marker vs. Summary vs. In-Place Compression Token Cost

### 7.3 Marker vs. Summary {+vs. In-Place Compression+} Token Cost

### 7.3 Marker vs. Summary vs. In-Place Compression Token Cost

The [-two-] compaction strategies differ not only in fidelity but in steady-state token cost. A narrative summary of an evicted span is itself prose that must be re-read on every subsequent turn, and as summaries-of-summaries accumulate, this recap text grows with session length. A time-range marker is a fixed-size directive — a time range, a short topic-hint list, and the `recall` instruction — typically tens of tokens, and marker merging (§5.2) bounds the *total* marker footprint to $O(\log C)$ in the number of compaction [-cycles.-] {+cycles. Between these two extremes sits **lossy in-place compression** — the headroom-style strategy (§2.4) of crushing content with content-aware compressors and keeping a degraded-but-addressable representation resident. We include it as the realistic steady-state competitor the original two-way table omitted, since the field's deployed alternative is increasingly in-place compression rather than narrative summarization.+}

### 7.3 Marker vs. Summary vs. In-Place Compression Token Cost

| Per-cycle artifact | Narrative compaction {+| Lossy in-place compression (e.g. headroom CCR)+} | Pointer compaction | | ----------------------------- | --------------------------------- {+| ----------------------------------------------+} | --------------------------- | | Bytes written to context | Full prose recap (hundreds–thousands of tokens) | {+Compressed content (a fraction of the original, content-type dependent) |+} One marker (tens of tokens) | | Re-read cost per later turn | Entire recap, {+every turn | Compressed content,+} every turn | One marker, every turn | | Growth across $C$ cycles | Roughly linear in $C$ (recaps stack) | {+Linear in retained content (no merge) |+} $O(\log C)$ (markers merge) | | Recovery of evicted detail | Impossible (lossy) | {+Cache lookup of the cached original |+} On-demand via `recall` {+| | Recovery fidelity | None | Exact (cached) but subject to compressor errors in the resident proxy | Byte-exact from durable store+} |

### 7.3 Marker vs. Summary vs. In-Place Compression Token Cost

The marker pays a small, occasional `recall` cost only when evicted detail is actually needed (measured at 22% of turns, §9.3), versus a narrative summary that pays a recurring recap tax on *every* turn whether or not the detail is used. [-This makes pointer-] {+In-place compression sits between the two: it pays a smaller recurring re-read tax than narrative summarization (the resident proxy is compressed, not full prose) and recovers the exact original from cache, but it keeps a representation resident on every turn rather than removing the span, and the resident proxy is itself a lossy artifact that can mislead before a recovery is triggered. Pointer+} compaction {+is+} strictly cheaper in steady state for sessions where most evicted content is never re-touched — the common [-case.-] {+case — while in-place compression is preferable precisely when the evicted content is re-touched often enough that a resident, addressable proxy earns its recurring cost. The two are composable (§2.4): compress a span before evicting it behind a marker when it is likely to be re-touched, and eviction discipline handles the rest.+}

### 9.6 Context Anatomy

The Context Anatomy module records the full decomposition of every LLM prompt: system prompt, workspace files, skills, tool schemas, conversation history, tool results, and user message. Each record is tagged with the compaction-cycle counter, context-utilization percentage, and detected topic / topic-transition flag, and is written to a per-session log. It is the primary diagnostic for understanding compaction behavior in production: by replaying anatomy records, an engineer reconstructs exactly what was in-context at any turn, which markers were present, and when compaction fired. It sits at the intersection of all three memory layers — the hot tail feeds the history slice, persona-aware assembly appears in the system-prompt field, and Total Recall's pointers appear in the conversation-history slice — which makes it the single most useful tool for cross-layer memory [-debugging.-] {+debugging. Because it itemizes `skillBytes` and `toolSchemaBytes` as distinct slices, it also exposes the eviction headroom in static capability sets that §6.1 exploits.+}

### 10.1 Synthetic Pilot: Experimental Setup

We generated 10 synthetic traces — a deliberately small pilot intended to validate the architecture before scaling to real-world benchmarks. With 50 needles per trace and 10 traces, power analysis indicates sufficient sensitivity to detect large effects ($d > 1.0$) at $\alpha = 0.05$; the observed effects ($d > 6$) are well above this threshold. Larger-scale evaluation on LOCA-bench [-(§11)-] {+and on the shared public benchmarks of §11+} will provide tighter confidence intervals. Needles (hashes, file paths, parameters) were seeded in early turns. Flood phases generated ~150K tokens forcing 5 compactions.

### 11. Limitations and Future Work

**Retrieval-trigger blindness.** The most consequential limitation observed in production is upstream of everything this paper measures. Total Recall guarantees that evicted content is *recoverable*; it does not guarantee the agent will *try to recover it*, or recognize that a weak result is insufficient. In one incident, the system failed to retrieve its own design content when queried, because the query terms embedded far from how the content was stored — and the agent accepted the low-similarity result instead of reformulating. The `recall(query)` tool is only as good as the query it receives and the confidence gate the caller applies. Task-conditioned scoring (§4) ranks *what is injected once a query is issued*; deciding *whether to query* and *whether the result is good enough* is a metacognitive function that sits above storage. Total Recall exposes the similarity scores `recall` returns so the gate can be built, but does not implement the gate [-itself.-] {+itself. The gate now has a documented shape to point at rather than an abstraction: doubt-driven-development (Osmani, addyosmani/agent-skills; §2.5) is a general claim-verification loop — DOUBT (fresh-context adversarial re-examination) bounded by STOP (trivial findings, three cycles, or override) — whose DOUBT step consumes exactly the similarity scores `recall` exposes to decide whether to re-query, and whose three-cycle bound is the concrete form of the "reformulate and retry with expanded queries" this paper gestures at. The relationship is honest and asymmetric: doubt-driven-development is memory-agnostic and addresses no storage concern; Total Recall provides the recoverable substrate and the exposed-score interface but not the loop. Citing it converts this hand-off from "someone should build this" into a stated contract between the storage layer and a documented metacognitive loop.+}

### 11. Limitations and Future Work

{+**Retrieval anti-triggers.** The mirror of the trigger problem is over-firing: a `recall` issued when the answer is already in the push pack wastes a pull and risks injecting stale context. The "When NOT to use" anti-trigger discipline of addyosmani/agent-skills (§2.5) suggests a symmetric construct — a declared set of conditions under which `recall` should *not* fire — analogous to the non-evictable-kind guards (§5.1) that declare what storage must never drop. Formalizing retrieval anti-triggers is future work.+}

### 11. Limitations and Future Work

[-**Sample size.** The synthetic pilot (10 traces) demonstrates the architecture's properties given the observed effect sizes, but cannot characterize performance under the full distribution of real-world workloads.-]

### 11. Limitations and Future Work

{+**Sample size and shared benchmarks.** The synthetic pilot (10 traces) demonstrates the architecture's properties given the observed effect sizes, but cannot characterize performance under the full distribution of real-world workloads, and its bespoke needle traces are not directly comparable to other systems. headroom (Chopra; §2.4) ships a reproducible evaluation suite reporting token savings versus accuracy delta on *standard public benchmarks* — GSM8K, TruthfulQA, SQuAD, BFCL — which is the metric pair and yardstick the field will compare against. A planned extension adopts these same public benchmarks as a comparison axis and reports Total Recall's recovery-fidelity and token-footprint claims in headroom's token-savings-vs-accuracy-delta terms, so the numbers are measured on a shared scale rather than only on bespoke needle traces.+}

### 11. Limitations and Future Work

Two {+further+} evaluation extensions are planned for the camera-ready version:

### 12. Conclusion

Total Recall replaces it with a principled alternative: treat the context window as a cache over a lossless store, evict via pointers instead of summaries, retrieve on demand with task-conditioned priority, and reconcile writes so the working set stays bounded while the audit log stays complete. The approach is simple, the implementation is compact, and the results are unambiguous: 100% needle recall where truncation achieves 0%; 94% exact-match at 2-hop where narrative compaction achieves 4%; sub-linear compaction latency; and months of production operation with zero data [-loss.-] {+loss. The same eviction-plus-pointer principle generalizes beyond conversation history to static capability sets, collapsing a 44-entry skill catalog from ~915 to ~130 always-resident tokens with no loss of reachability (§6.1).+}

### 12. Conclusion

Context Anatomy (§9.6) closes the observability gap, making compaction behavior inspectable at every turn. The remaining gap is upstream — whether the agent asks the right question of its own memory — and the architecture is built to hand that problem cleanly to the metacognitive [-layer.-] {+layer, whose shape recent verification disciplines (§2.5, §11) now make concrete.+}

### References

1. Ainslie, J., et al. (2020). _Reformer: The Efficient Transformer_. ICLR 2020. 2. Belady, L. A. (1966). _A Study of Replacement Algorithms for a Virtual-Storage Computer_. IBM Systems Journal, 5(2). 3. Bousetouane, F. (2024). _ACC: Adaptive Cognitive Control for Bio-Inspired Bounded Agent State_. arXiv:2401.11653. 4. Chang, Z., et al. (2023). _LangGraph: Composable Memory Graphs for Agents_. arXiv:2312.12423. 5. Chen, S., et al. (2023). _RetMem: Retrieval-Augmented Memory for Long-Horizon LLM Agents_. arXiv:2308.14321. 6. {+Chopra, T. (2026). _headroom: Reversible Compress-Cache-Retrieve Context Compression for LLMs_. GitHub (chopratejas/headroom), Apache-2.0. 7.+} Curme, C. & Daugherty, W. (2024). _Deep Agents: Filesystem Persistence for Long-Running Agent Tasks_. LangChain Engineering Blog. [-7.-] {+8.+} Dai, Z., et al. (2023). _LongAgent: Classroom-scale Evaluation of Context Management_. arXiv:2311.08245. [-8.-] {+9.+} Edge, D., et al. (2024). _From Local to Global: A Graph RAG Approach to Query-Focused Summarization_. arXiv:2404.16130. [-9.-] {+10. Haines, C. (2026). _marketingskills: A Catalog of Marketing Frameworks as Agent Skills_. GitHub (coreyhaines31/marketingskills). 11.+} Jiang, S., & Zhang, X. (2002). _LIRS: An Efficient Low Inter-reference Recency Set Replacement Policy_. SIGMETRICS 2002. [-10.-] {+12.+} O'Neil, E. J., et al. (1993). _The LRU-K Page Replacement Algorithm for Database Disk Buffering_. SIGMOD 1993. [-11.-] {+13. Osmani, A. (2026). _agent-skills: Disciplined Agent Workflows, incl. doubt-driven-development_. GitHub (addyosmani/agent-skills). 14.+} Packer, C., et al. (2023). _MemGPT: Towards LLMs as Operating Systems_. arXiv:2310.08560. [-12.-] {+15.+} Park, J. S., et al. (2023). _Generative Agents: Interactive Simulacra of Human Behavior_. arXiv:2304.03442. [-13.-] {+16.+} Sarthi, P., et al. (2024). _RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval_. arXiv:2401.18059. [-14.-] {+17.+} Shinn, N., et al. (2023). _Reflexion: Language Agents with Verbal Reinforcement Learning_. arXiv:2303.11366. [-15.-] {+18.+} Verma, A. (2024, pre-print). _Focus: Agent-Managed Context Compression for Long-Horizon Tasks_. arXiv:2401.07190. [-16.-] {+19.+} Wang, G., et al. (2023). _Voyager: An Open-Ended Embodied Agent with Large Language Models_. arXiv:2305.16291. [-17.-] {+20.+} Yao, S., et al. (2023). _ReAct: Synergizing Reasoning and Acting in Language Models_. ICLR 2023. [-18.-] {+21.+} Yu, Y., et al. (2024). _Mem0: Reconciled Long-Term Memory for LLM Agents (ADD/UPDATE/DELETE)_. arXiv:2401.01885. [-19.-] {+22.+} Zeng, Y., et al. (2024). _LOCA-bench: A Benchmark for Long-Context Agent Evaluation_. arXiv:2402.07962. [-20.-] {+23.+} Zhang, Q., et al. (2024). _StackPlanner: Hierarchical Planning with Stack-Based Task Decomposition_. arXiv:2401.05890.
