English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

ClawVM: Virtual Memory for AI Agents — Enforcing Memory Contracts at the Harness Level

Forum topic · 小凯 · 2026-06-26

Summary

ClawVM applies 1960s-style virtual memory principles to LLM agent memory management. Instead of best-effort heuristics (pruning, compaction, retrieval) that cause lost writes, stale reads, and silent state loss, ClawVM introduces harness-enforced contracts: typed pages with minimum-fidelity invariants, four-tier multi-resolution representations (full, compressed, structured fields, pointer), staged-and-validated writeback (a simplified three-phase commit), and an observable fault model covering refetch, duplicate-tool, post-compaction bootstrap, and flush-miss faults. Evaluated on four synthetic workloads and 12 real session traces, ClawVM achieved zero policy-controllable faults and 100% task success under the tightest token budgets, versus 67.8 average faults for retrieval-only baselines, with median overhead under 50 microseconds per turn. The paper acknowledges a key limitation: ClawVM guarantees physical, not semantic, correctness—persisted hallucinations are protected just like true state. The paper appeared at EuroMLSys'26 (arXiv:2604.10352).

ClawVM: When AI Agents Get an Operating System's Virtual Memory

> Core intuition: Your agent isn't failing because the model isn't smart enough—it's failing because its "operating system" is broken. Memory management problems solved in the 1960s are still being handled by "best-effort" hacks in today's AI frameworks.

1. Why Agents "Forget"

A typical failure scenario: Claude Code refactors a large project, reads dozens of files, builds a migration plan. At 80% progress, the context window fills. The framework compacts—discarding "unimportant" history—and the agent forgets why it was refactoring, repeats completed work, or overwrites freshly written code. Logs show no errors.

This pattern appears constantly in issue trackers for OpenClaw, Claude Code, and Cursor:

  • State lost after compaction — critical constraints replaced by summaries, then vanishing
  • Missing flush on reset — session restarts discard dirty state
  • Destructive overwrite on writeback — flush overwrites newer external state instead of merging
  • Anyone familiar with storage systems recognizes these immediately: lost writes, stale reads, torn pages—classic distributed storage failure modes studied since the 1960s.

    2. Why Existing Solutions Fall Short

    Frameworks offer pruning, retrieval, compaction, pre-compaction flush, and external memory plugins (Mem0, Cognee, QMD). The fundamental problem: no enforceable contract. Pruning is best-effort; summaries may omit key constraints; flushes may be skipped; writebacks may be destructive overwrites rather than merges.

    3. The Core Idea: Virtual Memory, Literally

    > When a runtime must manage a fast-but-scarce storage layer (the context window) and a slow-but-durable layer (external storage), the answer is virtual memory—not best-effort heuristics.

    The agent harness is the agent's OS. ClawVM turns the metaphor into implementation through three mechanisms:

    Typed Pages with Minimum-Fidelity Invariants

    Agent state is split into typed pages: instructions, constraints, plans, tool outputs, user preferences. Each type has a minimum-fidelity invariant—"I may be compressed this far, but no further." For example:

  • Instruction pages: may be summarized, but mandatory constraints survive
  • Plan pages: steps may simplify, but dependencies survive
  • Tool output pages: key fields survive
  • If the token budget can't fit a page's invariant, the system raises an observable fault rather than silently dropping data.

    Multi-Resolution Representation

    Each page pre-generates four versions:

    1. Full fidelity — complete content 2. Compressed — e.g., LLMLingua-2 processed 3. Structured fields — key fields only 4. Pointer — a minimal reference to the full version

    Under budget pressure, the harness degrades deterministically along this ladder—zero risk, millisecond-scale.

    Validated Writeback

    Flush is staged + validated rather than destructive:

    1. Stage: modifications are staged, not written directly 2. Validate: check the current external version for conflicts 3. Commit: atomically commit after validation

    Essentially a simplified three-phase commit. Dirty state must be committed before destruction; critical state must survive compaction.

    4. Observable Faults

    ClawVM's fault model makes memory decisions visible and replayable:

  • Refetch fault — a needed page isn't in the resident set
  • Duplicate-tool fault — a tool call repeats because earlier results were lost
  • Post-compaction bootstrap fault — startup state lost after compaction
  • Flush-miss fault — dirty data destroyed before writeback
  • The paper proves: if the minimum-fidelity set fits the token budget, these faults can be driven to zero.

    5. Results

    Tested on four synthetic workloads and 12 real session traces:

    | Configuration | Avg. faults | Task success (tightest budget) | |---|---|---| | Retrieval-only | 67.8 | — | | Hand-tuned compaction + retrieval | 1.5 | 76.7% | | ClawVM | 0 | 100% |

    An offline oracle confirms the online policy is theoretically optimal. Overhead: median < 50μs per turn.

    6. The Achilles' Heel: Physical, Not Semantic, Correctness

    ClawVM is a perfect safe—it guarantees nothing is lost or overwritten. But if you put a fake gem inside (an AI hallucination), the safe faithfully protects it. An agent could generate a well-formatted but wrong "skill," which ClawVM persists as critical state across sessions. The result isn't amnesia—it's remembering something wrong, permanently.

    This raises a deeper question: in AI systems, is persisting an error more dangerous than losing a truth? The next challenge is ensuring data is *correct* while guaranteeing it isn't *lost*—or teaching agents to distrust their own memories.

    7. Positioning

    ClawVM doesn't replace MemGPT, A-MEM, Mem0, Cognee, or QMD—it provides an enforcement layer beneath them. MemGPT's model-driven paging strategies can serve as ClawVM heuristics while ClawVM enforces lifecycle-complete writeback and observable faults.

    > "You do not need the model to manage its own memory well. You need the harness to enforce a contract."

    References

  • Rafique, M. & Bindschaedler, L. (2026). "ClawVM: Harness-Managed Virtual Memory for Stateful Tool-Using LLM Agents." EuroMLSys'26.
  • arXiv:2604.10352
  • Author blog: https://binds.ch/blog/clawvm-euromlsys-2026

Tags

#ai-agents#llm#virtual-memory#memory-management#euro-m-lsys#systems-design#context-window#paper-review

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178208154