ContextPilot: Teaching Agents for Proactive Context Management via Fine-grained RL

Zhuoshi Pan, Qizhi Pei, Junru Lu, Honglin Lin, H. Vicky Zhao, di Yin, Xing Sun


Abstract
Long-horizon agentic tasks require large language models (LLMs) to iteratively retrieve, integrate, and maintain dispersed information across multi-turn interactions, but preserving all interaction histories leads to a continuously growing working context. Recent proactive context management methods allow models to edit their own working context with specialized tools, yet they still face **three key limitations**: (1) a *limited toolset* restricted to search, deletion, and summarization, with no support for global planning, long-term memory, and adaptive compression; (2) *inefficient exploration* that treats context management actions uniformly despite their heterogeneous impacts on final outcomes; and (3) *coarse-grained credit assignment* that assigns the final trajectory-level reward to all intermediate context editing actions during RL. To bridge these gaps, we introduce ***ContextPilot***, a proactive context management framework for long-horizon agentic reasoning. Our approach systematically augments the toolset with planning, long-term memory, and soft context offloading tools. We further propose an RL method tailored for context management, which uses context and entropy variation to identify critical context control actions for branch sampling and estimates action-level advantages from all branched trajectories that pass through these actions. Experiments on long-context QA and deep search tasks show that ***ContextPilot*** achieves stronger performance with a more compact working context, outperforming existing baselines across various base models and benchmarks.
Anthology ID:
2026.emnlp-main.299
Volume:
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
EMNLP
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
6886–6903
Language:
URL:
https://aclanthology.org/2026.emnlp-main.299/
DOI:
Bibkey:
Cite (ACL):
Zhuoshi Pan, Qizhi Pei, Junru Lu, Honglin Lin, H. Vicky Zhao, di Yin, and Xing Sun. 2026. ContextPilot: Teaching Agents for Proactive Context Management via Fine-grained RL. In Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing, pages 6886–6903, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
ContextPilot: Teaching Agents for Proactive Context Management via Fine-grained RL (Pan et al., EMNLP 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.emnlp-main.299.pdf