# ContextPilot：用细粒度强化学习教智能体主动管理上下文

- 来源：HuggingFace Daily Papers（社区热门论文）
- 发布时间：2026-08-28 08:00
- AIHOT 分数：46
- AIHOT 链接：https://aihot.virxact.com/items/cmtgmdkag0307roch8kw6xsag
- 原文链接：https://arxiv.org/abs/2608.28476

## AI 摘要

ContextPilot 提出一种面向长程智能体任务的主动上下文管理框架，通过扩充规划、长期记忆和软上下文卸载工具，并设计基于上下文与熵变化的细粒度 RL 方法，解决现有方法工具集受限、探索低效和信用分配粗糙的问题。在长上下文问答和深度搜索任务中，ContextPilot 以更紧凑的工作上下文取得更强性能，在多种基座模型和基准上持续优于现有基线。代码已开源。

## 正文

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 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.
