Virtual Context Windows
A prototype mechanism: treat external storage (files, DB) as an extension of the context window, not a separate retrieval system. The agent reads from disk the way a process reads from swap.
Virtual Context Windows
A virtual context window is not simply a larger context window.
It coordinates three separate systems:
1. Memory storage
What information exists and how it is represented.
2. Retrieval policy
When missing information may be needed and which memories to retrieve.
3. Context management policy
What enters active context, remains an unloaded reference, or leaves the working set.
Traditional virtual memory receives an objective access signal from hardware. Agent memory systems must infer that access semantically.
Virtual Context Windows treat external memory as a software-managed context overlay. Compact references remain outside active context until a learned need-recognition policy - or an explicit agent decision - requests expansion.
What was built
The prototype demonstrates selective, model-initiated expansion of external memory references in CSM.
Implemented:
csm_reentry_previewreturns a re-entry block with compact, unexpanded references.context_faultresolves a known memory ID into full content.context_searchperforms semantic retrieval against the memory store.- Eager injection remains the production path. Lazy resolution is experimental and opt-in.
The prototype does not demonstrate reliable need recognition, adaptive working sets, durable promotion, retrieval correctness, or decay and demotion.
What the prototype exposed
The prototype surfaced three distinct failure modes in the retrieval and context management pipeline.
Semantic need recognition
The agent must infer that unavailable information could affect its reasoning before seeing that information.
This creates three distinct failures:
- Over-expansion: too much context is retrieved.
- Semantic miss: consequential context exists but is never requested.
- Late recovery: the correct context is retrieved only after reasoning has already followed a misleading path.
Threshold tuning can improve retrieval policy, but it cannot eliminate failures caused by imperfect knowledge-gap recognition.
Retrieval waste
Some retrieved context does not contribute to any reasoning step or decision. This is mostly instrumentable: track which references are retrieved but never cited or referenced in downstream reasoning.
Contamination
Wrong, stale, or irrelevant memory can influence reasoning in ways that are not immediately visible. Contamination is more expensive to evaluate than ordinary retrieval telemetry because it requires an arbiter whose reliability must also be measured.
judgment_source:
human
evaluator_model
automated_signal
Next experiments
All four mechanisms below are proposed, not implemented.
Session working-set promotion
Track fault demand over a rolling turn window.
- repeated demand promotes a reference for the current session,
- promotion remains ephemeral by default,
- a session fault never directly mutates durable importance.
Refault detection
A refault is:
resolved
-> removed from active context
-> requested again shortly afterward
A refault is evidence that the context-management policy - not the memory - was misclassified.
WEAVE graph readahead
When memory M resolves, optionally expose highly ranked one-hop causal neighbors as compact stubs rather than full memories.
Graph readahead is conditional on adjacency lookup remaining within the retrieval budget. High-frequency paths may require cached or precomputed neighbor summaries.
Utilization tracking
Classify retrieved references as:
- explicitly cited,
- used to support a claim,
- caused a decision or revision,
- triggered another retrieval,
- apparently unused.
Importance timescales
Two different signals must be distinguished.
Session working-set importance
Represents temporary task locality. Possible signals:
- repeated faults,
- refaults,
- repeated co-access,
- active causal neighborhood.
Durable importance
Represents demonstrated value across sessions. Possible signals:
- repeated usefulness across independent sessions,
- stable decision support,
- explicit user confirmation,
- validated long-term graph relevance.
The invariant:
Retrieval event
-> session evidence
-> promotion proposal
-> independent evaluation
-> possible durable update
Never:
fault -> important forever
Cross-session aggregation thresholds - session count, decay window, evidence confidence, and minimum usefulness - are experimental parameters derived from held-out session evaluation rather than settled architectural constants.
Failure model
| Failure mode | Meaning | Observability |
|---|---|---|
| Semantic miss | Relevant memory was not requested | Evaluation required |
| Retrieval waste | Retrieved context did not contribute | Mostly instrumentable |
| Refault | Previously resolved context had to be loaded again | Automatic |
| Retrieval contamination | Wrong, stale, or irrelevant memory influenced reasoning | Retrospective judgment |
| Promotion drift | Temporary locality became unjustified durable importance | Governance evaluation |
| Promotion cycling | A reference repeatedly promotes, decays, refaults, and promotes again | Automatic lifecycle telemetry |
Not all metrics are equally objective or equally cheap to collect.
Lifecycle stability
Hysteresis is the proposed stabilization shape:
promotion threshold
>
retention threshold
>
demotion threshold
- promotion requires strong evidence,
- retention requires moderate evidence,
- demotion requires sustained lack of usefulness,
- a fast refault after demotion provisionally restores the reference and flags the demotion policy as suspect.
Future lifecycle metrics:
promotion_cycle_count
time_between_promotion_and_demotion
time_between_demotion_and_refault
post_promotion_usefulness
rollback_frequency
These thresholds are not validated. They require independent evaluation.
Evaluation target
Recover X% of manually labeled consequential context gaps within N reasoning steps while keeping irrelevant retrieved context below Y%.
Supporting benchmark outputs:
- refault rate,
- contamination estimate,
- promotion drift rate,
- promotion cycle count,
- judgment-source agreement.
X, N, Y, promotion thresholds, decay windows, and hysteresis boundaries are experimental parameters derived from held-out session evaluation.
Implementation status
| Mechanism | Status | Current or initial policy |
|---|---|---|
| Compact unresolved references | Implemented | Returned through csm_reentry_preview |
| Specific-reference resolution | Implemented | context_fault |
| Semantic memory retrieval | Implemented | context_search |
| Eager production injection | Implemented | Remains the default path |
| Refault telemetry | Proposed | Detect repeated load after context removal |
| Session working-set promotion | Proposed | No production threshold selected |
| WEAVE neighbor stubs | Proposed | Bounded, latency-budgeted one-hop summaries |
| Retrieval utilization tracking | Proposed | Evidence-linked outcome classifications |
| Durable promotion proposals | Aspirational | Evidence schema and aggregation policy required |
| Promotion governor | Aspirational | Manual approval for the earliest implementation |
| Decay and demotion | Aspirational | No automatic decay in the initial version |
| Retrieval-contamination evaluation | Research-only | Human-labeled or judge-labeled benchmark sets |
| Promotion-governance evaluation | Research-only | Validate promotion, retention, demotion, cycling, and fast-refault behavior on held-out sessions |
The current prototype implements selective reference resolution. Adaptive working sets, graph readahead, promotion governance, contamination evaluation, hysteresis, and durable decay are not current CSM behavior.
Scope boundary
The prototype demonstrates selective, model-initiated context retrieval. It does not solve semantic need recognition or durable knowledge governance. Those are separate research problems exposed by the prototype, not capabilities already delivered by it.
Future document
Adaptive Memory Governance - a separate specification that will own evidence schemas, promotion proposal records, evaluator authority, commit and rollback rules, decay functions, hysteresis benchmarks, judge reliability, cross-session aggregation, and promotion-drift audits.