ContextPilot teaches agents proactive context management via RL

ContextPilot teaches agents proactive context management via RL

Long-horizon agentic tasks force large language models to repeatedly retrieve, integrate and hold onto information across many turns of interaction, and keeping the full interaction history makes the working context grow without bound. Recent proactive context management methods let models edit their own working context using dedicated tools, but the authors identify three key limitations in this line of work: the toolset is limited to search, deletion and summarization, with no support for global planning, long-term memory or adaptive compression; exploration is inefficient because it treats all context management actions uniformly even though they have very different effects on the final outcome; and reinforcement learning training uses coarse-grained credit assignment, applying the same trajectory-level reward to every intermediate context-editing action.

To close these gaps, the authors introduce ContextPilot, a proactive context management framework for long-horizon agentic reasoning. It systematically expands the toolset with planning, long-term memory and soft context offloading tools, on top of the search, deletion and summarization tools used before. Alongside the new tools, the authors propose a reinforcement learning method built specifically for context management: it uses variation in context and entropy to identify the critical editing decisions worth branch sampling, then estimates action-level advantages from all the branched trajectories that pass through each corresponding context-editing action, rather than assigning one reward to the whole trajectory.

In experiments on long-context question answering and deep search tasks, ContextPilot achieves stronger performance with a more compact working context, consistently outperforming existing baselines across various base models and benchmarks. The authors have released the code on GitHub, at Tencent/ContextPilot.

Key facts

  • The authors identify three limitations in existing proactive context management methods: a toolset limited to search, deletion and summarization; uniform, inefficient exploration of context-editing actions; and coarse-grained RL credit assignment that gives every editing action the same trajectory-level reward.
  • ContextPilot expands the editing toolset with planning, long-term memory and soft context offloading tools.
  • Its RL method uses context and entropy variation to pick critical editing decisions for branch sampling, then estimates action-level advantages from the branched trajectories that pass through each editing action.
  • On long-context QA and deep search tasks, ContextPilot outperforms existing baselines across various base models and benchmarks while keeping a more compact working context.
  • The code is released on GitHub at Tencent/ContextPilot.

Why it matters

Agents that run for many turns, such as deep search or extended question-answering systems, accumulate interaction history that keeps growing unless something actively manages it. The authors argue existing proactive context management approaches fall short in three specific ways: their editing toolset is limited to search, deletion and summarization; they explore context-editing actions uniformly even though those actions affect outcomes very differently; and their RL training assigns the same trajectory-level reward to every context edit, which blurs which specific edits actually helped. ContextPilot is built to close all three gaps at once, by adding new editing tools and by giving the RL training a way to credit individual editing decisions rather than the trajectory as a whole.

Who it affects

The work targets researchers and engineers building long-horizon LLM agents, the kind that need to hold and manage context across many turns, such as deep search agents or long-context QA systems. It is a research contribution rather than a shipped product, so its immediate audience is people training or fine-tuning agents with reinforcement learning, not end users of an agent product.

How to use it

The authors have published the code for ContextPilot on GitHub, at Tencent/ContextPilot. The source does not state a release timeline for the code or the paper, so the current state of the repository is best checked directly.

How solid is it

The claims rest on experiments across long-context QA and deep search tasks, tested against existing baselines on multiple base models and benchmarks, with the authors reporting consistently stronger performance alongside a more compact working context. The available text does not give specific numbers such as accuracy scores or percentage improvements, and does not name the exact benchmarks or base models used beyond these two task categories, so the size of the gain cannot be quantified from the source alone.

Risks and caveats

The available text names three limitations in prior work and describes ContextPilot's fix for each, but it does not include author names or institutional affiliations, a release timeline for the code or paper, or concrete experimental figures. Readers who need those specifics, or want to verify the claimed gains, will need to check the GitHub repository and the full paper rather than relying on the abstract alone.