Skip to main content
QUICK REVIEW

[Paper Review] The Pensieve Paradigm: Stateful Language Models Mastering Their Own Context

Xiaoyuan Liu, Tian Liang|arXiv (Cornell University)|Feb 12, 2026
Multimodal Machine Learning ApplicationsComputer Science0 citations
TL;DR

StateLM introduces a learned self-context engineering loop with a toolkit of memory operations, enabling models to manage their own context and outperform baselines across long-document QA, chat memory, and deep-research tasks.

ABSTRACT

In the world of Harry Potter, when Dumbledore's mind is overburdened, he extracts memories into a Pensieve to be revisited later. In the world of AI, while we possess the Pensieve-mature databases and retrieval systems, our models inexplicably lack the "wand" to operate it. They remain like a Dumbledore without agency, passively accepting a manually engineered context as their entire memory. This work finally places the wand in the model's hand. We introduce StateLM, a new class of foundation models endowed with an internal reasoning loop to manage their own state. We equip our model with a suite of memory tools, such as context pruning, document indexing, and note-taking, and train it to actively manage these tools. By learning to dynamically engineering its own context, our model breaks free from the architectural prison of a fixed window. Experiments across various model sizes demonstrate StateLM's effectiveness across diverse scenarios. On long-document QA tasks, StateLMs consistently outperform standard LLMs across all model scales; on the chat memory task, they achieve absolute accuracy improvements of 10% to 20% over standard LLMs. On the deep research task BrowseComp-Plus, the performance gap becomes even more pronounced: StateLM achieves up to 52% accuracy, whereas standard LLM counterparts struggle around 5%. Ultimately, our approach shifts LLMs from passive predictors to state-aware agents where reasoning becomes a stateful and manageable process.

Motivation & Objective

  • Motivate moving from stateless LLMs to state-aware agents that autonomously manage their memory and context.
  • Propose a general toolkit of memory and context-management tools to enable self-engineered context.
  • Demonstrate cross-domain gains in long-document QA, multi-turn chat memory, and deep research tasks.
  • Show that learned context management scales across model sizes and outperforms external, human-driven context engineering.

Proposed method

  • Introduce StateLM, a class of foundation models with an internal reasoning loop and a Pensieve-style memory toolkit.
  • Formalize a tool-augmented agentic reasoning process where the interaction history is mutable via deleteContext and a persistent external notebook.
  • Define a six-tool 'spellbook' (analyzeText, buildIndex, searchEngine, readChunk, note/updateNote, readNote, deleteContext, finish) to manage perception, acquisition, and memory management.
  • Train StateLM in two stages: supervised learning from expert trajectories (SFT) with outcome-based and process-based filtering, followed by reinforcement learning with trajectory rollouts and task-aware rewards.
  • Evaluate on long-context benchmarks across three domains (long document QA, chat memory, deep research) using models of 4B, 8B, and 14B.
Figure 1 : StateLM (right) maintains a “sawtooth” context-use profile, rather than monotonic accumulation (left).
Figure 1 : StateLM (right) maintains a “sawtooth” context-use profile, rather than monotonic accumulation (left).

Experimental results

Research questions

  • RQ1Can models autonomously engineer their own context with built-in memory tools to overcome fixed-context limits?
  • RQ2How does learned self-context engineering affect performance across long-document QA, multi-turn dialogue, and deep research tasks?
  • RQ3Do state-aware agents with Pensieve-inspired memory outperform external, scripted context-engineering baselines under fixed budgets?
  • RQ4How does StateLM scale with model size and task difficulty in real-world long-context settings?

Key findings

  • StateLM outperforms instruct baselines on long-document QA while using only about 1/4 of the active context.
  • On chat memory tasks, StateLM achieves absolute accuracy gains of 10%–20% over standard LLMs.
  • On BrowseComp-Plus deep-research tasks, StateLM reaches up to 52% accuracy versus around 5% for vanilla LLMs, averaging over 40% gains.
  • Across benchmarks, StateLM maintains robust performance under extreme context lengths (e.g., up to 2M tokens in Needle-in-a-Haystack setup).
  • Reinforcement learning on top of a well-trained StateLM yields additional improvements (e.g., StateLM-8B-RL shows +3 points on some benchmarks).
  • Tool-use patterns reveal more searches and fewer memory updates as tasks scale, indicating efficient, task-adaptive context management.
Figure 2 : The self-context engineering workflow of StateLM. Given a query over a long context, StateLM engages in a multi-round, stateful reasoning loop that analyzes the input, builds an index, and iteratively searches, reads, takes notes, and prunes its working context. Messages highlighted in re
Figure 2 : The self-context engineering workflow of StateLM. Given a query over a long context, StateLM engages in a multi-round, stateful reasoning loop that analyzes the input, builds an index, and iteratively searches, reads, takes notes, and prunes its working context. Messages highlighted in re

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.