Stateful tool-using LLM agents treat the context window as working memory, yet today's agent harnesses manage residency and durability as best-effort, causing recurring failures: lost state after compaction, bypassed flushes on reset, and destructive writeback. We present ClawVM, a virtual memory layer that manages state as typed pages with minimum-fidelity invariants, multi-resolution representations under a token budget, and validated writeback at every lifecycle boundary. Because the harness already assembles prompts, mediates tools, and observes lifecycle events, it is the natural enforcement point; placing the contract there makes residency and durability deterministic and auditable. Across synthetic workloads, 12 real-session traces, and adversarial stress tests, ClawVM eliminates all policy-controllable faults whenever the minimum-fidelity set fits within the token budget, confirmed by an offline oracle, and adds median <50 microseconds of policy-engine overhead per turn.
Figures & tables
Figure 1. Architecture of a stateful tool-using agent with the ClawVM layer (shaded). The agent harness manages sessions, assembles prompts, mediates tools, and emits lifecycle events (compaction, pruning, flush, reset). ClawVM interposes at the harness level: the page table and representation selector feed prompt assembly, the fault observer instruments paging and lifecycle behavior, and the writeback journal enforces validated, non-destructive persistence at all lifecycle boundaries. The context window (right) shows how pages at varying fidelity levels fill the token budget. Letters mark failure points from field reports (Section 2 ): (a) post-compaction bootstrap loss, (b) flush miss on reset, (c) destructive writeback to durable stores. Architecture diagram showing the ClawVM layer within a stateful tool-using agent harness, with labeled failure points at lifecycle boundaries.
Type
Min. fidelity
Scope
Degradation path
Bootstrap
Struct. after compact, reset
P/S
F → St
Constraint
Hard-pinned at struct.
S
F → St
Plan
Goal + step
S
F → St → Pt
Preference
Scope, prov.
P
F → C → St → Pt
Evidence
Ptr resolves det.
S
F → C → St → Pt
Conversation
Span ID + time
S
F → C → St → Pt
Table 1. Page classes, minimum-fidelity invariants, scope rules, and degradation paths in ClawVM .
Flush-miss fault from skipped pre-compaction commit
Silent recall visibility
Silent-recall fault from deny/error with reason code
Unsafe persistence rejection
Writeback rejected with DESTRUCTIVE_OP reason
Evidence churn duplicate tool
Duplicate-tool fault from repeated equivalent call
Table 3. Tier-1 lifecycle regression scenarios and gate assertions.
Baseline
Explicit
Δ %
Thrash
Δ %
Retrieval
67.8
− 100%
3.993
− 77.4%
Retr.+Cache
10.8
− 100%
1.642
− 45.2%
Comp-Hybrid
1.5
− 100%
1.017
− 11.4%
ClawVM
0.0
—
0.901
—
Oracle ( h=3 )
0.0
0.0%
0.901
0.0%
Table 4. Aggregate reductions relative to baselines, averaged over 4 workloads × 6 budgets (120–500 tokens). Explicit faults : policy-controllable events (refetch, duplicate-tool, bootstrap, flush-miss, silent-recall). Thrash : paging instability (faults + duplicate-signature alerts over hits); residual thrash at zero faults reflects workload repetition.
Variant
Boot.
Flush
D+R
Total
baseline
20
23
228
271
+pin
0
23
228
251
+resolve
20
23
0
43
+WB-C
20
3
228
251
+WB-R
20
20
228
268
+upgrade
7
23
42
72
Table 5. Additive ablation at budget 180: explicit faults when enabling one feature on the bare baseline. Summed across 4 workloads. Boot. = bootstrap, Flush = flush-miss, D+R = duplicate-tool + refetch.
Variant
Boot.
Flush
D+R
Total
ClawVM
0
0
0
0
− pin
9
0
0
9
− resolve
0
0
126
126
− WB-C
0
20
0
20
− WB-R
0
3
0
3
− upgrade
0
0
0
0
Table 6. Subtractive ablation at budget 180: explicit faults when removing one feature from full ClawVM . Summed across 4 workloads. Boot. = bootstrap, Flush = flush-miss, D+R = duplicate-tool + refetch.
Comp-Hybrid
ClawVM
Type
n
180
300
180
300
coding
9
9/9
9/9
9/9
9/9
debugging
8
1/8
8/8
8/8
8/8
writing
2
2/2
2/2
2/2
2/2
ops
11
11/11
11/11
11/11
11/11
total
30
23/30
30/30
30/30
30/30
Table 7. Task success by type and policy at two budgets. All 7 Comp-Hybrid failures are bootstrap faults in debugging tasks.
Policy
Budget
Success
Faults
Tok/task
Thrash
p50 ( μ s)
Comp-Hybrid
180
76.7%
0.23
1607
1.36
170
Comp-Hybrid
300
100.0%
0.00
2649
1.36
164
ClawVM
180
100.0%
0.00
1605
1.36
167
ClawVM
300
100.0%
0.00
2639
1.36
166
Table 8. Task-granularity replay: 30 synthetic tasks at two budgets. Success = zero explicit faults for the task.