ACON: Optimizing Context Compression for Long-horizon LLM Agents
MemoryContext CompressionAgentDistillationICML 2026KAIST微软剑桥大学https://github.com/microsoft/acon
原文采用 CC BY 4.0 许可;本页依据 v3 添加中文翻译并调整排版。
ACON:面向长程大语言模型智能体的上下文压缩优化
Abstract
Large language models (LLMs) are increasingly deployed as agents in dynamic real-world environments, where success depends on maintaining precise records of actions and observations. However, the resulting unbounded context growth in long-horizon agentic tasks makes two critical bottlenecks: prohibitive inference memory costs and reasoning degradation due to irrelevant information. Existing compression methods fail to fully address this, often relying on brittle heuristics or requiring parameter updates impractical for proprietary or large-scale LLMs. We introduce Agent Context Optimization (ACON), a unified framework that optimally compresses both observations and history into concise, informative representations. Distinct from prior works, ACON employs an optimization in natural language space: it iteratively refines compression guidelines based on failure analysis of the agent, ensuring critical state information is preserved without model fine-tuning.
大语言模型(LLM)正日益作为智能体部署在动态的现实环境中,而任务能否成功取决于是否能准确记录动作与观测。 然而,在长程智能体任务中,由此带来的上下文无限增长造成了两个关键瓶颈:高昂的推理内存成本,以及无关信息导致的推理能力下降。 现有压缩方法未能充分解决这一问题,它们往往依赖脆弱的启发式规则,或需要更新模型参数,而这对闭源或大规模 LLM 并不现实。 我们提出 智能体上下文优化(Agent Context Optimization,ACON),这是一个统一框架,可对观测与历史进行优化压缩,将其转化为简洁且信息丰富的表示。 与以往工作不同,ACON 在自然语言空间中进行优化:它基于对智能体失败原因的分析,迭代改进压缩准则,无需微调模型即可确保关键状态信息得到保留。
To further minimize computational overhead, we distill the optimized compressor into smaller models. Experiments on AppWorld, OfficeBench, and Multi-objective QA demonstrate that ACON reduces peak token usage by 26–54% while improving task success over existing compression baselines. Notably, it enables smaller LMs to function effectively as long-horizon agents, achieving up to 46% performance improvement by mitigating context distraction. Our code is available at https://github.com/microsoft/acon.
为进一步降低计算开销,我们将优化后的压缩器蒸馏到更小的模型中。 在 AppWorld、OfficeBench 和多目标问答上的实验表明,ACON 将峰值 token 用量减少了 26–54%,同时相较现有压缩基线提高了任务成功率。 尤其值得关注的是,它通过缓解上下文干扰,使较小的语言模型也能有效承担长程智能体任务,性能提升最高达到 46%。 代码已公开:https://github.com/microsoft/acon。
1. Introduction
Large language models (LLMs) have become the backbone of AI agents, enabling them to plan and act in dynamic environments. However, these tasks often unfold over extended horizons, requiring the agent to maintain a continuous record of observations, tool outputs, and evolving states. In such settings, context is not auxiliary but foundational; losing a single detail such as a file path or an API parameter can derail the entire workflow. As interactions accumulate, context grows unbounded as shown in Figure 2, making two major bottlenecks. First, the inference memory cost of transformers scales with context length, resulting long-horizon reasoning computationally prohibitive due to the massive KV cache requirements. Second, excessively long contexts dilute relevant information, distracting the model with outdated or extraneous details and degrading decision quality.
大语言模型(LLM)已成为 AI 智能体的核心,使其能够在动态环境中规划并采取行动。 然而,这些任务往往需要经过较长的交互过程,因此智能体必须持续记录观测、工具输出和不断变化的状态。 在这种场景下,上下文是基础,而非辅助信息;丢失文件路径或 API 参数等一个细节,都可能使整个工作流偏离预期。 随着交互不断累积,上下文会无限增长,如 图2 所示,并形成两个主要瓶颈。 首先,Transformer 的推理内存成本随上下文长度增长,庞大的 KV 缓存需求使长程推理的计算代价变得难以承受。 其次,过长的上下文会稀释相关信息,使模型受到过时或多余细节的干扰,从而降低决策质量。

图1:AppWorld 基准上的 准确率与峰值 token 数之间的权衡。我们比较历史压缩中的平均准确率与峰值 token 数。相较朴素提示词基线,ACON(本文方法)在大型模型(gpt-4.1)上减少 token 成本的同时保持准确率,在较小模型(Qwen-14B)上甚至提升了准确率。更多结果见 第 4 节。

图2:研究动机:LLM 智能体中无限增长的上下文。 持续交互使上下文不断增长,带来较高的内存用量(红线)。这说明了压缩的必要性,同时也提出了两个关键问题:如何优化压缩器,以及 如何降低其成本。ACON 通过 压缩准则优化 与 压缩器蒸馏 解决这些问题,在保留必要信息的同时有效降低峰值 token 数(蓝线)。
The challenge of managing this context is particularly critical in productivity scenarios, such as email management or workflow automation, where agents must coordinate across heterogeneous tools. Unlike simpler conversational tasks, these environments demand the preservation of diverse signal types: factual history, action-outcome relationships, success preconditions, and future decision cues. Naive strategies like token truncation or generic summarization are insufficient, as they easily discard these critical details essential for multi-step reasoning. Consequently, effective compression must balance aggressive reduction with the precise retention of task-relevant state information.
在邮件管理、工作流自动化等生产力场景中,智能体需要协调多种异构工具,因此上下文管理尤为关键。 不同于较简单的对话任务,这些环境要求保留多种类型的信号:事实历史、动作与结果之间的关系、成功所需的前置条件,以及未来决策线索。 token 截断或通用摘要等朴素策略并不足够,因为它们很容易丢弃多步推理所必需的关键细节。 因此,有效的压缩必须在大幅缩减上下文与准确保留任务相关状态信息之间取得平衡。
Existing compression approaches, however, fail to fully address these agent-specific needs. Dialogue-oriented systems focus on conversational coherence rather than state tracking, while document-centric methods assume single-step reasoning where context can be discarded after use. While recent agent-focused methods attempt to bridge this gap, they face significant limitations: heuristic-based approaches are often brittle and narrowly specialized, limiting their robustness. Meanwhile, model optimization-based approaches typically entangle compression with the agent model, making them difficult to apply directly to proprietary, API-based LLMs, where gradient-based updates to the underlying model are infeasible.
然而,现有压缩方法未能充分满足这些智能体特有的需求。 面向对话的系统关注对话连贯性,而非状态跟踪;面向文档的方法则假设只需单步推理,使用后的上下文即可丢弃。 虽然近期面向智能体的方法试图弥合这一差距,但仍存在明显局限:基于启发式规则的方法往往脆弱且高度专用,稳健性受到限制。 与此同时,基于模型优化的方法通常将压缩与智能体模型耦合在一起,难以直接用于通过 API 提供服务的闭源 LLM,因为无法对其底层模型进行梯度更新。
To address these challenges, we introduce Agent Context Optimization (ACON), a unified framework for optimizing the compression of both environment observations and interaction histories. Distinct from heuristic approaches that rely on static rules and model optimization-based methods that require model parameter updates, ACON introduces a compression guideline optimization directly in natural language space. This method refines compressor prompts through failure analysis ensuring that critical environment-specific signals are preserved after compression without altering the agent model weight. It makes ACON purely model-agnostic and directly applicable to agents based on proprietary, API-based LLMs.
为应对这些挑战,我们提出 智能体上下文优化(ACON),这是一个统一框架,用于优化环境观测与交互历史的压缩。 不同于依赖静态规则的启发式方法,以及需要更新模型参数的方法,ACON 直接在自然语言空间中进行 压缩准则优化。 这种方法通过失败分析改进压缩器提示词,确保压缩后仍保留环境特有的关键信号,而无需改变智能体模型的权重。 因此,ACON 完全独立于具体模型,可直接应用于基于闭源 API 型 LLM 的智能体。
ACON yields three key advantages over previous works. First, the guideline optimization enables environment-specific compression rules to be derived consistently across diverse agentic tasks, overcoming the brittleness of handcrafted heuristics. Second, by retaining essential information, optimally compressed contexts not only reduce memory costs but also improve decision quality, allowing smaller models to act more effectively by mitigating distraction. Third, we validate that these optimized compressors can be distilled into smaller models, demonstrating that the compression module itself can be deployed with minimal computational overhead.
与以往工作相比,ACON 具有三个关键优势。 第一,准则优化能够在多种智能体任务中稳定地推导出针对具体环境的压缩规则,克服手工启发式规则的脆弱性。 第二,通过保留必要信息,经过优化压缩的上下文不仅能降低内存成本,还能提升决策质量,减少干扰,从而让更小的模型更有效地行动。 第三,我们验证了这些优化后的压缩器能够被蒸馏到更小的模型中,表明压缩模块本身可以以很低的计算开销部署。
We validate ACON on three multi-step agent benchmarks: AppWorld, OfficeBench, and Multi-objective QA, each requiring 15+ interaction steps.
我们在三个多步智能体基准上验证 ACON:AppWorld、OfficeBench 和多目标问答,每个基准均需要 15 步以上的交互。
Our empirical results demonstrate clear advantages of ACON:
实验结果展示了 ACON 的明确优势:
- lowers peak token usage of agents by 26–54% while improving task success compared to existing compression baselines
- enables effective distillation of the context compressor into smaller models, preserving 95% of the teacher’s accuracy, thereby reducing the overhead of the compression
- allows small LMs to function more effectively as agents, improving performance by 32% on AppWorld, 20% on OfficeBench, and 46% on Multi-objective QA by mitigating the distraction of long contexts.
- 将智能体峰值 token 用量降低 26–54%,同时相较现有压缩基线提高任务成功率;
- 能够将上下文压缩器有效蒸馏到更小的模型中,保留教师模型 95% 的准确率,从而减少压缩开销;
- 通过缓解长上下文干扰,使小型语言模型更有效地充当智能体,在 AppWorld、OfficeBench 和多目标问答上的性能分别提升 32%、20% 和 46%。
Our result highlights on AppWorld benchmark are in Figure 1.
我们在 AppWorld 基准上的主要结果见 图1。
In summary, our work makes the following contributions:
我们的贡献概括如下:
- We propose Agent Context Optimization (ACON), a framework for optimizing compression of both environment observations and interaction histories, tailored to multi-step, long-horizon agentic tasks.
- We develop a failure-driven compression guideline optimization. This approach is model-agnostic, making it readily applicable to any LLM, including proprietary API-based models, without requiring weight updates.
- We enable cost-efficient deployment of optimized compressors by distilling them into smaller models, preserving over 95% of the teacher's performance while reducing the overhead of compression.
- We validate ACON on AppWorld, OfficeBench, and Multi-objective QA, showing that it reduces peak token usage by 26–54% while improving task success over existing compression baselines with LLMs, and enabling small LMs to achieve 20–46% performance improvements.
- 我们提出 智能体上下文优化(ACON),这是一个针对多步、长程智能体任务的框架,用于优化环境观测与交互历史的压缩。
- 我们开发了一种由失败驱动的压缩准则优化方法。该方法独立于具体模型,无需更新权重,即可方便地应用于任何 LLM,包括闭源 API 型模型。
- 我们通过将优化后的压缩器蒸馏到更小的模型中,实现低成本部署,在保留教师模型 95% 以上性能的同时减少压缩开销。
- 我们在 AppWorld、OfficeBench 和多目标问答上验证了 ACON,表明它能够将峰值 token 用量降低 26–54%,同时相较现有基于 LLM 的压缩基线提高任务成功率,并使小型语言模型获得 20–46% 的性能提升。
2. Related Works
Long-horizon LLM agents. Large language model (LLM) agents extend pretrained models beyond static single-step reasoning tasks (e.g., RAG-based QA, math problem solving, or code generation) to interactive decision-making in dynamic environments. Unlike chatbots or solvers that return an answer in one pass, agents must iteratively observe their surroundings, select tools, and execute actions while revising their plans based on feedback. Recent work highlights the importance of long-horizon LLM agents, which tackle tasks that unfold over dozens to hundreds of steps and require coordination across multiple applications and tools. A central challenge in these scenarios lies in managing the dynamic long context, where the agent must retain multi-step interaction histories and handle diverse observations produced by heterogeneous environments.
长程 LLM 智能体。 大语言模型(LLM)智能体将预训练模型从静态的单步推理任务(例如基于 RAG 的问答、数学求解或代码生成)扩展到动态环境中的交互式决策。 不同于一次就返回答案的聊天机器人或求解器,智能体必须反复观测环境、选择工具并执行动作,同时根据反馈修正规划。 近期研究凸显了 长程 LLM 智能体 的重要性:这类智能体处理需要数十至数百步才能完成的任务,并且需要协调多个应用程序与工具。 这些场景中的一个核心挑战是管理 动态长上下文:智能体必须保留多步交互历史,并处理异构环境产生的多样化观测。
Context compression for LLMs. Managing this ever-growing context has been a longstanding challenge, and a variety of approaches have been proposed to compress LLM inputs. Prior works on context compression can be broadly grouped into three directions: document- or retrieval-based compression, dialogue memory summarization, and low-level KV cache compression. While each line of research has demonstrated benefits in its respective setting, they remain insufficient for the dynamic and heterogeneous contexts required by long-horizon agents, where the relevance of information frequently shifts as the agent progresses.
LLM 的上下文压缩。 管理持续增长的上下文一直是一项挑战,已有多种方法被提出用于压缩 LLM 输入。 以往的上下文压缩工作大致可分为三个方向:基于文档或检索的压缩、对话记忆摘要,以及底层 KV 缓存压缩。 虽然各个研究方向都在相应场景中展现了优势,但对于长程智能体所需的动态、异构上下文,它们仍然不足,因为信息的相关性会随着智能体的任务推进而频繁变化。
Beyond general compression, several recent works have explored context compression specifically for LLM agents. However, these approaches either rely on naive prompting or target narrow domains, limiting their broader applicability. Another related line of works treats context compression as an agent action, employing reinforcement learning to optimize the model for both compression and agent action policy. However, such methods inherently update the model to couple reasoning with compression, typically requiring access to internal weights. In addition, ReSum shares the motivation of extending long-horizon agents through summarized contexts, but it optimizes the policy model to better utilize summaries.
除通用压缩之外,近期一些工作专门探索了 LLM 智能体的上下文压缩。 然而,这些方法要么依赖朴素提示词,要么面向狭窄领域,限制了其更广泛的适用性。 另一类相关工作将上下文压缩视为智能体动作,利用强化学习同时优化模型的压缩能力与智能体动作策略。 但这类方法本质上需要更新模型,将推理与压缩耦合在一起,通常要求能够访问内部权重。 此外,ReSum 同样希望通过摘要上下文拓展长程智能体的能力,但它优化的是策略模型,使其更好地利用摘要。
In contrast, we introduce a universal optimization framework for agent context compression that is applicable to any arbitrary LLMs. Our framework distinguishes itself by supporting both history and observation compression and providing a generalizable optimization process for the compression. Since our approach is entirely model-agnostic, it remains equally effective for both open-source models and proprietary API-based LLMs. A detailed analysis is provided in Appendix C.
相比之下, 我们提出了一种适用于任意 LLM 的通用智能体上下文压缩优化框架。 该框架的特点是同时支持历史压缩与观测压缩,并提供可泛化的压缩优化过程。 由于我们的方法完全 独立于具体模型,它对开源模型和闭源 API 型 LLM 都同样有效。 详细分析见 附录 C。
3. Agent Context Optimization (ACON)
We present Agent Context Optimization (ACON), a unified framework for optimized history and observation compression in long-horizon LLM agents. We begin by formulating the agent task and defining context cost in Section 3.1. Next, in Section 3.2, we introduce generative compression with LLMs for both history and observation, and formalize the associated optimization objective and its challenges. We then propose our optimization method in Section 3.3, followed by a distillation that enables smaller models for compressions to reduce the compression cost (Section 3.4).
3.1. Problem Formulation
Task. An agentic task is formulated as a Partially Observable Markov Decision Process (POMDP) finish_task).
任务。 智能体任务被形式化为一个部分可观测马尔可夫决策过程(POMDP)finish_task)时,就会到达终止状态。
An LLM agent interacts with the environment to get information for making a decision to achieve a given task
LLM 智能体通过多步与环境交互来获取决策所需的信息,以完成给定任务
where
其中,

图3:压缩准则优化。 通过对比未压缩上下文时的成功轨迹与压缩上下文后的失败轨迹来生成反馈,再由 LLM 利用收集到的反馈改进压缩准则。
Cost function for context. We assume that the LLM agent's parameters
上下文成本函数。 我们假设 LLM 智能体的参数
where
其中,
3.2. History & Observation Compression with LLMs
To address this challenge, we use an LLM
History compression. The interaction history accumulates both environment observations and agent actions. In long-horizon tasks, this history can grow excessively large. To manage its length, we apply history compression only when the length exceeds a predefined threshold
历史压缩。 交互历史会同时累积环境观测与智能体动作。 在长程任务中,历史可能增长得过于庞大。 为控制其长度,我们仅在历史长度超过预定义阈值
The compressed history
压缩后的历史
Latest observation compression. Given an action
最新观测压缩。 给定动作
This mechanism avoids unnecessary overhead when
当
In both cases, the compressor LLM selects information to preserve based on its learned prior knowledge of importance. However, there is no guarantee that the salient details required for successful task completion are retained. The agent context effectively serves as a world model of the environment, encompassing diverse forms of information such as causal relations (e.g., email leaves drafts), evolving states (e.g., account balance), preconditions (e.g., login required), and task-relevant decision cues (e.g., due dates). Effective context compression must therefore accommodate this heterogeneous and dynamic nature of agent context, ensuring that the most critical signals are preserved for long-horizon reasoning and task success.
在这两种情况下,压缩器 LLM 都依据其已学到的关于信息重要性的先验知识,选择要保留的信息。 然而,无法保证 成功完成任务所需的关键细节一定得到保留。 智能体上下文实际上充当了 环境的世界模型,涵盖多种信息形式,例如因果关系(如邮件会留下草稿)、变化中的状态(如账户余额)、前置条件(如需要登录),以及任务相关的决策线索(如截止日期)。 因此,有效的上下文压缩必须适应智能体上下文的异构性与动态性,确保保留对长程推理和任务成功最重要的信号。
Optimization objective. We optimize the compressor parameters
优化目标。 我们优化压缩器参数
With the agent
固定智能体
where
其中,
Challenges. The optimization objective in Equation (7) is difficult to optimize in practice because there is no gold supervision for compression, the reward is sparse and only revealed at the end of the trajectory, and the context cost is defined over discrete quantities, which precludes direct gradient computation.
挑战。 公式(7) 中的优化目标在实践中难以优化,因为压缩缺乏标准监督信号,奖励稀疏且仅在轨迹结束时才显现,而上下文成本又定义在离散量上,无法直接计算梯度。
While these properties naturally motivate reinforcement learning (RL), applying RL introduces additional obstacles:
这些性质自然会让人想到强化学习(RL),但应用 RL 又会带来额外障碍:
- updating the parameters
of a LLM with RL can be computationally prohibitive, - environment rollouts are extremely expensive since each reward requires multi-step executions of both agent and compressor, and
- policy gradient estimates suffer from high variance since compression quality is only indirectly evaluated through eventual task success.
- 使用 RL 更新 LLM 的参数
可能需要难以承受的计算成本; - 环境轨迹采样极其昂贵,因为每个奖励都需要智能体与压缩器进行多步执行;
- 压缩质量只能通过最终任务是否成功来间接评估,因此策略梯度估计的方差很大。
3.3. Optimizing Compression Guidelines
To overcome these challenges, we propose to optimize compression guidelines
为克服这些挑战,我们提出优化用于上下文压缩的 压缩准则
We instantiate this idea as prompt optimization using an LLM as the optimizer, where the natural language prompt
我们将这一思想实现为以 LLM 作为优化器的提示词优化,通过自然语言表达的反馈来改进自然语言提示词
On the training set
在训练集
This feedback serves as a natural language gradient, indicating how the compression guideline
这些反馈充当自然语言梯度,指出应如何改进压缩准则
where
其中,
However, optimizing only for reward may neglect the context cost (second term in Equation (7)). To address this, motivated by alternating optimization, we perform a second iteration that conditions only on successful task with compressed context, asking the LLM to generate feedback about which information was actually used during execution. This refines
We illustrate overall process in Figure 3. Algorithm 1 and prompts are in Appendix B.
| Method | Average (168) | Easy (57) | Medium (48) | Hard (63) | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Acc. ↑ | Steps ↓ | Peak ↓ | Dep.↓ | Acc. ↑ | Peak ↓ | Dep.↓ | Acc. ↑ | Peak ↓ | Dep.↓ | Acc. ↑ | Peak ↓ | Dep.↓ | |
| Agent: gpt-4.1 / Compressor: gpt-4.1 | |||||||||||||
| No compression | 56.0 | 16.14 | 9.93 | 5.96 | 80.7 | 7.57 | 2.98 | 47.9 | 10.10 | 5.36 | 39.7 | 11.95 | 9.11 |
| History Compression | |||||||||||||
| FIFO | 45.8 | 28.48 | 6.73 | 5.69 | 84.2 | 5.85 | 2.89 | 39.6 | 7.26 | 6.24 | 15.9 | 7.14 | 7.80 |
| Retrieval | 27.4 | 33.17 | 8.39 | 6.68 | 61.4 | 7.40 | 3.97 | 12.5 | 8.74 | 7.72 | 7.9 | 9.02 | 8.33 |
| LLMLingua | 39.3 | 24.42 | 7.50 | 6.37 | 66.7 | 6.38 | 3.04 | 37.5 | 8.04 | 7.39 | 15.9 | 8.09 | 8.59 |
| Prompting | 43.5 | 24.01 | 6.93 | 5.29 | 66.7 | 6.36 | 2.84 | 41.7 | 7.10 | 5.36 | 23.8 | 7.31 | 7.48 |
| ACON ut | 51.2 | 20.92 | 7.17 | 4.49 | 77.2 | 6.45 | 2.43 | 50.0 | 7.39 | 4.47 | 28.6 | 7.65 | 6.37 |
| ACON ut co | 56.5 | 22.82 | 7.33 | 4.69 | 86.0 | 7.09 | 2.84 | 56.2 | 7.48 | 4.43 | 30.2 | 7.44 | 6.55 |
| Observation Compression | |||||||||||||
| LLMLingua | 32.1 | 18.16 | 8.17 | 6.01 | 54.4 | 5.78 | 2.33 | 29.2 | 8.24 | 5.23 | 14.3 | 10.29 | 9.92 |
| Prompting | 42.3 | 17.38 | 6.58 | 4.09 | 64.9 | 4.92 | 1.88 | 35.4 | 6.96 | 4.11 | 27.0 | 7.79 | 6.07 |
| ACON ut | 47.0 | 16.67 | 7.62 | 5.08 | 70.2 | 5.87 | 2.21 | 45.8 | 7.79 | 5.00 | 27.0 | 9.07 | 7.73 |
| ACON ut co | 53.6 | 18.12 | 7.43 | 4.93 | 82.5 | 5.66 | 2.63 | 47.9 | 7.30 | 4.43 | 31.8 | 9.14 | 7.50 |
表1:AppWorld 基准(test-normal)上不同难度的结果。各分组报告智能体的准确率(任务目标完成得分)、步数、峰值输入 token 数(
3.4. Distilling Context Compression into Small Models
While compression guideline optimization enables effective compression, repeatedly invoking the large LLM for compression adds substantial overhead. To reduce this cost, we distill the compressor into a smaller model. The teacher with optimized guideline
where
其中,
Once trained, the student replaces the teacher during inference, decoupling decision making from compression. This two-stage pipeline, guideline optimization then distillation, achieves effective compression with a much smaller model (
训练完成后,学生模型在推理时替代教师模型,将决策与压缩解耦。 这一先优化准则、再进行蒸馏的两阶段流程,使小得多的模型也能实现有效压缩(
4. Experiments
We evaluate ACON on three challenging benchmarks that require multi-step interactions across diverse domains. Our experiments are designed to address the following key questions:
我们在三个具有挑战性的基准上评估 ACON,这些基准覆盖不同领域,均需要多步交互。 实验旨在回答以下关键问题:
- How well does ACON improve token efficiency while preserving performance? (Section 4.2)
- Does distilling the compressor reduce its size while maintaining agent performance? (Section 4.3)
- Can ACON help small, distilled LM agents perform better under long contexts? (Section 4.4)
(a) OfficeBench
| Method | Acc. ↑ | Steps ↓ | Peak ↓ | Dep. ↓ |
|---|---|---|---|---|
| Agent: gpt-4.1 / Compressor: gpt-4.1 | ||||
| No Compression | 76.84 | 11.52 | 7.27 | 4.43 |
| History Compression | ||||
| FIFO | 67.37 | 12.26 | 4.02 | 2.64 |
| Retrieval | 65.26 | 16.20 | 4.33 | 2.06 |
| LLMLingua | 70.53 | 10.89 | 4.65 | 1.85 |
| Prompting | 71.58 | 10.13 | 4.40 | 1.10 |
| ACON ut | 74.74 | 13.13 | 4.93 | 3.85 |
| ACON utco | 72.63 | 11.54 | 4.54 | 1.91 |
| Observation Compression | ||||
| LLMLingua | 71.58 | 11.89 | 7.38 | 6.14 |
| Prompting | 55.79 | 12.24 | 6.44 | 2.68 |
| ACON ut | 73.68 | 10.83 | 6.55 | 3.85 |
| ACON utco | 72.63 | 10.28 | 6.17 | 2.88 |
(b) 8-objective QA
| Method | EM ↑ | F1 ↑ | Steps ↓ | Peak ↓ | Dep. ↓ |
|---|---|---|---|---|---|
| Agent: gpt-4.1 / Compressor: gpt-4.1 | |||||
| No compression | 0.366 | 0.488 | 15.78 | 10.35 | 3.32 |
| History Compression | |||||
| FIFO | 0.293 | 0.388 | 19.26 | 5.09 | 2.51 |
| Retrieval | 0.331 | 0.438 | 20.06 | 5.11 | 2.62 |
| LLMLingua | 0.363 | 0.481 | 17.68 | 5.68 | 2.24 |
| Prompting | 0.376 | 0.478 | 18.70 | 4.73 | 1.66 |
| ACON ut | 0.373 | 0.494 | 17.14 | 4.71 | 1.57 |
| ACON utco | 0.335 | 0.458 | 17.79 | 4.65 | 1.50 |
| Observation Compression | |||||
| LLMLingua | 0.320 | 0.414 | 14.23 | 5.16 | 1.35 |
| Prompting | 0.288 | 0.397 | 11.64 | 3.41 | 0.45 |
| ACON ut | 0.364 | 0.475 | 16.33 | 4.97 | 1.28 |
| ACON utco | 0.336 | 0.461 | 14.00 | 4.22 | 0.81 |
表2:OfficeBench 与 8 目标问答 基准上的结果。我们报告性能指标(acc/EM/F1)、步数、峰值输入 token 数(

图4:以 gpt-4.1 为智能体时,蒸馏压缩器在历史压缩上的结果。灰色虚线表示使用 gpt-4.1 教师压缩器时的性能。学生模型(Qwen3-14B、Qwen3-8B、Phi-4)基于效用最大化 UT 步骤之后优化得到的压缩准则,从 gpt-4.1 压缩器蒸馏而来,并在所有基准上评估。我们还纳入了未经蒸馏的 gpt-4.1-mini,结果表明,即便不进行额外训练,小模型也能成为有效的压缩器。
4.1. Experimental Setup
Benchmarks & Metrics. We focus on long-horizon agentic task benchmarks that require 10+ interaction steps on average:
基准与指标。 我们关注平均需要 10 步以上交互的长程智能体任务基准:
- AppWorld: Main benchmark with 9 simulated apps (e.g., Venmo, Spotify, SimpleNote) and ∼100 simulated users. Performance is measured by task completion score.
- OfficeBench: Productivity tasks across 6 apps (e.g., Word, Excel, Email), operating on simulated documents. Performance is measured by benchmark-defined accuracy functions.
- 8-objective QA: QA benchmark where agents interact with a search tool to answer 8 questions and output a consolidated answer set. Performance is the average of Exact Match (EM) and F1 scores across 8 questions.
- AppWorld:主要基准,包含 9 个模拟应用(例如 Venmo、Spotify、SimpleNote)以及约 100 名模拟用户。 性能通过任务完成得分衡量。
- OfficeBench:在 6 个应用(例如 Word、Excel、Email)之间处理模拟文档的生产力任务。 性能通过基准定义的准确率函数衡量。
- 8 目标问答:智能体通过与搜索工具交互来回答 8 个问题,并输出汇总答案集的问答基准。 性能为 8 个问题的精确匹配(EM)与 F1 得分的平均值。
In addition to task-specific performance metrics, we report three token efficiency metrics following prior work:
除任务特定的性能指标外,我们遵循以往工作,报告三项 token 效率指标:
- Steps: The average number of interaction steps per task.
- Peak Tokens: The maximum context length encountered across all steps.
- Dependency: The cumulative dependency of each generated action on prior tokens, measuring how much generation relies on the context history.
- 步数: 每个任务的平均交互步数。
- 峰值 token 数: 所有步骤中出现的最大上下文长度。
- 依赖度: 每个生成动作对先前 token 的累积依赖,用于衡量生成过程对上下文历史的依赖程度。
Full details are provided in the Appendix B.
完整细节见 附录 B。
Throughout all experiments, we use ReAct agent. For the detailed tool format, we follow the convention of each benchmark.
所有实验均使用 ReAct 智能体。 具体工具格式遵循各基准的惯例。
Baselines.
基线。
- No Compression: full uncompressed context.
- FIFO: keep the most recent
interactions, discarding earlier ones. - Retrieval: select
past interactions most similar to the current query via embedding search. - LLMLingua: extractive compression with an encoder-only LM.
- Prompting: naive baseline using a general compression instruction.
- 不压缩: 使用完整、未压缩的上下文。
- FIFO: 保留最近的
次交互,丢弃更早的交互。 - Retrieval: 通过嵌入搜索,选择与当前查询最相似的
次历史交互。 - LLMLingua: 使用仅含编码器的语言模型进行抽取式压缩。
- Prompting: 使用通用压缩指令的朴素基线。
Our Methods. We evaluate two versions of ACON.
我们的方法。 我们评估 ACON 的两个版本。
- ACON ut utilizes an optimized guideline for context compression after utility maximization step.
- ACON utco applies compression maximization co after utility maximization ut, aiming for shorter but informative compression.
- ACON ut 使用效用最大化步骤之后得到的 优化准则 进行上下文压缩。
- ACON utco 在效用最大化 ut 之后执行压缩最大化 co,以获得更短但信息充分的压缩结果。
We apply only single step per each step for experiments. Additional analysis on the number of steps is in Appendix C.
实验中,每种优化步骤都只执行一次。 关于步骤数量的进一步分析见 附录 C。

图5:从 gpt-4.1 轨迹蒸馏得到的 Qwen3-14B 智能体的性能与效率权衡。对于蒸馏压缩器,我们采用与 图4 相同的蒸馏设置。相较不压缩的基线,ACON 框架提供压缩后的轨迹,并结合蒸馏压缩器,使蒸馏后的智能体在所有基准上持续获得更高准确率,同时显著减少峰值输入 token 数。

图6:使用 gpt-4.1 在 AppWorld 上进行的 压缩阈值消融实验。(1) 不同任务轨迹长度(任务步数)下的压缩次数(压缩频率);(2) 不同阈值设置下的性能比较。
4.2. Overall performance and token efficiency
In Table 1 and Table 2, we first evaluate ACON using on gpt-4.1 for both agent and compressor, which already achieves strong results on benchmarks.
在 表1 和 表2 中,我们首先评估智能体与压缩器均使用 gpt-4.1 时的 ACON;该模型本身已在这些基准上取得较强表现。
For history compression, as shown in Table 1, on AppWorld, ACON reduces peak tokens by over 25% while preserving the accuracy of the no compression upper bound, outperforming all baselines that suffer severe degradation on medium and hard tasks spanning longer steps. On OfficeBench (Table 2a), ACON lowers peak context size by nearly 30% while maintaining accuracy above 74%. On 8-objective QA (Table 2b), ACON even surpasses the no compression baseline in EM/F1 while reducing peak tokens and dependency by 54.5% and 61.5%, respectively. For observation compression, ACON consistently outperforms all baselines confirming that compression guideline optimization is effective for compressing not only history but also raw observations.
对于历史压缩,如 表1 所示,在 AppWorld 上,ACON 将峰值 token 数减少了 25% 以上,同时保持了不压缩上界的准确率,优于所有基线;这些基线在交互步数更长的中等和困难任务上都出现了严重退化。 在 OfficeBench(表2a)上,ACON 将峰值上下文规模降低了近 30%,同时将准确率维持在 74% 以上。 在 8 目标问答(表2b)上,ACON 的 EM/F1 甚至超过了不压缩基线,同时将峰值 token 数和依赖度分别降低了 54.5% 和 61.5%。 对于观测压缩,ACON 持续优于所有基线,证实压缩准则优化不仅对历史有效,也能有效压缩原始观测。
Applying only the utility maximization step (ut) improves performance while reducing token cost across all benchmarks, whereas the compression maximization step (co) further lowers token cost but may slightly hurt accuracy depending on the environment. This trade-off suggests a practical guideline for choosing between the two variants. In verbose and noisy environments such as AppWorld, where observations contain redundant API outputs and distractors, utco is often preferable because aggressive pruning can improve both efficiency and focus. In contrast, in high-fidelity information-seeking tasks such as OfficeBench and 8-objective QA, ut is generally safer because over-compression may remove subtle facts needed for final decisions. Therefore, utco is recommended when observations contain substantial redundancy, while ut is preferable when precise fact retention is critical.
仅执行效用最大化步骤(ut)即可在所有基准上提升性能并降低 token 成本,而压缩最大化步骤(co)能够进一步降低 token 成本,但根据环境不同,可能轻微损害准确率。 这种权衡为选择两个变体提供了实用准则。 在 AppWorld 这类信息冗长、噪声较多的环境中,观测包含冗余的 API 输出与干扰项,因此 utco 往往更合适,因为积极删减内容可以同时提高效率与专注程度。 相反,在 OfficeBench 和 8 目标问答这类要求信息高度保真的信息获取任务中,ut 通常更稳妥,因为过度压缩可能删除最终决策所需的细微事实。 因此,当观测含有大量冗余信息时,推荐使用 utco;当准确保留事实至关重要时,则更适合使用 ut。
4.3. Compressor distillation
We distill the compressor with optimized guidelines after ut step into smaller models such as Qwen3-14B, Qwen3-8B, and Phi-4 using LoRA. As shown in Figure 4, the distilled compressors retain over 95% of the performance of the gpt-4.1 teacher (indicated by the grey dotted line) while reducing computational overhead. We also observe that gpt-4.1-mini, even without any distillation, can serve as an effective lightweight compressor on OfficeBench and QA. This indicates that small models can reliably replace large LLM-based compressors when equipped with optimized guidelines. These results confirm that small models are sufficient for compression, enabling the expensive LLM to be only reserved for the agent.
我们使用 LoRA,将完成 ut 步骤后采用优化准则的压缩器蒸馏到 Qwen3-14B、Qwen3-8B 和 Phi-4 等更小的模型中。 如 图4 所示,蒸馏后的压缩器保留了 gpt-4.1 教师模型 95% 以上的性能(灰色虚线所示),同时减少了计算开销。 我们还观察到,gpt-4.1-mini 即使完全未经蒸馏,也能在 OfficeBench 和问答任务上充当有效的轻量压缩器。 这表明,配备优化准则后,小模型可以可靠地替代基于大型 LLM 的压缩器。 这些结果证实,小模型足以承担压缩任务,从而可以仅将昂贵的 LLM 用作智能体。
4.4. ACON for distilled small agents
We examine whether ACON also benefits smaller LLM agents, which are particularly vulnerable to long-horizon inefficiency. Without compression, models such as Qwen3-14B often fail on medium and hard tasks due to distracting context. As shown in Figure 5, ACON substantially improves their performance: on AppWorld, Qwen3-14B achieves a 32.4% relative improvement (from 25.6% to 33.9%), and on 8-objective QA, it shows a 45.6% gain (from 0.158 to 0.23 EM). These results demonstrate that ACON acts as an equalizer, enabling smaller agents with concise but informative contexts to approach the performance of larger models.
我们考察 ACON 是否也能使更小的 LLM 智能体受益,因为它们尤其容易受到长程任务低效率的影响。 在不压缩上下文时,Qwen3-14B 等模型经常因上下文干扰而在中等和困难任务上失败。 如 图5 所示,ACON 显著提升了它们的性能:在 AppWorld 上,Qwen3-14B 获得了 32.4% 的相对提升(从 25.6% 提升至 33.9%);在 8 目标问答上,它获得了 45.6% 的提升(EM 从 0.158 提升至 0.23)。 这些结果表明,ACON 能缩小模型间的差距,让使用简洁但信息充分上下文的小型智能体接近更大模型的性能。
4.5. Analysis
Compression threshold: moderate value yields the best trade-off. In Figure 6, we provide ablations on threshold for compression in Equation (3) and Equation (4). Results show that smaller thresholds reduce tokens but incur more frequent compression calls and degrade accuracy, while larger thresholds preserve accuracy with higher cost. Moderate values (4096 for history, 1024 for observation) provide the best trade-off, maintaining accuracy close to no compression while still reducing peak tokens substantially.
Prompt optimizer: o3 + contrastive feedback works best. We analyze how the choice of optimizer and the use of contrastive feedback affect compression guideline quality. As shown in Table 3, the default o3 with contrastive feedback yields the best performance, while removing contrastive feedback (only using failed trajectories) or switching to other models results in lower accuracy. Although o3 shows the best performance, we also demonstrate that the optimizer model can be replaced to weaker models such as gpt-4.1, showing it still yields sufficiently fine guideline compared to the baseline guideline.
提示词优化器:o3 加对比反馈效果最佳。 我们分析了优化器选择以及是否采用对比反馈对压缩准则质量的影响。 如 表3 所示,默认使用 o3 并结合对比反馈时性能最佳;移除对比反馈(仅使用失败轨迹)或改用其他模型,都会降低准确率。 虽然 o3 表现最好,但我们也展示了可将优化器模型替换为 gpt-4.1 等较弱模型,它们得到的准则仍然足够好,优于基线准则。
| Optimizer model | Task contrastive | Average Acc. |
|---|---|---|
| o3 | ✓ | 51.2 |
| o3 | ✗ | 50.6 (-0.6) |
| gpt-4.1 | ✓ | 47.6 (-3.6) |
| gpt-5 | ✓ | 50.6 (-0.6) |
表3:AppWorld 上使用 gpt-4.1 智能体与历史压缩器时,提示词优化器的消融实验。默认设置为 o3 优化器,并使用任务对比反馈。
Optimization cost: practical and lightweight. One might assume that leveraging a reasoning model like o3 would be cost-prohibitive. However, our guideline optimization step is remarkably lightweight, demanding less than $2 per benchmark. This can be negligible compared to the expense of trajectory rollouts on the training dataset. For instance, utilizing gpt-4.1 on AppWorld train set requires a total rollout cost of approximately $20. Furthermore, even this data collection cost is substantially lower than that of RL-based methods such as GRPO, which requires extensive rollout for advantage estimation. Detailed API cost computation and breakdowns are provided in Appendix B.2 and Appendix C.2.
API cost analysis of compressors across different models. While using a compressor reduces context length, it incurs additional computational costs beyond the agent. In Section 3.4, we proposed a distillation strategy to mitigate this overhead. To quantify the cost efficiency, we analyze the expenses using API pricing as a proxy. With gpt-4.1 as the baseline compressor, the cost remains significant at $0.045 per example. Switching to gpt-4.1-mini reduces the compression cost to $0.014, achieving a 69.2% reduction.
不同模型压缩器的 API 成本分析。 虽然使用压缩器可以缩短上下文,但它也会在智能体之外引入额外计算成本。 在 第 3.4 节 中,我们提出了蒸馏策略来缓解这一开销。 为量化成本效率,我们以 API 定价作为代理指标分析费用。 使用 gpt-4.1 作为基线压缩器时,每个样例的成本仍较高,为 0.045 美元。 改用 gpt-4.1-mini 后,压缩成本降至 0.014 美元,减少了 69.2%。
However, the most substantial gain is observed with distilled Qwen3-14B, where the cost decreases to $0.0004. This represents a 99.1% reduction compared to the teacher model, effectively minimizing the cost burden of context compression.
不过,蒸馏后的 Qwen3-14B 带来了最显著的收益,成本降至 0.0004 美元。 相较教师模型,这减少了 99.1%,有效降低了上下文压缩的成本负担。
Practical efficiency trade-off. We further quantify the practical overhead of generative compression on AppWorld. For API cost, we estimate the end-to-end cost of both the agent and compressor, excluding input caching. For latency, we run the agent and compressor locally on a single A100 GPU rather than using API endpoints, which avoids confounding factors such as network overhead and server-side queueing. As shown in Table 4, ACON reduces end-to-end API cost by compressing the context of agent, but introduces additional wall-clock latency due to the extra compressor call.
实际效率权衡。 我们进一步量化了 AppWorld 上生成式压缩的实际开销。 对于 API 成本,我们估算智能体与压缩器的端到端总成本,不考虑输入缓存。 对于延迟,我们在单张 A100 GPU 上本地运行智能体与压缩器,而不使用 API 端点,从而避免网络开销、服务端排队等混杂因素。 如 表4 所示,ACON 通过压缩智能体上下文降低了端到端 API 成本,但额外的压缩器调用也增加了实际耗时。
| Method | API Cost ↓ | Latency ↓ |
|---|---|---|
| No Compression | $0.331 | 73.24s |
| ACON (history) | $0.285 | 87.68s |
| ACON (observation) | $0.272 | 101.92s |
表4:AppWorld 上的实际效率。 API 成本按每个任务估算,采用 gpt-4.1 智能体与 Qwen3-14B 压缩器。延迟为每个任务实际耗时的中位数,采用 Qwen3-14B 智能体与 Qwen3-14B 压缩器。
We include more experimental results including experiments with different agent models, additional ablation studies, case study, and qualitative examples of context compression in Appendix C and Appendix D.
5. Conclusion
We presented Agent Context Optimization (ACON), a unified framework that systematically compresses both interaction histories and environment observations for long-horizon LLM agents. Unlike prior work that relies on naive prompting or narrow domains, ACON introduces compression guideline optimization in natural language space, enabling adaptive and model-agnostic compression. Experiments on AppWorld, OfficeBench, and Multi-objective QA show that ACON reduces peak tokens by 26–54% while improving task success over existing compression baselines, with small degradation relative to full-context baseline. Beyond memory efficiency, we demonstrate that optimized compressors can be distilled into smaller models, substantially lowering overhead without sacrificing performance. Moreover, by supplying concise yet informative contexts, ACON allows small agents such as Qwen3-14B to approach the performance of much larger models. Overall, our findings highlight that ACON lays a foundation for more general, memory-efficient, and deployable long-horizon LLM agents.
我们提出了 智能体上下文优化(ACON),这是一个统一框架,为长程 LLM 智能体系统性地压缩交互历史与环境观测。 不同于依赖朴素提示词或面向狭窄领域的以往工作,ACON 在自然语言空间中优化压缩准则,实现自适应且独立于具体模型的压缩。 AppWorld、OfficeBench 和多目标问答上的实验表明,ACON 将峰值 token 数降低了 26–54%,相较现有压缩基线提高了任务成功率,相较完整上下文基线则有小幅下降。 除内存效率外,我们还表明,优化后的压缩器能够被蒸馏到更小的模型中,在不牺牲性能的情况下显著降低开销。 此外,通过提供简洁而信息充分的上下文,ACON 使 Qwen3-14B 这样的小型智能体能够接近大得多的模型的性能。 总体而言,我们的发现表明,ACON 为构建更通用、内存效率更高且易于部署的长程 LLM 智能体奠定了基础。
Limitations and Future Work. While ACON effectively reduces context costs, a few limitations remain. First, our empirical evaluation primarily focuses on GPT models due to resource constraints. Second, like many context management frameworks, the compression process itself introduces computational overhead and increased latency. We include more detailed discussion on limitations and future work in Appendix A.
局限性与未来工作。 虽然 ACON 能有效降低上下文成本,但仍存在一些局限。 首先,由于资源限制,我们的实证评估主要集中于 GPT 模型。 其次,与许多上下文管理框架一样,压缩过程本身会引入计算开销并增加延迟。 关于局限性与未来工作的更详细讨论见 附录 A。