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

Zhuoshi Pan, Qizhi Pei, Junru Lu, Honglin Lin, H. Vicky Zhao +2 more
8/28/2026
4 citations
cs.CL
rl

Official code: Tencent/ContextPilot (146 stars, Python, last commit 2026-08-31).

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.

Show full abstract

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 editing decisions for branch sampling and estimates action-level advantages from all branched trajectories that pass through the corresponding context editing action. Experiments on long-context QA and deep search tasks show that ContextPilot achieves stronger performance with a more compact working context, consistently outperforming existing baselines across various base models and benchmarks. Code is available at https://github.com/Tencent/ContextPilot.

View on arXivView PDF

Code Implementations(1)

[EMNLP26] contextpilot: teaching agents for proactive context management via fine-grained rl

14613Python, ShellAug 26, 20263 months agoNOASSERTION

Similar Papers

Cite this paper

@article{pan2026contextpilot,
  title  = {ContextPilot: Teaching Agents for Proactive Context Management via Fine-grained RL},
  author = {Zhuoshi Pan and Qizhi Pei and Junru Lu and Honglin Lin and H. Vicky Zhao and Di Yin and Xing Sun},
  year   = {2026},
  eprint = {2608.28476},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2608.28476v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2608.28476.svg)](https://codeofpaper.com/paper/2608.28476)

Discussion