The Pensieve Paradigm: Stateful Language Models Mastering Their Own Context
Authors: Xiaoyuan Liu
Tian Liang
Dongyang Ma
Deyu Zhou
Haitao Mi
Pinjia He
Yan Wang
Venue: ICLR 2026 Poster (2026)
Keywords: LLM
memory management
Primary area: foundation or frontier models, including LLMs

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.

Published as a conference paper at ICLR 2026
THE PENSIEVE PARADIGM: STATEFUL LANGUAGE MODELS MASTERING THEIR OWN CONTEXT
Xiaoyuan Liu Tian Liang? Dongyang Ma² Deyu Zhou
Haitao Mi²
Pinjia Hell Yan Wang²
Schooo of Data Science, The Chinese University of Hong Kong, Shenzhen
Tencent Al Lab Hoong Kong University of Science and Technology. Guangzhou xyliu. csê gmail com, yanwang branden@gmail com hepinjie ii edu.cn
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-matue lack the "wand" to operate it. They remain like a Dumbledore without ageney, passively accepting a manually engineered context as their entire memory. This work finally places the wand in the model's s hand. We introduce StateLM, a new class of foundation models endowed with internal reasoning loop manage their own state. We equip our model with suite of memory tools, such as context pruning, document indexing, and note-taking, and train 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; the chat memory task, they achieve absolute accuracy improvements of 10% to 20% over standard LLMss. On the deep research task BrowseComp-Plut the performance gap becomes achieves up to 52% accuracy, whereas standard LLM counterparts struggle around 5%. Ultimately, approach shifts LLMs from passive predictors state-aware agents where reasoning becomes a stateful and manageable process.
databases and retrieval systems, our models inexplicably
actively manage
pronounced: StateLM
INTRODUCTION
A fundamental limitation of current LLMs is their stateless, autoregressive nature. At their core, they passive predictors, architecturally designed to perform sequence completion within an externally- -etorially-provideed context. This forces them to operate like a mind with no long-term memory of its own, unable to actively manage or alter their own reasoning process. This core limitation has pushed the area towards brittle, external workflows of "Context Engineering", where complex reasoning offloaded to human- written scripts that orchestrate series of iso- lated LLM calls. Whether through brute-force context window expansion scripted workflows, the model itself remains passive component without the capability to strategize or manage its own memory.
LLM
StaseLM Pruning)
Cres
begg Place Dorl)
uodesehics
Lioor Possin Accorudsioo Faluom
Thggeling
Tims Ressoring Stepe
Timme Rleactiing Staze
Figure 1: StateLM (right) maintains a "sawtooth" context-use profile, rather than monotonic accumu- lation (left).
Work was done when interned at Tencent AI Lab. Correspondence Pinjia He <hepinjia@euli Secptiiaaeuukeeeee www...u...............

---

Published as a conference paper at ICLR 2026
This dilemma evokes powerful analogy from the world of Harry Potter. With touch of his wand, Dumbledore extracts, stores, and organizes his memories in a Pensieve. He possesses complete agency: he decides what to offload, what to revisit, and even how to share his thoughts with others like Harry. This vision of active memory management stands in stark contrast to our current reality in AI. A profound paradox exists: while we have built the Pensieve, the vast databases and retrieval systems, we have never given the model the wand. Instead, we humans, act as the wizards, We use our own "spells" (e.g., context engineering) pull out what we think is relevant information, and then force-feed it into the model's 's context. The model is not the wizard; it is merely passive observer of the magic we perform on its behalf.
The central question of our work is therefore simple: What happens when we finally place the wand in the model's hand? We answer this by introducing Stateful Language Models (referred to as StateLMss,, new class of foundation models endowed with a learned capability to self-engineer their context. As illustrated in Figure | unlike traditional models that accumulate tokens linearly until hitting the limit, StateLM maintains efficient, "sawtooth" context length. The cornerstone of this mechanism is the deleteContext tool, which empowers model the capability to self-forget redundant tokens from its context. By coordinating this with auxiliary "spells" for data ingestion (readChunk) and insight distillation (updateNote), the model establishes a dynamic reasoning loop: reads segment, record key information into persistent notes, and immediately remove the raw text. With this learned "self-context engineering" capability, StateI consistently maintains a compact, noise-free state that allows for sustainable, accurate reasoning regardless of the total context length.
We evaluate StateLM through a set of complementary experiments. On long-documen QA bench- marks, StateLM consistently outperforms instruct baselines while using only 1/4 of their active context, with average accuracy gains ranging from 5% to 12% across model scales. StateLM also surpasses prior agentic methods under identical context budget. Beyond document QA, StateLM generalizes to more diverse, complex settings such as long-term chat memory and deep research tasks without task-specific tuning. On the chat memory task, they achieve absolute accuracy improvements of 10% to 20% over standard L.MMs. On the deep research task BrowseComp-Plun the performance gap becomes even more pronounced: The StateLM series achieves up to 52% accuracy, whereas the best vanilla LLM counterparts remain around 5%, resulting in an average improvement of over 40%. Further analysis shows that the improvements are consistent across diverse problem aspects, and that the learned tool-use patterns adapt accordingly to different tasks. Together, these results establish StateLM as a pioneering, general approach for diverse scenarios, shifting LLMs from passive predictors state-aware systems.
Our contributions are threefold:
The Pensieve Paradigm:
We introduce a novel framework that shifts context engineering from external, human-written scripts to the model's own agency, enabling L.LMs to actively manage their own context.
MtateLM: We develop a new class of foundation models endowed with learned self-context engineering capabilities, allowing the model dynamically manage its reasoning state through a general-purpos toolkit of memory operations.
Cross-Domain Generality: We demonstrate significant performance gains across long-document QA, multi-turn dialogue, and deep research. To our knowledge, this is the first study to simultane- ously address the memory challenges of these three domains within a single, unified model.
RELATED WORK: HUMAN AS THE WIZARD
The core challenge of statelessness has not gone unnoticed. The dominant response, however, has been to cast the human developer as the wizard, meticulously orchestrating the model's limited memory. This paradigm of external control is defined by Andrej Karpathy "context engineering":
t...the delicate art and science of filling the context window with just the right information for the next step..." " (Karpathy 2025)
This observation frames the entire landscape of current research. The vast majority of work focuses on building better context-workflow while the model remains a passive component, waiting for the human wizard to manage its memory.
2

---

Published as a conference paper at ICLR 2026
RAG The most prevalent form of context engineering is Retrieval-Augmentte Generation (RAG) (Lewis et al., 2020; Gao et al. 2024). In the standard RAG paradigm, a pipeline de- signed around stateless LLM. The process involves taking user query, using dense retriever to search a vector database (the Pensieve) for relevant text chunks, and "stuffing" this retrieved context into the model's prompt. The model has agency; it passively accepts the context it is given. Recent advancements like ALR? (Li et al. (2024) and Search-O1 (Li et al., (025a) make this external workflow more sophisticated, but they still operate within workflow predefined by the human developer.
Agentic Memory A second line of work moves toward more structured memory systems for LLM agents. Frameworks like MemGPT (Packer et al., 2024) and MemOS (Li et al. 2025b) introduce pperating-system-lik. memory hierarchies to page information in and out of the context window, whereas Memory-R1 (Yan et al. 2025), and MemAgent (Yu et al.) 2025) apply the memory update actions at fixed, human-specified points. Most recently, research has shifted toward making these context management behaviors learnable through Reinforcement Learning (RL). Context- Folding (Sun et al., 2025a) introduces a framework that empowers agents to manage their context by procedurally branching into sub-trajectories and "folding" them upon completion. This allows the model to collapse intermediate steps while retaining a concise summary. Similarly, ReSum (Wu et al., 2025) proposes a paradigm for indefinite exploration by training agents to perform periodic context summarization. By converting interaction histories into compact states, ReSum enables models to bypass context constraints.
However, even these advanced methods remain bound by the "Human as the Wizard" paradigm. In Context-Folding (Sun et al. 2025b), the model is trained adapt to specific, human-designed branching-and-folding routine. In ReSum (Wu et al. 2202). the model learns to reason within fixed summarization schedule. In both cases, the fundamental logic of context management is hard-coded into the training objective or the tool definition.
This Study: The Model as its Own Context Engineer. While existing works train models to adapt to numan-predefingg context engineering routines, StateLM trains the model to become its own context engineer. Instead of teaching the model to merely execute a rigid routine like folding or summarizing, we place the wand in its hand. StateLM is equipped with general-purpose purpose toolkit of memory operations such as to use them strategically. The model is no longer a passive observer of predefined workflow; it learns to architect own reasoning loop, dynamically deciding which information vital, which is noise, and how to structure its reasoning state.
readChunk, and updateNote- and is trained
3 METHODOLOGY
This section introduces our proposed method, StateL.M. We first formalize the problem setup (Sec- tion 3.11. then describe the proposed StateLM framework and the Pensieve paradigm (Section 3.2 Finally, we outline the training procedures used to develop the StateLM (Section 3.3).
3.1 PROBLEM SETUP
We consider generic tool-augmented agentic reasoning process for language models. Given user query q, the agent interacts with an environment over a sequence of rounds t = I,..., T. Initially, the state is so = [q]. At each subsequent round t, the agent conditions
interaction state
St [g, 01, Qt-1, 0.-1].
where each (a,, o.) denotes a past assistant action and its corresponding environment observation.
Although the interaction is defined over the abstract state st, the language model operates textual prompt obtained by applying a chat templating function C, which serializes the interaction into a token sequence representing the model's reasoning state and injects additional text such as system prompt and tool descriptions x; = C(st). For clarity, we omit this step in the subsequent discussion.
At round t, the agent samples action de T st). Each action consists of natural-langee language reasoning segment ("thought") followed by a tool invocation ("act"). The environment then returns an observation o = E Est, at), where & denotes the environment dynamics.
3

---

Published as a conference paper at ICLR 2026
Environment
Environment
Self-Enginseeed Context
R
MEMORY
Updir Stcces
Long Cunteal Iepui
Roand
Iatemal Memory Nooboos
USFR QUTRY
La'sdlr
DELETR, CONTENTION
Nosndf
Celoa Dekthan SacDa
Reanl?
Tokeaied Larh
DELETE CONTENTieg
Sound
Catesi Deleiie Sacceo
Lae decessne in tos long ... BUILD INDENO
Nowal
To Tn-ummnnss,, in me READ Nillies)
Sound
Note Cankar Sunmay
For use supaeiie,, Ie's SEARCH ENGINE
Rowed
Relenst Beads
4
Avalibie Spac Turs
key informatonis
CHUNK .M
Rosal 10
IEAPTER oNr Tilll
I'r patuedd preeh nb.
FINaSII scowe)
Context Limit
StateLM
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 index, and iteratively searches, reads, takes notes, and prunes its working context. Messages highlighted in red are replaced with stubs after the deletion operation. The loop terminates once StateLM determines it has gathered sufficient information for the final answer.
defining characteristic of this formulation is the monotonic growth of the interaction state:
1
Sz (at, Oz);
where || denotes ordered concatenation. All prior actions and observations are permanently retained and exposed to the model in future rounds. While effective for short-horizon reasoning, this monotonic accumulation becomes critical limitation in long-horizon settings. Earlier reasoning steps and raw tool outputs persist in the prompt and continuously consume the model's 's fixed context budget, eventually leading to context exhaustion and performance degradation.
3.2 OUR METHOО:: STATELM REASONING WITH PENSIEVE
LtateLM extends the generic agentic reasoning loop by allowing the model to explicitly modify its own interaction history. Rather than treating the interaction state as an uppend-only record, endow the policy with the ability actively control which past elements remain visible. This transforms the interaction state from a passive log into a mutable, stateful object that can be manipulated over time.
Table 1: The StateLM "Spellbook": general- purpose toolkit for stateful context management.
Tool Name
Description
Contex Perception (Understanding the environmnnt) ana analyzes yzeText
Returs the input length.
CheckBudget
Reports remaining interaction budget.
Information Acquisition (Accessing input) bui 1deiddx
Builds a searchable index.
sea Bearrchngiim readChunk
Searches for relevant segments.
Loads a selected text chunk.
8,41 St ot)
St+1 = F(st, at ot),
Memory Management (Distilling signal and pruning noise)
not e/ updateNote
Records or updates key knowledge.
where F is a state-evolution function that can append new interactions or modify historical elements based on s actions.
readllate
Retrieves stored notes inlo context.
de at cContext
Removes messages from context.
Termination
Sinish
Ends reasoning and outputs the answer.
The core mechanism enabling this transforma- tion for the agentic loop is the Pensieve paradigm, which we define as a persistent external memory coupled with explicit context-pruning operations. Conceptually, the Pensieve comprises two compo- nents: (i) an external notebook that stores compact, task-relevant notes across the entire episode, and (ii) deletion action that remove the selected past interactions from the context. This design is inspired by the Pensieve metaphor in Harry Potter, where raw experiences are extracted, distilled into durable memories, and revisited on demand.
4

---

Published as a conference paper at ICLR 2026
Concretely, in addition to standard reasoning and tool-use actions, StateLM may emit context- management actions of the form
narg()rgs), = deletteContex((mm))
where msg identifies previous assistant action a; environment observation o,, Executing de exetteeCnt () removes the corresponding element from the interaction history exposed to the model in subsequent rounds, while the recorded note remains persistently accessible. This helps to sustain long-horizon reasoning under fixed context budgets.
3.3
TRAINING APPROACH
3.3.1 SUPERVISED LEARNING FROM EXPERT TRAJECTORIES
We first initialize StateLM using supervised learning from expert-generated trajectories that demon- strate effective context management. To construct such trajectories, we incorporate teacher model and place it in the StateLM inference environment, equipped with curated system prompt that specifies high-level process guidelines and few processing examples. We then collect complete interaction trajectories produced by the teacher. As illustrated in Figure (left), each expert trajectory consists of a sequence of interleaved actions, decomposed into thoughts (t) and acts (a), together with the corresponding environment observations (o).
In practice, trajectories produced by teacher models can fail to meet our requirements due to various reasons. To obtain high-quality dataset, we apply post-processing pipeline to filter and construct the training samples.
Outcome-based Reject Sampling. We first retain only trajectories that reach a correct final answer. Correctness is determined by comparing the model-provided answer against the golden answer.
Process-based Reject Sampling. Among the trajectories that pass outcome filtering, we further filter based on context management behavior. Specifically, we discard trajectories that fail to prune the context time, and those that skip necessary reading steps when sequential reading is required.
Training Sample Construction. From each expert trajectory T = (4, l1, 01 01, ar), we construct multiple supervised training samples by progressively evolving the interaction history within the same StateLM environment used during generation. Specifically, at the i-th step, the input context the model is the chat-templated text derived from the interaction state s;, which recursively evolves from the initial state while the prediction target is the teacher's 's thought and act at step i.
During training, we upply a token-level mask such that the cesss-entropy loss is computed only over the tokens of the final assistant turn corresponding to step i. All earlier turns are masked out and do not contribute the loss, as they may be modified or removed during subsequent generation. This masking scheme also ensures compatibility with chat templates that include generation tag control, such as the <think> tag logic used by Qwen3.
Action Balancing. Even after the two-stage rejection sampling, the resulting data distribution can remain imbalanced. particular, actions involving frequent and low-complexity tool calls such as DeleetCConeett and readChunk may dominate the dataset, leading to the underrepresentation of other operations. To avoid biasing the policy toward certain operation strategies, we downsample training samples associated with overrepresented actions, yielding more balanced distribution over memory and reasoning operations.
3.3.2 REINFORCEMENT LEARNING FOR JELF-IMPROVENENT
Following behavior initialization through supervised fine-tuning, we employ reinforcement learning fine-tuning to further improve StateLMs and promote the emergence effective gobleem-solving strategies through aidl--rnd-rrro interaction. The training algorithm builds a GRPO-style objective, with adaptations specific to StateLM, including trajectory snapshots, controlled batching, and task- aware reward design.
5

---

Published as a conference paper at ICLR 2026
Supervised Fine-tuning
Reinforcemnnt Fine-tuning
Environment
Environment
StateLLM migh
Grodent Update
Input data
Inpul diata
Reward Module
trajectory 7 = 1g. Op. 02r
Rolleut trajetory
T: Eg.
Reward Sh
Prosessing Layer
samples S, (g.r..a I.S, 19.4,0,.00 b. ........
(a. du of cocee compree
Contwol Evoloe
$
$
CE Loss
Reward
snapehatt
(4.
Initaal Model
Group Relativ Advantage Estimation
Figure 3: The two training stages of StateLM.
Trajectory Rollout and State Snapshots. As illustrated on the Figure 3 (right), given an input query q, we rollout n trajectories , from the current policy Tea Each trajectory corresponds complete episode and terminates either with finishh sh call or upon reaching predefined budget limit. During rollout generation, the agent interacts with the environment and invokes context management actions. We collect state snapshot whenever context-editing action is taken. After the snapshot, the context evolved and masked, and next sample proceeds from the new state. By the end of a trajectory, this process yields sequence of state snapshots together with their loss masks.
Rather than using all snapshots produced within trajectory, control the batch size by uniformly sampling a fixed number of snapshots per trajectory. Each selected snapshot contributes equally to the optimization objective, independent of the length of the underlying trajectory. Under this design, the parameter serves as a control knob for variance and computational cost, thereby mitigating bias toward longer trajectories.
Reward Design. After collecting the rollout trajectories, assign scalar reward to each trajectory and its associated snapshot trajectories based on the outcome of the final trajectory. Specifically, given a query q, golden answer a, and the terminal trajectory Tast, the reward is defined as:
+1, correct, formatted, and finished, 0.5, incorrect, formatted, and finished, unformatted or unfinished.
R(g, a, Tistt) =
Correctness is determined by checking equivalence between the final answer and the golden answer using the same judging procedure as in the SFT stage. Format compliance requires the answer to be returned via the finish tool call and satisfy task-specific constraints, such as brevity requirements. We additionally impose predefined limits on the maximum context window size and the number of interaction turns. Trajectories that exceed either limit are aborted and categorized as unfinished. Given this outcome reward, the advantage is computed using a group-based baseline formed across samples from multiple rollout trajectories.
EXPERIMENT
To verify the effectiveness of the proposed method, we evaluate the proposed method through extensive experiments on three base models of varying parameter scales across multiple benchmarks.
4.1 TRAINING SETUP
Our training procedure consists of two stages. For Stage 1: Supervised Learning from Expert Trajectories, we use the PublicDomain split of NovelQA (Wang et al. (025) and the training split of NarrativeQA (Kočiský al. 2018) to generate expert demonstrations. These datasets chosen for their long-con long-context characteristics, which naturally require explicit context management. We use Claude Opus 4.1 as the teacher model for its agentic capabilities. While the majority of trajectories

---

Published as a conference paper at ICLR 2026
Table Wveedle-in-a-hayttae (NIAH) experimental results comparing model performance across selected context lengths. All values represent accuracy (%) and results are averaged over 3 runs.
Length
Model
32K
64K
128K
256K
512K
768K
1M
2M
Qwen3-4B
100.00
100.00
88.33
41.67
23.33
16.67
3.33
1.7
StateLM-4B (w/o search)
95,00
95.56
95.56
88.33
76.67
62.78
53.89
32.22
Qwen3-8B
100.00
100.00
88.33
41.67
23.33
16.67
3.33
1.7
StateL.M-8B (w/o search)
99.44
98.33
98.33
99.44
95.55
88.89
88.89
67.22
Qwen3-144
100.00
100.00
88.33
41.67
23.33
16.67
3.33
1.7
StateLM-14B (w/o search)
100.00
100.00
99.44
97.78
89.45
94.44
95.00
83.89
are generated with the search tool enabled, we also incorporate a small subset generated without search to develop scan-based reading behaviors. In total, we collect 3.3K full trajectories, which are subsequently filtered and decomposed into 35.7K training samples. For Stage 2: Reinforcement Learning for Improveepoeettt, we adopt LongBench v2 (Bai et al.) 2025) as the training dataset, using 488 problems in its training set. We also augment this dataset by converting a subset of multiple- choice questions into open-ended questions based on LLM judgments. The detailed statistics for the training datasets described in Appendix A and the training configurations used in the experiments are reported in Appendix
For the models, conduct experiments using the 4B, 8B, and 14B instruct variants from Qwen3 model family (Yang et al. 2025), selected for their strong capability and agentic support. Models trained with SFT and RL are referred to StateLM and StateLM-RL in the following evaluations.
4.2 SYNTHETIC MEMORY RETRIEVAL
We first assess whether StateLM can succeed on task that isolates memory retrieval from extensive reasoning. To this end, follow the Needle-in-a-Haayttck setup from prior work (Hsich et al.) 2024) and construct a synthetic benchmark of 480 problems spanning 8 context lengths. Each problem embeds single key sentence (the "needle"") into a long passage (the "haystack"), and the model must retrieve the exact value associated with the queried key. To test the model limit, we utilize YaRN (Peng et 2023) obtain the recommended 128K context window for both StateLM and the Qwen3 instruct baselines. For the latter, we follow prior work (Wang et al., 2025 An et al. 2024 and truncate the input by retaining only the first 128K tokens the context.
To test StateLM's memory management ability under increasing context pressure, we deliberately remove the search tool from the available tool set. Otherwise, StateLM would rely on the search tool to retrieve the key and achieve near- parrperfect accuracy regardless of context length. In addition, we adopt a context-deletion strategy in which only the assistant's tool-call segment is pruned when the corresponding assistant message ID is specified for deletion, while the original thought is preserved. find empirically that this strategy better aligns the model's behavior with the scanning- -ased tool set and consistently yields higher performance.
Table reports the results. Across all model scales, the StateLM variants outperform their instruct baselines starting from 128K and The Qwen3 instruct models report identical accuracy they consistently solve the problems within their context limit, and repeated sampling does not affect the outcome. While the instruct baselines rapidly degrade beyond the 128K limit, falling to nearly 0% accuracy at IM tokens, the LtateL.M variants remain highly robust up to 2M context.
4.3 LONG-CONTEXT REASONING
We next evaluate the effectiveness of StateLM in practical long- cong-context reasoning scenarios. To this end, we consider four benchmarks spanning three different domains:
Long Document QA: the Copyright split of NovelQA (Wang et al. 2025) (757 problems) and the
Mn.MC (English Multiple-Choice) split of ccBench (Zhang al. 2024) (229 problems).
7

---

Published as a conference paper at ICLR 2026
Table 3: Performance comparison of StateLM with baseline models on long-context reasoning benchmarks. The mean input length of each benchmark computed by the Qwen3 tokenizer is reported parentheses. Results for Qwen3 and StateLM variants are measured over 3 runs. *For BrowseComp-Pluss we use the full 128k context for our trained StateLMs for better performance.
LongDoc QA (135K)
Model
Context
Chat Memory (115K)
*BrowseComp+
NovelQA
ocBench
(552K)
Qwen3-235B (w/ Pensieve)
256K
80.71
73.36
67.00
55.33
RL-Memory 7
32K
60.24
62.45
40.60
RI-Memory
32K
78.86
74.24
59.00
ReadAgent-8B
32K
16,38
24.02
0.00
ReadAgent-14B
32K
23.12
34.06
14,60
Qwen3-4B
128K
65.17
+ 0.53
59.97
+: 0.50
39.53 + 1.36
4: 1.02
Mt-4
32K
79.57
+ 0.93
67.25 + 0.76
59.33 0.23
35,33 =: 5.99
Qwen3-8B
128K
65.87
1.42
66.81 1.16
45,40 1.56
5.56 0.77
Mt88
32K
83.84
0.42
70. 16
+: 1.33
58.93
2.53
46,22 1.68
,, Statee.M-88-Re
32K
84.15
1,00
73.07 1.33
59.73 + 2.30
46,44 = 0.77
Owen3-14P 14B
128K
77.94
+ 0.26
74.96 + 0.25
54,07
0.76
5,46 : 0.04
StateI.M-14B
32K
84.15
0.82
77.44 + 1.40
64,40
+: 1.40
51.33 1.34
L.StateL.MI4BBRRL
32K
84.85
0.42
78.46 0.67
64.47 0.50
52.67 4.00
Chat Memory: LongMemEval-SS (Wu et al. 2024) (500 problems), which evaluates long-term memory retention under multi-turn user-assistant interactions.
Deep Research: randomly downsampled subset of BrowseComp-Pius (Chen et al. 2025) (150 problems) following (Sun et al. (2025a) which tests agent model's 's deep research ability through iterative reasoning over search results.
Our primary comparisons are against Qwen3 instruct models, which are scaled to 128K context length using YaRN. In addition, we include the following methods:
Qwen3-235B (Yang et al. 2025): the strong agentic model Swen3-2355-A300 -n0--nnsttttt-2500
directly equipped with our StateI.M framework with 256K context window.
ReadAgent (Lee et al.) 2024): prompting based LLM agent that organizes long documents into
compressed episodic "gist" memories and selectively revisiting the original text when needed.
2025 an RL-trained LLM agent that processes long contexts incrementally in chunks and updates its memory prompt after each chunk.
MemAgent Yu et al.
For all benchmarks, we report Accuracy the evaluation metric. For Long Document QA, where all questions are multiple-choice, correctness is determined using rule-based evaluation script. For Chat Memory and BrowseComp- Pluu,, follow the original evaluation protocols and adopt LL-M-based judge. Additional evaluation details and implementations are provided in Appendix
Quwen3-4B
Statel M-44
Qwen3-ep B-BB
StateL SB
Qwend-14B
StateLMi-14
67.64
$3.52
60
Accaraccy
60
LEST
30-126K
128-812K
Problem Evidense Position (Token)
Problem Dridence Fosition (Token)
Problem Evidenor Position (Token)
Figure 4: NovelQA accuracy by answer evidence token position in the provided context.
On LongDocQA and Chat Memory, StateLM outperform the instruct baselines using only 1/4 of the context window and other agentic methods under the same context budget. The results in
8

---

Published as a conference paper at ICLR 2026
Qwenn3-14B
Ht-MeemoryAgent-14
Statel, M-14B
@wenn-114 14B
RL-MemAgent 14B
StateLMM11B
character
multi-ses
meaning
knoow update
100
single ste-tist
90
plot
80
67-5
88.9
Accuracy
70/94
20.5
BB
relnt
temporal
19 27-78
single single siglleson-asst asst
60
30.1
$3.6
50
Multi-Hop
Single-Hop
times
span
single-ses-peet
Problem Complexity
Figure 5: Performance breakdown by problem aspect on NovelQA (left) and LongMemEval (middle), and by question complexity on NovelQA (right).
Table 3 show notable performance improvements of StateLM over the standard instruct baselines, demonstrating the effectiveness of learned context management. For example, compared to the standard Qwen3-8B, Statel.M-8B achieves over a 10% absolute improvement on Long Document QA. 13% on Chat Memory. While the relative gains are more pronounced for smaller models, StateLM follows a similar scaling trend to instruct models, with larger variants achieving stronger performance, indicating that the proposed approach scales effectively with model capacity. addition, StateLM consistently outperforms other agentic memory methods at the same model scale and context budget, highlighting the advantage of the self-managed paradigm over predefined workflows.
Figure further breaks down performance by the position of answer evidence in the context. The results show that, on the Long Document QA task, StateI consistently outperforms the instruct baseline across all evidence ranges, with the most pronounced gains occurring when the relevant evidence appears later in the document. For example, the 128-256K range, StateLM exceeds the instruct model by 23 and 24 accuracy points for the 4B and 8B variants, respectively.
StateLM generalizes effectively to deep research tasks. On the deep research benchmark pronounced: StateLM-145 MoLeLM-14B-ER B-RL achieves
BrowseComp-Plle the performance gap becomes up to 52% accuracy, whereas the best vanilla counterpart, Qwen3-1444 14B, remains around 5%. On average, the StateI.M series delivers improvements 40 points standard LLMss These results demonstrate the generalizability of our proposed paradigm to diverse scenarios, including complex agentic tasks.
RL training brings further improvements. Table also shows that applying reinforcement learning on top of well-trained StateLM can further improve performance. For example, StateLMM8B--R achieves an additional 3 -poontt increase on coBench. Our in-house experiments show that continuing SFT training with additional epochs can degrade performance, whereas RL training does not suffer from this issue. These results indicate that MtateL can further refine its capabilities by exploring and learning from its own trajectories.
StateLM improves across problem aspects and difficulty levels. By breaking down performance across different axes in Figure 5 we observe that StateLM- 14B achieves consistent improvements over both the instruct baseline and MemAgent across most aspects. StateLM is relatively weaker on "span" and "user-preference" categories, which likely stems from the limitations of keyword- search-basee reading when handling non-direct or implicit queries. In contrast, StateLM-111 14B exhibits the largest gains over the instruct model on the "Multi-Hop" category, showing the advantage and robustness of the proposed iterative reasoning loop for integrating evidence across multiple locations.
FURTHER ANALYSIS
5.1 TOOL USE PATTERN
To better understand how StateLMs manage their reasoning states during inference, we analyze their tool-use patterns across different benchmarks. Specifically, track the total rounds, external memory operations (mem, including note, updateNote, and readNote), context pruning operations (del, de GeleteContext) and search operations (srh, searchEngi Table reportss

---

Published as a conference paper at ICLR 2026
the average counts of these operations per problem for StateLM-14B, and more results provided in Appendix D
The results reveal several patterns. First, the total number of reasoning rounds increases with task difficulty. In particular, StateLM allo- cates more intermediate steps on more chal- lenging benchmarks such LongMemEval and BrowseComp-Plus where the overall perfor- mance is lower. Second, as input length grows, the primary change is an increase in search oper- ations rather than memory updates, suggesting that MM relies multiple targeted searches to navigate longer inputs while retaining only key information memory. Finally, the number of memory operations remains cost-efficient. In contrast fixed-worfflow methods where memory updates may occur at every step, StateLM invokes memory operations far less frequently. Together, these patterns demonstrate StateLM's ability to adapt its behavior to different tasks in efficient and problem-ave aware manner.
Rounds
mem
del
srh
NovelQA (119K)
18.6
4,3
6.3
1.8
ooBench (189K)
20.7
4.6
6.8
2.9
LongMemEEvl (115K)
22.4
2.2
BrowseCompt (552K)
22.8
4.1
6.1
6.6
Table 4: Tool-use pattern of S- across benchmarks with mean input length reported.
5.2 COMPARISON TO QWEN3 AGENTIC
Since recent open-son open-source models such as Qwen3 already support agentic tool calls, natural question arises: is deliberate training necessary for developing StateLMs? In other words, can instruct models learn to manage their own context and memory solely through an agent-style system prompt paired with appropriate toolkit? To validate our approach, we construct detailed system prompt that explicitly specifies the intended context management procedure (see Figure in the Appendix) and expose the full tool set of StateLM to Qwen3 instruct models, which refer to "Agentic" models. We then evaluate these models on the Long Document QA tasks including NoveIQA and BeBhhch and compare their performance against fine-tuned StateLMs.
The results in Figure 6 present this compari- son. While the largest agentic model, Qwen3- 14B, is able to correctly complete and submit answers for up 30% of the questions, its per- formance remains substantially below that of the trained StateLMs. Smaller agentic variants per-
Qhwes3-H-AAgaee
Qwen3 -BB-gggtiicc
QwenS A4B-Ageiii StotedMM-148
90
75
Accuracy
60
form even worse, further widening the gap. Our
45
error analysis reveals that these models often fail to keep their context within the budget, caus- ing the overflow error. These findings suggest that although such models inherently possess cestruction-folloviin
30
15
and tool-calling capabil- ities, mastering the context management with the Pensieve is not a trivial task and requires deliberate training, particularly for these rela- tively small-scale models. In other words, our training stages enable these models learn and develop effective tool-use patterns that make context management more robust and reliable.
NovelQA
Infiniteeench
Figure 6: StateLM and Qwen3-agentic model per- formance comparison.
6 CONCLUSION
In this work, we introduce StateLM, a state-aware agentic system in which models actively manage their own context through tool-based operations. Across both synthetic memory retrieval and realistic long-context reasoning tasks, StateLM consistently outperforms instruct baselines as well as existing agentic methods. These results point shift from systems that passively accumulate context toward models that dynamically refine and control their reasoning states. Despite certain limitations, our proposed paradigm offers a scalable and principled approach for future foundation models and agentic systems, where context management becomes an intrinsic and learned capability.
10

---

Published as a conference paper at ICLR 2026
ACKNOWLEDGEMENT
This paper was supported by the Guangdong Basic and Applied Basic Research Foundation (No. 2024A1515010155..
REPRODUCIBILITY STATEMENT
We ensure reproducibility by providing detailed descriptions of our methodology, datasets, models, and training and evaluation configurations in Section 4 Appendix B and Appendix [ The main code is included in the supplementary material, and we will release both the code and our training dataset publicly facilitate the reproduction of results.
ETHICS STATEMENT
This work complies with the ICLR Code of Ethics. Our research mainly develops a stateful language model that efficiently manage its own context memory. Training and evaluation rely solely on published datasets, and the research does not involve human subjects or sensitive personal data. We carefully considered issues of fairness, privacy, security, and potential societal impact, and found no outstanding ethical concerns. Nevertheless, we acknowledge that such models are still at an early stage of development and should be used for research purposes only. We further emphasize that evaluations should be conducted in controlled environments with limited tool access.
REFERENCES
Chenxin An, Shansan Gong, Ming Zhong, Xingjian Zhao, Mukai Li, Jun Zhang, Lingpeng Kong, and Xipeng Qiu. L-eval: Instituting standardized evaluation for long context language models. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume I: Long Papers), pp. 14388-14411, 2024.
Yushi Bai, Shangqing Tu, Jiajie Zhang, Hao Peng, Xiaozhi Wang, Xin Lv, Shulin Cao, Jiazheng Xu, Lei Hou, Yuxiao Dong, et al. Longbench v2: Towards deeper understanding and reasoning on realistic long-context multitasks. Proceedings of the 63rd Anmual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 3639-3664, 2025.
Zijian Chen, Xueguang Ma, Shengyao Zhuang, Ping Nic, Kai Zou, Andrew Liu, Joshua Green, Kshama Patel, Ruoxi Meng, Mingyi Su, et al. Browsecomp- A more fair and transparent evaluation benchmark of deep-research agent. arXiv preprint 25Xx:22508.06000 2025.
Yunfan Gao, Yun Xiong, Xinyu Gao, Kangxiang Jia, Jinliu Pan, Yuxi Bi, Yi Dai, Jiawei Sun, Meng Wang, and Haofen Wang. Retrieval-augmmented generation for large language models: survey, 2024.
Cheng-Ping Hsich, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, and Boris Ginsburg. RULER: What's the real context size of your long-context language models? In First Conference on Language Modeling. 2024. URL /ttp:s::///peeeevi.e. www. forum? Id=kIoBbc76Sy
Andrej Karpathy. Context engineering is the delicate art and science of filling the context window... com www.ccoo//aaaa http:////....loaattt//ttt/////// lan June 2025.
Accessed: 2025-06-25.
Tomáš Kočiský, Jonathan Schwarz, Phil Blunsom, Chris Dyer, Karl Moritz Hermann, Gábor Melis, and Edward Grefenstette. The narrativeqa reading comprehension challenge. Transactions the Association for Computational Linguistics, 6:317-328, 2018.
Kuang Kuang-Huei Lee, Xinyun Chen, Hiroki Furuta, John Canny, and Ian Fischer. A human-inm -imaa-inspired reading agent with gist memory of very long contexts. In Proceedings of the 41st International Conference Machine Learning, pp. 66396-26415 2024.

---

Published as a conference paper at ICLR 2026
Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented genera- tion for knowledge-intensinn nlp tasks. Advances in Neural Information Processing Systems, 33: 9459-9474, 2020.
Huayang Li, Pat Verga, Priyanka Sen, Bowen Yang, Vijay Viswanathan, Patrick Lewis, Taro Watanabe, and Yixuan Su. ALR?: A retrieve-then-reason framework for long-context question answering. 2024.
Xiaoxi Li, Guanting Dong, Jiajie Jin, Yuyao Zhang, Yujia Zhou, Yutao Zhu, Peitian Zhang, and Zhicheng Dou. Search-ol: Agentic search-enhanced large reasoning models, 2025a.
Zhiyu Li, Shichao Song, Hanyu Wang. Simin Niu, Ding Chen, Jiawei Yang. Chenyang Xi, Huayi
Lai, Jihao Zhao, Yezhaohui Wang, Junpeng Ren, Zehao Lin, Jiahao Huo, Tianyi Chen, Kai Chen, Kehang Li, Zhiqiang Yin, Qingchen Yu, Bo Tang, Hongkang Yang, Zhi-Qin John Xu, and Feiyu Xiong. Memos: An operating system for memory generation (mag) in large language models, 2025b. URL httpps//aaax....rrraaa//////////
22101
Charles Packer, Sarah Wooders, Kevin Lin, Vivian Fang, Shishir G. Patil, Ion Stoica, and Joseph E. Gonzalez. Memgpt: Towards Ilms as operating systems, 2024. URL https::/arxiv..
abs/2310. 08560
Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. Yar:: Efficient context window extension of large language models. arXiv preprint wrXiv223990007// 2023.
Weiwei Sun, Miao Lu, Zhan Ling, Kang Liu, Xuesong Yao, Yiming Yang, and Jiecao Chen. Scaling long-horizon I1m agent via context-folding. arXiv preprint arXiv:2510.11967 2025a.
Weiwei Sun, Miao Lu, Zhan Ling. Kang Liu, Xuesong Yao, Yiming Yang, and Jiecao Chen. Scaling long-horizon IIm agent via context-folding, 2025b. URL
11967
Cunxiang Wang, Ruoxi Ning, Boqi Pan, Tonghui Wu, Qipeng Guo, Cheng Deng, Guangsheng Bao, Xi- angkun Hu, Zheng Zhang, Qian Wang, and Yue Zhang. NovelQA: Benchmarking question answer- ing on documents exceeding 200k tokens. In The Thirteenth International Conference on Learning Representations, 2025. URL htttt:t/
net for::m/ormmmm d=uMEsKF 2o B7J
Di Wu, Hongwei Wang, Wenhao Yu, Yuwei Zhang, Kai- Kei Chang, and Dong Yu. Longmemeval: Benchmarking chat assistants on long-term interactive memory. arXiv preprint arXiv:2410.10813, 2024.
Xixi Wu, Kuan Li, Yida Zhao, Liwen Zhang, Litu Ou, Huifeng Yin, Zhongwang Zhang, Xinmiao Yu, Dingehu Zhang, Yong Jiang, Pengjun Xie, Fei Huang, Minhao Cheng, Shuai Wang. Hong Cheng, and Jingren Zhou. Resum: Unlocking long-horizon search intelligence via context summarization, 2025. URL wtt.tttss//// arxiv wwwp:ii..rgg/aaaa abs ab399./.2290133333
Sikuan Yan, Xiufeng Yang, Zuchao Huang, Ercong Nie, Zifeng Ding, Zonggen Li, Xiaowen Ma, Hinrich Schütze, Volker Tresp, and Yunpu Ma. Memory-rl: Enhancing large language model agents to manage and utilize memories via reinforcement learning, 2025. Utt peattps://arxiv
brg/abs/2508.. 19828
An Yang, Anfeng Li, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chang Gao, Chengen Huang, Chenxu Lv, et al. Qwen3 technical report. arXiv preprint 098508250 2025.
Hongli Yu, Tinghong Chen, Jiangtao Feng, Jiangjie Chen, Weinan Dai, Qiying Yu, Ya-Qin Zhang, Wei-Ying Ma, Jingjing Liu, Mingxuan Wang, and Hao Zhou. Memagent: Reshaping long-context Il with multi-cony rl-based memory agent, 2025. URL httphhtpp:/aaaa
org/ atwggb//////0/g
02259
Xinrong Zhang, Yingfa Chen, Shengding Hu, Zihang Xu, Junhao Chen, Moo Khai Hao, Xu Han, Zhen Leng Thai, Shuo Wang, Zhiyuan Liu, et al. oo bench: Extending long context evaluation beyond 100k tokens. arXiv preprint arXiv:2402. 13718, 2024.
12

---

Published as a conference paper at ICLR 2026
THE USE OF LARGE LANGUAGE MODELS
Large language models (LLMs) were applied in restricted manner to support writing refinement. The authors supplied their draft text the LLM, which suggested enhancements such grammatical corrections, clearer formulations, and the elimination of informal expressions. LLMs were addition- ally consulted to generate possible paper titles. While the model proposed alternatives, the final title was independently selected and refined by the authors, and was not adopted verbatim from any single model output. Furthermore, LLMs were employed as auxiliary coding tools during implementation. They provided code completions and debugging advice; however, all final code, experimental setup, and validation were designed, implemented, and confirmed by the authors. phasize that LLMs WERE NOT utilized for developing research ideas, designing experiments, or conducting literature review. All conceptual advances and experimental methodologies were entirely conceived and executed by the authors.
important to em-
A TRAINING DATASET CONSTRUCTION
Source
Questions
Trajs
Outcome Filter
Process Filter
Samples
Action Balancing
NovelQA
3096
3291
2322
2256
46180
35737
NarrativeQA
100
83
8
634
Total
3196
3374
2330
2264
468
35737
Table 5: SFT Dataset statistics by filtering stages.
Source
Questions
Type
Split
488
Open-Ended (127), MCQ (361)
Train
LongBench v2
15
Open-Ended (1), MCQ (14)
Validation
Table 6: RL Dataset statistics.
For LongBench v2 data used in reinforcement learning, we convert a subset multiple-choice questions into open-ended questions by removing the original option lists, which help to diversify the problem type. The transfcrability the question is determined by an LLM- judge, which instantiate gpt-oss- 120b, based whether the correct answer remains unique, verifiable, and unambiguous.
B TRAINING CONFIGURATIONS
For Supervised Fine-tuning (SFT), each model was trained on two machines, each equipped with H20 GPUs. The training configurations are specified in the table below.
Table 7: SFT Training Configuration
Parameter
Value
Global Batch Size
128 cosine
Learning Rate Scheduler
Learning Rate
1 x 10-5
Warm-up Ratio
3 x 10-2
Max Sequence Length
28000
Epochs
(14B), 4 (4B, 8B)
Parallelism Strategy
DeepSpeed ZeRO-3
For reinforcement learning (RL) training. we use the GRPO algorithm with rollout batch size of 32 and rollout number of 8. We enable KI. loss and set the KI. coefficient 0.001. The number of
13

---

Published as a conference paper at ICLR 2026
samples for each rollout trajectory is set to for the 8B model and 2 for the 14B model. Models trained for 32 steps to obtain the StateLM-RL. variants.
C EVALUATION CONFIGURATIONS
C.I GENERATION
In our experiments, we use the Qwen3 non-thinking mode for both StateLMs and instruct base- lines. We exclude the thinking mode because requires a 32K output space each step, which computationally expensive and reduces the available context window.
For both M and instruct baselines, we adopt the recommended sampling parameters as docu- mented in the Qwen3 official guide. Detailed configurations are reported in Table g below:
Table 8: Generation Configuration
Parameter
Value
Method
Temperature
0.7
Both
Top-p
0.8
Both
Top_k
20
Both
Max Output Tokens
8000
Instruct
Max Context Tokens
120000
Instruct
Context Budget
32000
StateLM
Round Budget
150
StateLM
Max Rounds
200
StateLM
This configuration used for most evaluations, except for the BrowseComp- subset. For this benchmark, we follow the official configuration obtain the Qwen3 results, detailed in the official repository! In this setting, Qwen3 instruct models are augmented with a search tool based on the BM25 algorithm, which is the same algorithm used in StateLM's search tool.
C.2 GRADING
For long-document QA tasks with multiple-choice questions, adapted from the implementation of (Zhang et al., (2024). Additionally, we observe that MemAgent models often output the option content without the corresponding option letter in multiple-choice questions; to reflect their best achievable performance, we adapt our grading script to treat such responses as correct. For LongMemBval and BrowseComp- we follow the official evaluation guidelines and use LLM-based judge to assess answer correctness, with GPT-4o as the judge model.
rule-based grading script
For the reward module in RL training, we adopt two-layer design: multiple-choice questions are evaluated using a rule-based grading script, and open-ended questions are evaluated with an LLM-based judge. In the experiment, the judge model is set gpt-oss- 120b, and the grading prompt shown in Figure
D TOOL USE ANALYSIS
In this section, we report tool-use statisties for StateLM-4B and StateLM-8B, which complement the analysis presented in Section 5.1
14

---

Published as a conference paper at ICLR 2026
Table Tool-use pattern of StateLM-4B across benchmarks. Mean input length each benchmark is reported.
Rounds
mem
del
srh
NovelQA (119K)
19.5
4.4
6.5
2.3
xcBench (189K)
21.4
4.6
6.6
3.9
Long (115K)
24.5
5.3
8.3
3.5
BrowseCompt (552K)
21.9
3.4
5.4
7.2
Table 10: Tool-use pattern of StateL.M-8B across benchmarks. Mean input length of each benchmark reported.
Rounds
mem
del
srh
NovelQA (119K)
19.6
4.5
6.6
2.2
ocBenc (189K)
21.0
4.3
6.3
4.2
Lona (115K)
24.5
5.6
8.9
2.3
BrowseComp+ (552K)
22.5
3.8
5.2
7.9
E ERROR ANALYSIS
To better understand the failure modes of StateLM, we conduct qualitative error analysis by manually inspecting incorrect trajectories across the evaluation benchmarks, and the major failure modes are summarized as follows:
Search Constraints. or paraphrased queries due to limited semantic coverage.
The current BM25-based keyword retrieval often misses evidence for implicit
Formatting Errors. small fraction failures arise from malformed tool calls, particularly in long-horizon trajectories and smaller models.
Context Window. Deleted content is replaced by lightweight stubs, which can still accumulate over long trajectories and gradually consume context budget. In addition, untimely or overly conservative deletions may cause transient context overflow before pruning takes effect.
These failure modes suggest several promising directions for Statel.M improvement, including larger management windows, more advanced search algorithm, and more high-quality on long-horizon training trajectories, which we leave for future work.
F PROMPTS
Prompt
You are an Al assistant for long-context processing with tools. Produce factually correct answers grounded in any attached text while conserving the context window by deleting unnecessary messages and taking notes. Describe your processing plan first, then proceed with the tools.
Figure 7: System prompt used training and inference of our StateLMs.
15

---

Published as a conference paper at ICLR 2026
Prompt
Given problem, its correct answer, and student's answer below, your task is to review the student's 's answer and determine it is correct by comparing it to the correct answer. If the student's answer incomplete or ambiguous, assume it is incorrect.
### Problem }problem}
### Answer
(answer)
### Student Answer {mode_ans
Please put your final answer (True False) in \[boxed{]. Specifically, if the student's answer is correct, the final answer should be (Tue):: otherwise, the final answer should be (axxedFallse..
Figure 8: Prompt template used by LLM Judge for Open-Ended questions.
Prompt
You are an AI assistant specialized in processing long-context tasks with tools. Produce factually accurate answers grounded in the provided context while minimizing context consumption.
Processing Strategy:
1. Check the size of the attached text:
Lonng (> 8K tokens): build an index and process in chunks. For extremely long texts, increase the chunk size up 12,000 tokens.
Short (< 8K tokens): load the full text and answer directly.
Empty: proceed with reasoming, using note-taking tools.
2. Analyze user's ss query and justify which processing mode is required to answer reliably and
state that you plan to use that mode explicitly.
(a) Linear scan: Full-passage, sequential chunk-by-chunn reading (no details skipped), or
(b) Keyword search: Keyword- search to retrieve and inspect only the relevant
chunks.
While reading, record relevant, accurate, and verifiable notes. Merge related notes as they grow to keep them concise.
Delete unnecessary context messages by their 'msg id' to preserve context space, but do not delete everything overuse the deletion tool. Deleted messages become stubs-do NOT restate their contents. Two required cases for deletions:
After calling 'readChunk': once you have analyzed the chunk and optionally taken notes, immediately delete the chunk content using the 'msg id' returned by the 'readChunk' tool. After calling 'note': delete the invoking assistant message using the 'msg id(invoking assistant)' returned by the 'note" tool result so the note-construction message cleared.
5. Consult your notes and use relevant evidence to answer the user's query.
Call 'udeeeBudget' regularly to monitor usage and prevent overflows; adjust your strategy accordingly.
Describe your reasoning and processing plan before invoking any tools.
Figure 9: System prompt for the Qwen3-Agentic models.
16


Reviews:
[{"review_id": "pQ56bGnGwK", "reviewer": "Reviewer_vbKg", "summary": "Stateful Language Models (StateLM or SLM) is a class of foundation models that are equipped with tools (including: dynamic indexing, context pruning, note taking) to manipulate their state in a reasoning loop which dynamically (and automatically) updates their context. A StateLM (i) can retrieve a needle in 1 million-token haystack (ii) in empirical results over practical QA benchmarks it performs better than strong instruct baselines using a fourth of their active context and (iii) is superior in learning to manage memory than agent-like prompting.\n\nSLM's reasoning trajectory consists of a series of actions (thoughts and acts (tool invocations)) and states (optionally modified contexts and responses from tools): tools can do tasks like analyze text, summarize or search through it or even update (e.g. delete) context. SLM is trained over trajectories for handling questions of types involving either locating or understanding text (search or scan types): each trajectory consists of steps (training samples) where given the history up to some step, SLM is trained to predict next step's thought and action. Interestingly, SLM's performance cannot be matched by models that have access to tools and are prompted to follow the context management process in SLM.", "questions": "- Are there any thoughts for automatically building the set of tools most amenable to particular question types?\n\n- Can the succession of the particular tools invoked drive the classification of questions answered into finer-grained classes?", "limitations": "", "rating": 8, "confidence": 3, "soundness": 3, "presentation": 4, "contribution": 4, "strengths": "- This is a simple and novel idea: the model becomes active, inspects its current memory/state and accordingly constructs the context to operate on using pre-defined tools.\n\n- No pressing need for the user-in-the-middle role of building prompts conditioned on a manually inspected state (automation).\n\n- Clean guidelines for training, set of orthogonal tools well-defined.\n\n- Performance on long-context recall and QA benchmarks are impressive.", "weaknesses": "- Critical requirement for the availability of a strong LLM for the generation of training samples (in particular for process-mode classification)\n- The set of tools is given, is generic enough but it certainly cannot fit any question handling.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "dr6SiUGOMV", "reviewer": "Reviewer_qeFc", "summary": "This paper presents StateLM, a stateful, memory-augmented LLM agent supervisedly trained to\nautonomously manage its own context through a (predefined) set of tools. Instead of relying on a\nhuman-defined workflow, the model learns, via SFT on author-curated reasoning trajectories, to\ndecide when to perform indexing, note-taking, searching, and pruning. Experiments on long-\ncontext QA benchmarks, compared with Qwen3-Instruct models, demonstrate substantial gains\nin both efficiency and scalability.", "questions": "5. What are the specific requirements for the “high-quality, good-behavior, expert\nreasoning trajectories”?\n6. Since the generation of expert reasoning trajectories is effectively a distillation\nprocess from Claude-Sonnet-4, it would be informative to include Claude-Sonnet-4’s\nown performance as a baseline in the Experimental section.", "limitations": "", "rating": 4, "confidence": 3, "soundness": 3, "presentation": 3, "contribution": 2, "strengths": "● The problem addressed in this paper is crucial: transitioning from stateless LLMs to a\nstateful paradigm enables long-term reasoning, multi-turn dialogue memory, and\ncross-session continuity.\n● The paper is well-written, and the case study in Section 3 provides an intuitive and\neffective way to illustrate the Pensieve paradigm.\n● The “model as the wizard” framing, i.e., pushing the model toward fully autonomous\ndecision-making about when (and, potentially in future work, how) to manage its own\ncontext, is an appealing selling point that makes the work conceptually engaging.\nHowever, as discussed below in the weaknesses, it remains to be seen whether this\nsetting can match the performance of prior semi-automated workflows.", "weaknesses": "1. The paper aims at a meaningful goal of achieving a fully automated workflow, since\nheuristic and human-defined pipelines may not fully unlock the capability of LLMs.\nHowever, the framework still relies on manually defined tools, making it essentially\nsemi-automated. Given that prior work (e.g., Memory-R1) also trains models to learn\nwhat memory operations to perform, the main difference here seems to lie in when\nthose operations are triggered. Memory-R1 updates memory after each turn, which is\na natural and reasonable design, while this work lets the model decide the timing in\nan end-to-end way.\n○ The point is that whether this flexibility is actually an advantage is not obvious. \nI would like to see stronger empirical evidence, for\nexample, the proposed method triggers memory operations much less\nfrequently and therefore achieves higher efficiency, better utility, or broader\ngeneralization across question types/domains to justify this design choice.\n2. **Limited benchmark and model scope:** Evaluation is conducted only on a single\nbase model (Qwen3-Instruct) and two document-based QA datasets (NovelQA and\ninfiniteBench En.MC split). Broader long-term or multi-session benchmarks such as\nLoCoMo, MSC, LongMemEval, or RULER (not necessarily all) should be included to\ntest richer memory behaviors.\n3. **Lack of scalability and generalization tests:** The model is trained on the\n*PublicDomain* split of NovelQA and mainly evaluated on the *Copyright* split. In\nTable 3, its gains diminish on $\\infty$Bench, particularly for larger backbones (e.g.,\nQwen3-8B). Additional experiments on cross-domain or OOD settings are needed to\nassess the proposed method’s applicability, especially given its reliance on formatted\ntraining.\n4. **Missing baselines:**\n○ Since the method equips the LLM with external memory, a fair comparison\nshould include the same base model with (i) direct function-call memory\naccess and (ii) MCP-based memory access (e.g.,\nhttps://github.com/doobidoo/mcp-memory-service), to see whether the base\nmodel (without SFT on reasoning traces) can already use memory when\ngiven access, and how much extra benefit the proposed framework actually\nprovides.\n○ Comparisons with prior memory-management methods, whether retrieval-\naugmented (RAG) or agent-based methods such as those evaluated in Mem0\nand Memory-R1, are necessary; For cost reasons, even a direct evaluation\nwithin their setups would make the results more informative.", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "xFlDZ1tmXK", "reviewer": "Reviewer_GVg6", "summary": "Pensieve/StateLM reframes long-context modeling as learned memory management. The LLM executes a tool-use loop ( e.g., analyzeText, buildIndex, searchEngine) to construct and prune its own working context rather than passively consuming a fixed window. StateLM is trained on Claude Sonnet 4–generated trajectories filtered for outcome and behavior on NovelQA and NarrativeQA. On Needle-in-a-Haystack (NIAH), StateLM outperforms Qwen-3 instruct baselines (4B/8B). On NovelQA and InfiniteBench, a 32K-context StateLM surpasses a 128K instruct baseline and shows scaling trends with higher inference-time compute. A prompt-only agent underperforms StateLM, supporting the claim that these behaviors should be learned, not merely prompted.", "questions": "1. Do you report a baseline using Qwen3 + MCP tooling for different tasks? Since Qwen3 family natively support building AI agents with MCP protocols, the prompt-only ablation may underserve tool use capability of instruct model.\n2. Do you provide error analysis for NIAH, NovelQA, and InfiniteBench for both StateLM and baselines (instruct and prompt-based)?\n3. What is the impact of each tool (e.g., removing deleteContext) on accuracy? Can you provide further ablation analysis?", "limitations": "", "rating": 4, "confidence": 4, "soundness": 3, "presentation": 3, "contribution": 2, "strengths": "- The data curation pipeline is carefully designed. multi-stage filtering and process-mode classification (search vs. scan) produce cleaner trajectories for training.\n- SLM w/o search greatly outperforms baseline by a large margin especially after 256K tokens.\n- On real-world tasks like NovelQA and InfiniteBench, the results are impressive where SLM with short context (32K) can achieve better performance than instruct model with context of 128K token\n- Good writing. The description of StateLM and experiments are clear and easy to follow.", "weaknesses": "- It is not clear how StateLM materially differs from prior work (e.g., A-Mem, SCM, Dynamic Cheatsheet). The claim of “not a fixed workflow loop” does not really establish novelty, as this function has been supported by agentic toolkit like Anthropic’s Model Context Protocol (MCP) and also has been explored by prior work.\n- The training trajectories come from Sonnet-4, which along with many open-source agents already can decide which tools to use given context. As presented, the contribution is largely policy learning over a fixed toolset (index/search/read/note/delete), rather than a new memory paradigm.\n- Ablations are limited: comparisons are mainly against a prompt-only baseline. There are no per-tool ablations (e.g., removing deleteContext) and no robustness analysis under noisy/failed tool calls.\n- All results are based on only two models Qwen3 4B/8B of the same family. It is not clear if it generalizes well to other families.\n- StateLM appears to use substantially more inference-time interaction/compute than single-pass baselines, making the comparison potentially not apples-to-apples.\n\nReferences:\n\n```\n@article{wang2024openhands,\n  title={Openhands: An open platform for ai software developers as generalist agents},\n  author={Wang, Xingyao and Li, Boxuan and Song, Yufan and Xu, Frank F and Tang, Xiangru and Zhuge, Mingchen and Pan, Jiayi and Song, Yueqi and Li, Bowen and Singh, Jaskirat and others},\n  journal={arXiv preprint arXiv:2407.16741},\n  year={2024}\n}\n```\n\n```\n@article{xu2025mem,\n  title={A-mem: Agentic memory for llm agents},\n  author={Xu, Wujiang and Mei, Kai and Gao, Hang and Tan, Juntao and Liang, Zujie and Zhang, Yongfeng},\n  journal={arXiv preprint arXiv:2502.12110},\n  year={2025}\n}\n```\n\n```\n@article{yu2025memagent,\n  title={MemAgent: Reshaping Long-Context LLM with Multi-Conv RL-based Memory Agent},\n  author={Yu, Hongli and Chen, Tinghong and Feng, Jiangtao and Chen, Jiangjie and Dai, Weinan and Yu, Qiying and Zhang, Ya-Qin and Ma, Wei-Ying and Liu, Jingjing and Wang, Mingxuan and others},\n  journal={arXiv preprint arXiv:2507.02259},\n  year={2025}\n}\n```\n\n```\n@article{wang2023enhancing,\n  title={Enhancing large language model with self-controlled memory framework},\n  author={Wang, Bing and Liang, Xinnian and Yang, Jian and Huang, Hui and Wu, Shuangzhi and Wu, Peihao and Lu, Lu and Ma, Zejun and Li, Zhoujun},\n  journal={arXiv preprint arXiv:2304.13343},\n  year={2023}\n}\n```", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}, {"review_id": "8W9BCOmgZN", "reviewer": "Reviewer_xaus", "summary": "The paper introduces **The Pensieve Paradigm**, a framework that equips an LLM with tools to dynamically manage its own context and reasoning process. The proposed system, called **StateLM**, allows the model to actively construct, prune, and update its working memory through operations such as dynamic indexing, note-taking, and context deletion. This enables it to go beyond the predefined context length and handle extremely long sequences efficiently.\n\nThe authors propose a data generation pipeline, and employ SFT to train models from the Qwen3 family. Empirical results show that StateLM achieves strong performance in both synthetic and real-world tasks, consistently outperforming the baselines, while using only a fraction of the context length.", "questions": "- In Figure 5, why does the inference time of  Qwen3-8B (baseline) decrease as the context length increases? Is it due to truncation?", "limitations": "", "rating": 6, "confidence": 4, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "- The paper is well written, and the main ideas are presented clearly.\n- I believe that the problem that the authors tackle is both interesting, and useful, particularly in the context of agentic systems. In many cases, agents are required to handle huge contexts (for instance large code repos); therefore, the proposed paradigm could be leveraged to both improve the performance and make agentic systems more efficient.\n- The paper has solid amount of empirical results that showcase the strength of the proposed method, covering both synthetic and real-world settings.", "weaknesses": "- As the authors also mention, the current set of tools is predefined and fixed. While this appears sufficient for the evaluated tasks (Needle-in-a-Haystack and Long Document QA), it may prove inadequate in more complex or dynamic scenarios\n- In Section 4.1, I think that the comparison with the baseline may not be entirely fair. The high accuracy achieved by the proposed approach on extremely long contexts is indeed interesting;  however, the poor performance of the baseline models in the cases where the context length is exceeded is not surprising. Perhaps, a better baseline could be to use a simple sliding window approach, where the size of the window is close to the context size of the model.\n- Although the authors note this as well, I believe that testing RL approaches would be reasonable in this setting, since there has been evidence that RL works well in similar settings(e.g [1]). \n\n[1] Feng, Jiazhan, et al. \"Retool: Reinforcement learning for strategic tool use in llms.\" arXiv preprint arXiv:2504.11536 (2025).", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "", "claims_and_evidence": "", "methods_and_evaluation_criteria": "", "theoretical_claims": "", "experimental_designs_or_analyses": "", "relation_to_broader_scientific_literature": "", "essential_references_not_discussed": "", "other_strengths_and_weaknesses": "", "other_comments_or_suggestions": "", "questions_for_authors": "", "summary_of_paper": "", "summary_of_recommendation": "", "technical_quality": "", "clarity_of_presentation": "", "potential_impact": "", "robotics_focus": "", "quality_of_limitations": "", "questions_for_rebuttal": "", "reasons_to_accept": "", "reasons_to_reject": "", "questions_to_authors": "", "extra_scores": {}}]

Author rebuttal:

Decision: Accept (Poster)