Decoupling Memory from Context: Structured Memory for Token-Efficient Test-Time Continual Learning

Yehya Farhat, Michael Desmond, Anastasios KyrillidisarXiv 2026

TL;DR

Large Language Model (LLM) agents often struggle to learn from experience without either expensive retraining or hitting context window limits. This paper introduces GraphMemory, a structured external memory that organizes learned strategies into a graph, allowing agents to retrieve only the most relevant subgraphs for each query. This approach reduces token usage by over 80% and slashes API costs while maintaining performance competitive with full-memory systems.

What Problem Does This Paper Address?

Modern LLMs are typically static; they don't naturally "remember" lessons from one interaction to improve the next. While "context engineering" (providing instructions or examples in the prompt) allows for weight-free adaptation, it faces a scaling wall.

Existing persistent memory systems, like Agentic Context Engineering (ACE), tend to append every new lesson to a shared "playbook." As the agent learns more, the prompt grows linearly ($O(N)$). This leads to three major issues:

  1. Cost: Every query becomes increasingly expensive in terms of tokens.
  2. Context Limits: Eventually, the memory exceeds the model's context window.
  3. Performance Degradation: Overloading the prompt with heterogeneous, irrelevant information can confuse the model, a phenomenon known as context collapse.

Methods

The authors first propose a unified theoretical framework that treats agent memory updates as a form of optimization over the model's textual context. They then introduce GraphMemory to decouple the total stored knowledge from the active context used for a specific query.

The GraphMemory Architecture

Instead of a flat file, memory is structured as a directed graph:

  • Nodes: Represent specific "knowledge points" or strategies (e.g., "When calculating EBITDA, ensure you exclude one-time restructuring charges").
  • Edges: Weighted connections that indicate how useful two pieces of knowledge are when used together. Weights are updated using a Beta posterior based on "helpful" or "harmful" feedback from a Reflector module.

The Adaptation Loop: RETRIEVE–GENERATE–REFLECT–CURATE

  1. Retrieve: An LLM Retriever looks at a compact index (containing only short keys and IDs) to pick "entry nodes." The system then performs a bounded breadth-first search (BFS) to pull in a relevant subgraph.
  2. Generate: The LLM produces an answer using only the retrieved subgraph as context.
  3. Reflect: A Reflector evaluates the performance and labels the memory transitions used as helpful, harmful, or neutral.
  4. Curate: A Curator updates the graph by adding new nodes or adjusting edge weights based on the reflection.
Figure 2: Overview of GraphMemory. An LLM retriever selects entry nodes from a compact index, after which a bounded breadth-first traversal loads the relevant subgraph. The ACE Generator and Reflector operate on this retrieved context, while the Curator writes new nodes and edges back to the graph.

Datasets

The system was evaluated on two financial reasoning benchmarks:

  • FORMULA: A task requiring the derivation of financial formulas from text.
  • FiNER: Financial Numeric Entity Recognition for XBRL tagging.

The researchers tested these across two different LLM backbones: Claude Haiku 4.5 and a 4-bit quantized Qwen3.8-27B.

Key Insights and Ideas

  • $O(1)$ Context Scaling: By using bounded retrieval, the amount of memory supplied to the model remains constant even as the total library of knowledge grows. This is a massive shift from the linear growth of previous systems.
  • Relational Retrieval: Unlike standard RAG (Retrieval-Augmented Generation) which often relies purely on semantic similarity, GraphMemory uses learned edges to navigate logical connections between strategies that might not be semantically similar but are functionally related.
  • Optimization Analogy: The paper provides a formal proof showing that while append-only memory leads to quadratic cumulative token exposure, bounded retrieval keeps it linear relative to the number of examples processed.
Figure 1: Prompt-token usage at successive training checkpoints for GraphMemory and ACE on FORMULA with Qwen3.8-27B.

Key Results

GraphMemory demonstrates that you don't need to show the model "everything it knows" to get high-quality results:

  • Token Efficiency: It used 81–85% fewer tokens during memory construction and 79–92% fewer tokens at test time compared to the ACE baseline.
  • Cost Savings: On the FORMULA task with Claude Haiku, the estimated training cost dropped from $157.20 (ACE) to just $24.00 (GraphMemory).
  • Competitive Accuracy: Despite the drastic reduction in context, GraphMemory remained within 4 percentage points of ACE's accuracy and actually outperformed ACE by 1.5 points on the FORMULA task when using the Qwen backbone.
Table 1: Offline adaptation performance, token usage, and estimated training cost on FORMULA and FINER. Training-token counts and costs are approximate. Costs assume a 95% −5% input–output token split and standard real-time API prices. Initial accuracy denotes cold-start test accuracy. † ACE/Qwen on FINER is not reported; see note below.

Limitations and Future Work

  • Inference Latency: GraphMemory is currently slower per query (approx. 1.8x) because it requires an explicit retrieval step before generation. The authors suggest that embedding-based retrievers could mitigate this.
  • Index Growth: While the retrieved context is $O(1)$, the "compact index" read by the retriever still grows with the number of nodes. For extremely large memories, this index itself might eventually need to be partitioned or summarized.
  • Evaluation Scope: The study focused on financial tasks; further research is needed to see how these graph-based strategies transfer across different domains or between different LLM architectures.

Summary updated

BibTeX
@misc{farhat2026decoupling,
  author = {Yehya Farhat and Michael Desmond and Anastasios Kyrillidis},
  title = {{Decoupling Memory from Context: Structured Memory for Token-Efficient Test-Time Continual Learning}},
  year = {2026},
  eprint = {2610.02687},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.02687},
}
Figure