PEEK 解决了长上下文智能体在重复场景中反复“从头探索”的痛点,做文档分析或代码库维护的开发者可以直接用,能显著降低推理成本并提升准确率。
PEEK 是一种为长上下文 LLM 智能体设计的系统,通过缓存和维护“上下文地图”来提升其在重复外部上下文(如文档库、代码仓库)中的表现。现有方法要么保留智能体的轨迹、被动访问原始材料,要么保留任务级策略,但都忽略了可复用的方向知识(如上下文内容、组织方式、历史有用的实体和模式)。PEEK 通过三个模块(Distiller、Cartographer、Evictor)将推理信号转化为结构化、固定大小的上下文地图,并嵌入智能体提示中。实验显示,PEEK 在长上下文推理和信息聚合任务上比强基线提升 6.3-34.0%,同时减少 93-145 次迭代,成本比最先进的 ACE 框架低 1.7-5.8 倍。在上下文学习任务上,PEEK 的解决率和评分准确率分别提升 6.0-14.0% 和 7.8-12.1%,成本仅为 ACE 的 1.4 倍,且泛化到不同语言模型和智能体架构。
PEEK: Context Map as an Orientation Cache for Long-Context LLM Agents
Large language model (LLM) agents increasingly operate over long and recurring external contexts, like document corpora and code repositories. Across invocations, existing approaches preserve either the agent's trajectory, passive access to raw material, or task-level strategies. None of them preserves what we argue is most needed for repeated same-context workloads: reusable orientation knowledge (e.g., what the context contains, how it is organized, and which entities, constants, and schemas have historically been useful) about the recurring context itself. We introduce PEEK, a system that caches and maintains this orientation knowledge as a context map: a small, constant-sized artifact in the agent's prompt that gives it a persistent peek into the external context. The map is maintained by a programmable cache policy with three modules: a Distiller that extracts transferable knowledge from inference-time signals, a Cartographer that translates it into structured edits, and a priority-based Evictor that enforces a fixed token budget. On long-context reasoning and information aggregation, PEEK improves over strong baselines by 6.3-34.0% while using 93-145 fewer iterations and incurring 1.7-5.8x lower cost than the state-of-the-art prompt-learning framework, ACE. On context learning, PEEK improves solving rate and rubric accuracy by 6.0-14.0% and 7.8-12.1%, respectively, at 1.4x lower cost than ACE. These gains generalize across LMs and agent architectures, including OpenAI Codex, a production-grade coding agent. Together, these results show that a context map helps long-context LLM agents interact with recurring external contexts more accurately and efficiently.