工具无需以文本表达:面向智能体的潜在上下文压缩
研究论文 · 2026/11/07
大型语言模型(LLM)智能体通常将原始工具输出附加到上下文中,导致多步交互中上下文开销大且注意力分散。现有方法受限于离散文本表示,压缩率有限。本文提出Coca-Cola,一种连续潜在上下文压缩模型,将工具观察压缩为潜在令牌并嵌入智能体输入嵌入空间,并引入动作保持训练,使智能体在完整和压缩观察下的下一动作分布对齐,从而学习保留决策关键信息的潜在令牌。在四个QA基准和两个模型家族上的实验表明,Coca-Cola将令牌消耗降低70.01%-89.24%,端到端运行时间减少24.45%-55.97%,同时持续提升任务性能。
该研究挑战了智能体必须使用文本工具输出的传统假设,提出连续潜在压缩方法,在显著降低计算开销的同时提升任务性能,为高效LLM智能体设计提供了新思路。
Large language model (LLM) agents typically append raw tool outputs to their context. Over multi-step interactions, long and noisy observations incur substantial context overhead and dilute the agent's attention to task-relevant information. Existing token pruning and summarization methods remain constrained by discrete text representations, limiting the achievable compression ratios. In this work, we challenge the prevailing assumption that agents must consume tool observations as explicit text tokens. To this end, we propose Coca-Cola, a continuous latent context compression model for LLM agents. Coca-Cola compresses tool observations into latent tokens and embeds them into the input embedding space of the agent. We further introduce Action-Preserving Training, which aligns the agent's next-action distributions under full and compressed observations. This trains the compression model to learn action-sufficient latent tokens that retain decision-critical information. Experiments with web-search agents on four QA benchmarks and two model families show that Coca-Cola reduces the agent's token consumption by 70.01%-89.24% and end-to-end runtime by 24.45%-55.97%, while consistently improving task performance. These results suggest that Coca-Cola offers a promising approach for context compression in agents. Our code is available at https://github.com/THU-Agent/Coca-cola.