Skip to content

research(memory): ClawVM-style typed page memory management for token-budget-aware compaction #3221

@bug-ops

Description

@bug-ops

Description

ClawVM (arXiv:2604.10352) introduces a virtual memory layer for stateful tool-using LLM agents that manages state as typed pages with minimum-fidelity invariants, multi-resolution representations under a token budget, and validated writeback at every lifecycle boundary.

The harness (prompt assembler, tool mediator, lifecycle observer) is the natural enforcement point — placing the contract there makes residency and durability deterministic and auditable.

Results: Across four workload families and six token-budget levels, ClawVM eliminates all policy-controllable faults (refetch, duplicate-tool, post-compaction bootstrap, flush-miss) from 67.8 mean faults/config to 0, and reduces paging instability by 77.4%.

Relevance to Zeph

Zeph's compaction subsystem (soft/hard/microcompact) operates on the full message history as a flat sequence. ClawVM's page model offers:

  • Typed pages (structured tool state, conversation context, memory excerpts) that degrade gracefully under token pressure
  • Minimum-fidelity invariants per page type — context can be summarized to pointer, never silently dropped
  • Validated writeback at compaction boundaries to prevent flush-miss bugs (analogous to the orphaned tool_use issue core: utility-gated tool_use leaves orphaned SQLite entry — WARN flood on next session #3168)
  • Deterministic audit trail for what was compacted and when

This is directly applicable to Zeph's zeph-core/src/agent/context/ compaction logic and the zeph-memory store routing.

User Stories

  • As a developer, context compaction should preserve tool state deterministically so that compacted sessions resume without re-fetching tool outputs
  • As a user on a long-running session, the agent should gracefully degrade memory fidelity under pressure rather than abruptly dropping context

Implementation Sketch

  1. Classify context segments into typed pages (tool outputs, conversation turns, memory excerpts, system context)
  2. Define minimum-fidelity invariants per page type (tool output → summary with structured fields; conversation → semantic summary; system → pointer)
  3. Enforce invariants at compaction boundaries in context_assembler.rs
  4. Add audit log entry per compacted page (type, original size, fidelity level, timestamp)

Source

Estimated Complexity

Medium-high. Requires redesigning the compaction contract in zeph-core/src/agent/context/. No external dependencies.

Spec

Pending /sdd specify session.

Metadata

Metadata

Assignees

Labels

P4Long-term / exploratorymemoryzeph-memory crate (SQLite)researchResearch-driven improvement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions