Toward Reliable Context Compression for Long-Horizon Agents: An Empirical Study of Execution Instability
摘要
This empirical study investigates how recurrent context compression affects long-horizon agent behavior, showing that compression can weaken recent interaction influence and cause instability. The authors introduce TRACE, a verifier-guided framework that improves compression reliability and performance on AppWorld.
查看缓存全文
缓存时间: 2026/08/10 08:01
# Toward Reliable Context Compression for Long-Horizon Agents: An Empirical Study of Execution Instability
Source: [https://arxiv.org/html/2608.06503](https://arxiv.org/html/2608.06503)
Guanghui Min1,2, Liang Wu2, Mayank Darbari2, Chen Chen1, Liangjie Hong2 1Department of Computer Science, University of Virginia, Charlottesville, VA, USA 2Nokia, Sunnyvale, CA, USA \{jjm8vr, zrh6du\}@virginia\.edu \{liang\.wu, mayank\.darbari, liangjie\.hong\}@nokia\.com
###### Abstract
Recurrent context compression controls context growth in long\-horizon agents, but its behavioral effects remain poorly understood\. In this preliminary empirical study, we show that compression can weaken the influence of recent interactions, increasing blocked actions, repeated exploration, and instability across runs\. Motivated by these observations, we introduceTRACE, a verifier\-guided framework that evaluates individual compaction events through paired closed\-loop continuations from the same environment state and uses summary preferences to optimize a natural\-language compression prompt while keeping all models frozen\. Initial results on AppWorld show improvements over existing compression baselines in task performance, multi\-run reliability, and context–execution efficiency\. These findings provide early evidence for boundary\-local evaluation as a promising direction for reliable agent context compression\. Our code is in[https://github\.com/nokia\-applied\-research/Trace](https://github.com/nokia-applied-research/Trace)\.
## 1Introduction
Large language models increasingly operate over long, evolving contexts rather than isolated prompts\. Such settings include interactive agents that interleave reasoning, actions, observations, and plan revision\(Yaoet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib1); Shinnet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib2); Wanget al\.,[2024b](https://arxiv.org/html/2608.06503#bib.bib3)\); browser, application, API, and office environments that require extended interaction with external systems\(Zhouet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib28); Trivediet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib29); Wanget al\.,[2024c](https://arxiv.org/html/2608.06503#bib.bib30)\); policy\-constrained conversational workflows; and retrieval\-intensive research tasks that accumulate evidence over multiple steps\. In all of these settings, the context grows with every tool output, retrieved source, intermediate decision, user clarification, and partial result\. Repeatedly supplying the full history increases inference cost and peak\-context pressure, while making the information needed for the next decision increasingly difficult to locate\. Context compression is therefore essential for scalable long\-horizon LLM systems\.
Prior work has progressively moved from document\-level prompt compression to trajectory\-aware context management\. General prompt\-compression methods prune, rewrite, or distill input tokens to reduce inference cost while preserving semantic content or downstream task quality\(Liet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib5); Jianget al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib6);[2024](https://arxiv.org/html/2608.06503#bib.bib7); Panet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib8); Xuet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib9); Shandilyaet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib10)\)\. For long\-horizon agents, recent methods recognize that context contains more than ordinary prose: it records action–observation histories, intermediate plans, and evolving interaction state\. ReSum and SUPO therefore co\-optimize summarization with downstream agent behavior\(Wuet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib17); Luet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib18)\); ACON improves compression guidelines by contrasting successful full\-context trajectories with failed compressed ones\(Kanget al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib19)\); and practical systems compact long sessions into structured natural\-language checkpoints\(OpenClaw Contributors,[2026a](https://arxiv.org/html/2608.06503#bib.bib25);[b](https://arxiv.org/html/2608.06503#bib.bib26); Nous Research,[2026](https://arxiv.org/html/2608.06503#bib.bib27)\)\. These advances establish that agent context should be treated differently from a static document\.
Nevertheless, these approaches share an implicit substitution assumption:once a shorter checkpoint retains the task\-relevant content, it can stand in for the original interaction history\. This assumption overlooks the directional role of history in long\-horizon execution\. A raw trajectory does not merely record facts; its ordered action–observation sequence anchors what has already been completed, where execution currently stands, and whether the task is ready to terminate\. Summarization can flatten this directed process into a declarative account of past progress and future plans\. As a result, even when salient entities and progress labels are retained, a frozen agent may lose its local position in the trajectory, replay completed actions, or continue acting beyond the terminal frontier\. The central challenge is therefore to compress history while preserving a representation from which the frozen agent can reliably recognize its current execution state\.
We proposeTRACE\(Trajectory\-RelativeAgentContext ComprEssion\), a verifier\-guided framework for optimizing recurrent context compression for frozen long\-horizon agents\. Rather than inferring compression quality from terminal task outcomes,TRACEevaluates each compaction boundary directly\. From the same environment state, it compares paired closed\-loop continuations before and after compression and measures the additional blocked or repeated exploration induced by the summary\. These boundary\-local scores produce preferences between candidate summaries\. A frozen proposer observes only which summary is preferred—not the subsequent actions, observations, or error signals—and uses these preferences to revise the natural\-language compression template\. The compressor model, downstream agent, tools, and decoding configuration remain fixed throughout\.
Our contributions are threefold:
- •Behavioral diagnosis\.We show that recurrent compression can attenuate the effect of recent interactions, increasing blocked execution and repeated exploration while reducing multi\-run reliability\.
- •Boundary\-local compression optimization\.We introduce a paired closed\-loop verifier that separates compression\-induced execution regressions from the frozen agent’s intrinsic behavioral variability, and use its summary preferences to optimize the compression template without exposing rollout details to the proposer\.
- •Empirical evaluation\.On AppWorld,TRACEconsistently outperforms existing compression baselines across task difficulty levels, improves repeated\-run reliability, and keeps average execution steps close to full context while substantially reducing peak context usage\. Moreover, the template optimized with MiniMax\-M3 transfers to Kimi\-K2\.7\-Code without further optimization, outperforming all compressed baselines and even exceeding full context in overall accuracy and Pass2\.
## 2Preliminaries
### 2\.1Context Compression for Frozen Long\-Horizon Agents
Notations\.We study context compression for a fixed downstream agentℳ\\mathcal\{M\}interacting with an external environmentℰ\\mathcal\{E\}\. The agent is fixed in the sense that its language model, system prompt, action interface, output parser, and decoding procedure are not modified\. Let𝒟=\{ui\}i=1\|𝒟\|\\mathcal\{D\}=\\\{u\_\{i\}\\\}\_\{i=1\}^\{\|\\mathcal\{D\}\|\}denote a distribution of long\-horizon tasks, where each task begins with an instructionuu\. A rollout is denoted byτ=\(u,a1,o1,…,aT,oT\)\\tau=\(u,a\_\{1\},o\_\{1\},\\ldots,a\_\{T\},o\_\{T\}\)\. Before decision steptt, the complete interaction history isht=\(u,a1,o1,…,at−1,ot−1\)h\_\{t\}=\(u,a\_\{1\},o\_\{1\},\\ldots,a\_\{t\-1\},o\_\{t\-1\}\), whereaia\_\{i\}is an agent action andoi=ℰ\(ai\)o\_\{i\}=\\mathcal\{E\}\(a\_\{i\}\)is the corresponding environment observation\. We distinguish the complete interaction historyhth\_\{t\}from theagent\-visible contextztz\_\{t\}supplied to the frozen agent\. Givenztz\_\{t\}, the agent generatesat∼ℳ\(⋅∣zt\)a\_\{t\}\\sim\\mathcal\{M\}\(\\cdot\\mid z\_\{t\}\)and receivesot=ℰ\(at\)o\_\{t\}=\\mathcal\{E\}\(a\_\{t\}\)\. Full\-context execution useszt=htz\_\{t\}=h\_\{t\}\. Since\|ht\|\|h\_\{t\}\|generally grows withtt, the complete history can eventually exceed the practical context budget of long\-horizon execution\.
### 2\.2Problem Definition
Long\-horizon agents must periodically replace their growing working context with a bounded textual representation\(Kanget al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib19); Luet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib18); Wanget al\.,[2024a](https://arxiv.org/html/2608.06503#bib.bib31); Nous Research,[2026](https://arxiv.org/html/2608.06503#bib.bib27); OpenClaw Contributors,[2026a](https://arxiv.org/html/2608.06503#bib.bib25)\)\. Let𝒞\\mathcal\{C\}denote a compressor andBBdenote the context budget\. Given the current agent\-visible contextztz\_\{t\}, actionata\_\{t\}, and observationoto\_\{t\}, define the pre\-compaction context asz¯t\+1=zt⊕\(at,ot\)\\bar\{z\}\_\{t\+1\}=z\_\{t\}\\oplus\(a\_\{t\},o\_\{t\}\), where⊕\\oplusdenotes textual concatenation\. The context supplied at the next decision step is recursively updated as
zt\+1=\{z¯t\+1,\|z¯t\+1\|≤B,𝒞\(z¯t\+1;B\),\|z¯t\+1\|\>B\.z\_\{t\+1\}=\\begin\{cases\}\\bar\{z\}\_\{t\+1\},&\|\\bar\{z\}\_\{t\+1\}\|\\leq B,\\\\ \\mathcal\{C\}\(\\bar\{z\}\_\{t\+1\};B\),&\|\\bar\{z\}\_\{t\+1\}\|\>B\.\\end\{cases\}\(1\)
Thus, after a compaction event, the replacement contextzt\+1z\_\{t\+1\}becomes the only historical record available to the frozen agent and to subsequent compaction steps\. For a compressor𝒞\\mathcal\{C\}, letp𝒞,B\(τ∣u\)p\_\{\\mathcal\{C\},B\}\(\\tau\\mid u\)denote the rollout distribution induced by the frozen agentℳ\\mathcal\{M\}, environmentℰ\\mathcal\{E\}, and the recursive context transition in Equation[1](https://arxiv.org/html/2608.06503#S2.E1)\. LetR\(τ\)R\(\\tau\)denote the environment\-defined terminal reward\.
## 3Empirical Study: Behavioral Effects of Context Compression
In this section, we first show that recurrent compression degrades task success and reliability, especially over longer trajectories\. We then trace this degradation to execution\-state mislocalization and examine how it manifests as blocked execution and repeated exploration after compaction\.
### 3\.1Repeated Compression Degrades Agent Behavior
\(a\)Compression performance\.
\(b\)Cross\-run behavioral instability\.
\(c\)Long\-horizon degradation\.
Figure 1:Repeated context replacement degrades agent behavior despite refetchable information\.AppWorld allows agents to re\-query persistent application state, so previously observed information remains recoverable after compaction\. \(a\) Mean pass rate declines as the context budget shrinks\. \(b\) The widening gap betweenP@2P@2andP2P^\{2\}indicates reduced reliability across repeated runs\. \(c\) Even with summary\-based compaction, degradation is substantially sharper for tasks with longer full\-context reference horizons\.Equation \([1](https://arxiv.org/html/2608.06503#S2.E1)\) makes context compression a recurrent intervention: once the working context exceeds the budget, the replacement context becomes the input to both subsequent decisions and later compaction events\. Its quality therefore cannot be assessed from a single replacement in isolation\. A locally plausible summary may still alter the downstream rollout once it is repeatedly reused as the agent’s working context\.
We evaluate this effect on the 147\-task AppWorld train–development split\(Trivediet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib29)\)\. AppWorld is a stateful API\-use benchmark: agents interact with persistent simulated applications through API calls, and earlier observations can be recovered by re\-querying the underlying application state\. This setting differs from knowledge\-intensive tasks, where summary\-based compaction is expected to outperform FIFO truncation because it preserves facts that would otherwise be permanently discarded\. In AppWorld, removing an observation from the working context does not necessarily make its content permanently inaccessible\. We use MiniMax\-M3 as both compressor and downstream agent\(MiniMax,[2026](https://arxiv.org/html/2608.06503#bib.bib32)\)\. Our evaluation harness adapts OpenClaw’s recurrent compaction loop111Adapted from the OpenClaw agent\-core harness,[https://github\.com/openclaw/openclaw/blob/0e7b5c34292cc28707a0e5a0b730cff295ef0f8a/packages/agent\-core/src/harness/compaction/compaction\.ts](https://github.com/openclaw/openclaw/blob/0e7b5c34292cc28707a0e5a0b730cff295ef0f8a/packages/agent-core/src/harness/compaction/compaction.ts)\(commit0e7b5c34292cc28707a0e5a0b730cff295ef0f8a\)\.\(OpenClaw Contributors,[2026a](https://arxiv.org/html/2608.06503#bib.bib25)\)\. This common runtime pattern is also used in other agentic frameworks such as AG2 and Hermes Agent\(Wanget al\.,[2024a](https://arxiv.org/html/2608.06503#bib.bib31); Nous Research,[2026](https://arxiv.org/html/2608.06503#bib.bib27)\)\.
Figure[1](https://arxiv.org/html/2608.06503#S3.F1)reveals a surprising budget\-dependent pattern\. Summary\-based compaction does not uniformly outperform FIFO truncation: at1616K,88K, and44K, FIFO matches or slightly exceeds summary\-based execution\. Their difference emerges only under the tightest budget, where summary\-based compaction reaches72\.8%72\.8\\%while FIFO drops to42\.2%42\.2\\%\. Thus, in this information\-refetchable setting, the advantage of summarization over recency\-only truncation appears only under severe compression\. Both policies nevertheless remain below full\-context performance\.
Mean pass rate alone does not fully characterize this degradation\. Following the repeated\-run reliability metrics used inτ\\tau\-bench andτ2\\tau^\{2\}\-bench\(Yaoet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib35); Barreset al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib34)\),PkP^\{k\}denotes the fraction of tasks solved in allkkindependent runs, whereasP@kP@kdenotes the fraction solved in at least one of thekkruns\. We usek=2k=2throughout\. Under stronger compression, the gap betweenP@2P@2andP2P^\{2\}widens substantially\. Compression therefore does not merely remove a subset of tasks from the agent’s reach: it converts some tasks that were reliably solved into tasks that are only intermittently solved under the same runtime condition\.
This instability is more pronounced on tasks with longer full\-context execution horizons, measured by the median number of steps in successful full\-context runs\. Even under summary\-based compaction, longer\-horizon tasks degrade more sharply as the budget shrinks, consistent with an accumulating effect of repeated context replacement\.
Together, these results suggest that successful compression depends not only on preserving globally relevant information, but also on maintaining the local continuity that anchors the agent’s current execution position\. FIFO preserves recent action–observation continuity despite discarding most earlier history, whereas repeated summary replacement can progressively weaken this local anchor over longer trajectories\. We next isolate this effect at matched decision points\.
Takeaway:Compressor quality is better reflected by multi\-run stability than by single\-run performance alone\.
### 3\.2Beyond Information Loss: Execution\-State Mislocalization
Figure 2:Terminal completion\.Total height denotes the termination rate; dark segments denote termination in the required form\.The degradation in Section[3\.1](https://arxiv.org/html/2608.06503#S3.SS1)is often attributed to the loss of facts, variables, or task progress during summarization\. This account is incomplete in our setting: earlier observations remain re\-queryable in AppWorld, while FIFO truncation remains competitive at moderate budgets despite discarding most earlier history\. We therefore ask whether compression also weakens the agent’s ability to recover its current execution state—what has been completed, what remains actionable, and whether execution should continue or terminate\.
Summary Replacement Disrupts Terminal Completion\.We first probe the final decision before termination\. For each trajectory with at least one compaction, we hold the task, environment, agent header, and decision point fixed, and compare the actual summary context, FIFO truncation at the same budget, and the full pre\-terminal history\. All turns are reconstructed in their native interaction format, and we sample1010next actions under each rendering\.
Figure[2](https://arxiv.org/html/2608.06503#S3.F2)shows that, at22K, the summary condition terminates in only44\.6%44\.6\\%of samples, with37\.3%37\.3\\%using the required form, compared with77\.2%77\.2\\%/68\.1%68\.1\\%for FIFO and66\.6%66\.6\\%/60\.6%60\.6\\%for full history\. The deficit persists at44K and88K\. It is most pronounced when correct completion requires no substantive response: the summary\-conditioned agent more often continues acting or supplies unnecessary content instead of terminating directly\. Summary replacement therefore impairs both completion recognition and compliance with the required output form\.
Takeaway:Compression can weaken action commitment and adherence to the required output form\.
Compression Attenuates Recent Interaction Updates\.We next examine whether this effect persists throughout a summary’s lifetime\. For each compaction, letSt−1S\_\{t\-1\}denote the previous summary,Δt\\Delta\_\{t\}the new raw interaction history, andSt=C\(St−1,Δt\)S\_\{t\}=C\(S\_\{t\-1\},\\Delta\_\{t\}\)the updated summary\. At every recorded decision boundary before the next compaction, we construct four matched contexts: the full raw prefix;St−1S\_\{t\-1\}followed by the uncompressedΔt\\Delta\_\{t\}; the updated summaryStS\_\{t\}; andSt−1S\_\{t\-1\}withΔt\\Delta\_\{t\}omitted\. Each condition is then followed by the same recorded suffix and ends at the same decision point\.
Figure 3:Effect of recent interactions\.Divergence from full\-history behavior when the new interaction history is retained verbatim, compressed, or omitted\. Error bars denote task\-level95%95\\%bootstrap confidence intervals\.We independently sample2424next actions under each context\. Sampled actions are neither executed nor fed back to the agent\. We canonicalize the primary API call and compute its noise\-corrected total\-variation divergence from the full\-history distribution, averaging first over all decision points in the summary’s lifetime and then over tasks\. Figure[3](https://arxiv.org/html/2608.06503#S3.F3)reveals a clear gradient\. Retaining the raw update yields the smallest divergence \(0\.1490\.149\); compressing it into the updated summary increases divergence to0\.2330\.233; and omitting it entirely produces the largest shift \(0\.2890\.289\)\. OpenClaw therefore preserves part of the behavioral effect of recent interactions, but systematically attenuates it relative to retaining them verbatim\.
Together, these probes identify a common functional failure of recurrent compression: recent interactions that should revise execution exert a weaker or distorted effect on subsequent decisions after being absorbed into the summary\. This may arise from omitted information, distorted progress, or ineffective use of retained information; our experiments do not fully separate these causes\. Goal revisions, tool failures, unexpected outcomes, and completion events are consequential precisely because they should change how the agent continues\. This motivates evaluating compression at the boundary where it occurs, using its downstream execution consequences rather than terminal outcomes or static textual fidelity\.
### 3\.3Compression Induces Regressive Exploration
The preceding intervention shows that compression preserves part of the behavioral effect of recent interactions, but attenuates it relative to retaining them verbatim\. We next examine how this attenuation manifests during closed\-loop execution\.
At each compaction boundary, we restore the same AppWorld execution state and independently roll out the frozen agent under two context renderings\. PRE retains the raw interaction update available before compaction, whereas POST uses the updated summary together with OpenClaw’s retained raw turn\. These are free\-running closed\-loop rollouts using the original AppWorld tools: each generated action is executed, and its actual observation is returned before the next decision\. We evaluate590590boundaries and4,6404\{,\}640rollouts, using five samples per rendering for first compactions and three for later compactions, each capped at five actions\.
Figure 4:Blocked execution and regressive exploration\.Marginal POST\-minus\-PRE effects at each of the first five actions after compaction\. Blocked/error actions follow AppWorld’s native error contract; refetch/replay denotes an exact action signature previously observed before the boundary or earlier in the same rollout\. Error bars denote boundary\-level95%95\\%bootstrap confidence intervals\.Figure[4](https://arxiv.org/html/2608.06503#S3.F4)reports the marginal effect of each action step, rather than the cumulative effect through that step\. Compression immediately increases blocked execution: POST produces0\.1080\.108more blocked/error actions than PRE at the first action, and the effect remains positive throughout the continuation\. Refetching is initially weaker \(0\.0310\.031\), but rises at the second action and remains positive thereafter\.
This temporal pattern is consistent with two complementary consequences of attenuating recent interaction updates\. Compression can first make previously established execution state less directly accessible, producing explicit blocks, and subsequently induce additional work to recover or reconstruct that state\. Thus, retained information may remain recoverable while becoming less actionable for continued execution\.
Takeaway:Compression increases regressive exploration, weakening the influence of interactions retained within the context window\.
## 4Trace: Optimizing the Compression Prompt
Section[3\.3](https://arxiv.org/html/2608.06503#S3.SS3)shows that compression can make recently established execution state less actionable, leading to blocked actions and repeated exploration\.TRACE, illustrated in Figure[5](https://arxiv.org/html/2608.06503#S4.F5), converts this observation into a boundary\-local optimization signal\. All model parameters remain frozen: we optimize only the natural\-language compression template used by the compressor\.
Prior prompt\-optimization methods such as ACON construct feedback from trajectories where the agent succeeds with full context but fails with compressed context\(Kanget al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib19)\)\. Such trajectory\-level supervision, however, cannot isolate compression\-induced errors from the agent’s intrinsic behavioral variation and downstream contingencies\. A successful trajectory does not imply that every intermediate compression was faithful, since a compression defect may never be exercised or may be recovered through subsequent environment interactions\. Conversely, a failed trajectory does not imply that its summaries were poor, since failure may arise independently of compression\. We therefore construct supervision directly at individual compaction boundaries using paired closed\-loop continuations from the same execution state\.
### 4\.1Boundary\-Local Execution Verifier
Our verifier measures whether a compression event introduces additional observable execution regressions, operationalized as actions that are blocked by the environment or repeat tool calls that have already been executed\. Rather than attributing the eventual task outcome to every summary along the trajectory, we evaluate each summary locally at the boundary where it replaces the raw interaction history\.
Consider a compaction boundarybb\. Letxb−x\_\{b\}^\{\-\}denote the context immediately before replacement, consisting of the previous recurrent summary, if any, followed by the newly accumulated raw interactions\. Given a candidate summaryss, letxb\+\(s\)x\_\{b\}^\{\+\}\(s\)denote the corresponding post\-compaction context, including the recent raw turn retained by the compaction policy\.
Starting from the same environment state, we independently roll out the frozen agent underxb−x\_\{b\}^\{\-\}andxb\+\(s\)x\_\{b\}^\{\+\}\(s\)\. Both PRE and POST continuations are fully closed\-loop: generated actions are executed through the original tools, and the resulting observations are returned to the agent\. PRE therefore serves as a paired local control for the frozen agent’s intrinsic execution behavior, whereas POST captures any additional burden induced by replacing the history with summaryss\.
Figure 5:Overview ofTRACE\.At each compaction boundary, paired closed\-loop continuations are evaluated from the same environment state\. PRE retains the context available before compaction, whereas POST replaces the compressible history with a candidate summary\. The verifier measures the resulting increase in blocked or repeated actions and ranks candidate summaries\. The frozen proposer receives the downstream system prompt, the incumbent compression prompt, and the resulting summary preferences, but not the rollout actions, observations, errors, or verifier decomposition\. It then produces candidate compression templates, which are selected through end\-to\-end evaluation on the development split\.Letzj\(τ\)z\_\{j\}\(\\tau\)indicate whether thejj\-th action in continuationτ\\tauconstitutes an observable execution regression\. We define the short\-horizon execution burden as
G\(τ\)=∑j=1Kzj\(τ\),G\(\\tau\)=\\sum\_\{j=1\}^\{K\}z\_\{j\}\(\\tau\),\(2\)whereKKis a fixed rollout horizon\. The compression\-induced burden of candidate summaryssis
ΔGb\(s\)=𝔼\[G\(τb\+\(s\)\)\]−𝔼\[G\(τb−\)\],\\Delta G\_\{b\}\(s\)=\\mathbb\{E\}\\\!\\left\[G\\\!\\left\(\\tau\_\{b\}^\{\+\}\(s\)\\right\)\\right\]\-\\mathbb\{E\}\\\!\\left\[G\\\!\\left\(\\tau\_\{b\}^\{\-\}\\right\)\\right\],\(3\)and the verifier score is
Qb\(s\)=−ΔGb\(s\)\.Q\_\{b\}\(s\)=\-\\Delta G\_\{b\}\(s\)\.\(4\)A higher score indicates that the summary introduces fewer additional execution regressions relative to retaining the pre\-compaction context\.
In AppWorld, we instantiatezjz\_\{j\}as the union of two observable events\. An action is*blocked*when it triggers AppWorld’s native execution\-error contract\. An action is*repeated*when its canonicalized tool\-call signature matches one executed before the boundary or earlier in the same continuation\. Their union is counted once, including when an action satisfies both conditions\. These signals capture immediate execution failures and redundant attempts to recover information or repeat operations already explored before compression\.
Importantly, PRE is not treated as an optimal trajectory\. It serves only as a paired control from the same execution state, allowing the verifier to control for the frozen agent’s intrinsic stochasticity and execution errors when estimating the local effect of compression\.
### 4\.2Verifier\-Guided Prompt Optimization
Following ACON\(Kanget al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib19)\), we optimize the compressor in natural\-language prompt space rather than updating model parameters\. The difference lies in how supervision is constructed\. Instead of contrasting terminally successful and failed trajectories,TRACEconstructs preferences between summaries evaluated at the same compaction boundary\.
#### Training\-boundary selection\.
We first collect PRE and POST continuations for compaction boundaries in the AppWorld training split using the frozen base compressor\. From these continuations, we identify boundaries exhibiting blocked actions and group them according to AppWorld’s native execution\-error type\. We then select 12 boundaries through stratified sampling across these error categories\. This provides optimization examples covering multiple forms of execution blockage rather than concentrating on the most frequent error type\.
#### Candidate generation and boundary\-local scoring\.
LetP0P\_\{0\}denote the base compression template andIbI\_\{b\}the compressor input at boundarybb, including the previous summary, newly accumulated interaction history, retained recent turn, and compression budget\. The frozen base compressor independently generates three candidate summaries:
sb,n=S\(Ib;P0\),n∈\{1,2,3\}\.s\_\{b,n\}=S\(I\_\{b\};P\_\{0\}\),\\qquad n\\in\\\{1,2,3\\\}\.\(5\)
For each candidate, we generate a candidate\-specific POST continuation underxb\+\(sb,n\)x\_\{b\}^\{\+\}\(s\_\{b,n\}\)\. The PRE continuations collected for boundarybbremain frozen and are reused across all three candidates\. Each summary is scored using Equation[4](https://arxiv.org/html/2608.06503#S4.E4), so differences among candidates arise only from their POST behavior rather than from variation in the PRE control\.
For each boundary, we retain the highest\- and lowest\-scoring candidates,
sb\+=argmaxsb,nQb\(sb,n\),sb−=argminsb,nQb\(sb,n\),s\_\{b\}^\{\+\}=\\arg\\max\_\{s\_\{b,n\}\}Q\_\{b\}\(s\_\{b,n\}\),\\qquad s\_\{b\}^\{\-\}=\\arg\\min\_\{s\_\{b,n\}\}Q\_\{b\}\(s\_\{b,n\}\),\(6\)forming 12 boundary\-matched contrastive examples:
𝒟pref=\{\(Ib,sb\+,sb−\)\}b=112\.\\mathcal\{D\}\_\{\\mathrm\{pref\}\}=\\left\\\{\\bigl\(I\_\{b\},s\_\{b\}^\{\+\},s\_\{b\}^\{\-\}\\bigr\)\\right\\\}\_\{b=1\}^\{12\}\.\(7\)
#### System\-aware prompt proposal\.
During preliminary experiments, we found that guidelines inferred solely from contrastive summaries could contradict the frozen downstream system prompt\. For example, when an incorrect variable name in a summary caused an execution error, the proposer often added a rule such as “variables from previous sessions are not preserved,” even though the system prompt explicitly states, “You can use the variables from the previous code blocks in the subsequent code blocks\.”
We therefore provide the proposer with the downstream system prompt in addition to the incumbent compression template and preference examples\. The proposer is instructed to first examine whether either summary in a pair introduces information or directives inconsistent with the system prompt, and then use the contrastive pairs to infer revisions to the compression policy\.
The proposer observes only the compressor inputs and the better–worse summary pairs\. It does not observe the subsequent rollout actions, environment observations, blocked\-action errors, repeated\-call indicators, or verifier decomposition\. This prevents it from directly encoding individual rollout failures into the template\.
A frozen proposer generates five complete candidate templates:
\{P1,…,P5\}=G\(P0,Hsys,𝒟pref\),\\\{P\_\{1\},\\ldots,P\_\{5\}\\\}=G\\\!\\left\(P\_\{0\},H\_\{\\mathrm\{sys\}\},\\mathcal\{D\}\_\{\\mathrm\{pref\}\}\\right\),\(8\)whereHsysH\_\{\\mathrm\{sys\}\}is the frozen downstream system prompt\. Each candidate preserves the original summary schema, section structure, placeholders, renderer, compression budget, and downstream interface\. Only the natural\-language instructions governing what the compressor retains, updates, and removes are revised\.
#### End\-to\-end development selection\.
Boundary\-local verifier scores are used to construct the contrastive supervision, but the final template is selected by end\-to\-end agent performance\. For each proposed templatePmP\_\{m\}, we run the complete recurrent compression and execution pipeline twice on every task in the AppWorld development split\. LetYt,r\(Pm\)∈\{0,1\}Y\_\{t,r\}\(P\_\{m\}\)\\in\\\{0,1\\\}indicate whether runr∈\{1,2\}r\\in\\\{1,2\\\}succeeds on tasktt\. We compute
Pass2\(Pm\)=1\|𝒟dev\|∑t∈𝒟devYt,1\(Pm\)Yt,2\(Pm\),\\mathrm\{Pass\}^\{2\}\(P\_\{m\}\)=\\frac\{1\}\{\|\\mathcal\{D\}\_\{\\mathrm\{dev\}\}\|\}\\sum\_\{t\\in\\mathcal\{D\}\_\{\\mathrm\{dev\}\}\}Y\_\{t,1\}\(P\_\{m\}\)Y\_\{t,2\}\(P\_\{m\}\),\(9\)which measures the fraction of development tasks completed successfully in both runs\. The selected template is
P⋆=argmaxPm,m∈\{1,…,5\}Pass2\(Pm\)\.P^\{\\star\}=\\arg\\max\_\{P\_\{m\},\\;m\\in\\\{1,\\ldots,5\\\}\}\\mathrm\{Pass\}^\{2\}\(P\_\{m\}\)\.\(10\)
Thus, terminal outcomes are not used to construct individual summary preferences: those preferences are determined exclusively by the boundary\-local execution verifier\. Terminal performance is used only at the final model\-selection stage on the development split\. After selection,P⋆P^\{\\star\}is frozen and evaluated on the test split without further prompt revision\.
## 5Preliminary Experiments
### 5\.1Experimental Setup
Evaluation Datasets\.We evaluate on AppWorld, a representative long\-horizon tool\-use benchmark\(Trivediet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib29)\)\. We optimize prompts on the training split, select the prompt on the development split, and report final results on the test\-normal split\. We use a compression window of 4,096 tokens and cap each agent rollout at 50 steps\. Results on additional benchmarks will be included in future work\.
Tool\-use Agent and Compressor Models\.In our experiments, we evaluate MiniMax\-M3\(MiniMax,[2026](https://arxiv.org/html/2608.06503#bib.bib32)\)and Kimi\-K2\.7\-Code\(Moonshot AI,[2026](https://arxiv.org/html/2608.06503#bib.bib33)\)\. For optimization, we use MiniMax\-M3 as the frozen LLM proposer\. Both models are accessed directly through Ollama\.222[https://ollama\.com/](https://ollama.com/)
Baselines\.We use the uncompressed full context as the reference\. Baselines include FIFO truncation, LLMLingua\-2 token pruning\(Panet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib8)\), the OpenClaw compaction prompt\(OpenClaw Contributors,[2026a](https://arxiv.org/html/2608.06503#bib.bib25)\), the Hermes compaction prompt\(Nous Research,[2026](https://arxiv.org/html/2608.06503#bib.bib27)\)333Adapted from the Hermes agent context compressor:[https://github\.com/NousResearch/hermes\-agent/blob/cca3b77a4b4217bb13288f0c4cac9710d82432c8/agent/context\_compressor\.py](https://github.com/NousResearch/hermes-agent/blob/cca3b77a4b4217bb13288f0c4cac9710d82432c8/agent/context_compressor.py)\., and the ACON guidelines optimized on AppWorld, ACON\-UT and ACON\-UTCO\(Kanget al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib19)\)\. More details are in Appendix[A](https://arxiv.org/html/2608.06503#A1)\. TheTRACEprompt is provided in Appendix[B](https://arxiv.org/html/2608.06503#A2)\.
Evaluation Metrics\.For performance, we report the average single\-run pass rate,Pass2\\mathrm\{Pass\}^\{2\}, andPass@2\\mathrm\{Pass@2\}to capture both overall success and multi\-run stability\. For efficiency, we report the average number of agent steps and peak input tokens per task\.
### 5\.2Main Results
Table[5\.2](https://arxiv.org/html/2608.06503#S5.SS2)reports results on AppWorld test\-normal\. All compression methods reduce performance relative to uncompressed execution, with the degradation becoming substantially larger on medium and hard tasks\. Among the existing compressed baselines, Prompting\-O performs best overall, achieving an average accuracy of71\.471\.4, Pass2of59\.559\.5, and Pass@2 of83\.383\.3\.
Using the automatically optimized compression prompt,TRACEis the strongest compressed method overall\. It improves over Prompting\-O by5\.75\.7points in accuracy \(77\.177\.1vs\.71\.471\.4\),7\.87\.8points in Pass2\(67\.367\.3vs\.59\.559\.5\), and3\.63\.6points in Pass@2 \(86\.986\.9vs\.83\.383\.3\)\. The larger improvement in Pass2indicates that the optimized prompt improves not only average task success, but also the consistency of successful execution across the two independent runs\.
The effect varies with task difficulty\. On easy tasks,TRACEnearly matches no compression, reaching94\.794\.7accuracy and tying its Pass2of91\.291\.2\. On medium tasks, it obtains the highest accuracy and Pass@2 among compressed methods, although LLMLingua\-2 achieves a higher Pass2\. On hard tasks,TRACEconsistently outperforms every compressed baseline across all three metrics, reaching63\.563\.5accuracy,52\.452\.4Pass2, and74\.674\.6Pass@2\.
Despite these improvements, a substantial gap from uncompressed execution remains, particularly on medium and hard tasks\. Nevertheless, the consistent gains over existing compression methods show that boundary\-local contrastive feedback can produce a more reliable compression prompt without updating any model parameters\.
Table 1:Results across different difficulty levels on theAppWorldbenchmark \(test\-normal\)\. Acc\., Pass2, and Pass@2 denote mean success over two independent runs, the fraction of tasks solved in both runs, and the fraction solved at least once, respectively\.No compressionis the uncompressed baseline\. Among compressed methods, column\-wise best is inbold; our results are highlighted inblue\.### 5\.3Efficiency
Figure 6:Efficiency across task difficulty\.Average peak input tokens versus average agent steps on AppWorld test\-normal, grouped by task difficulty\. Lower\-left is better\. Red dashed circles highlightTRACE\.Figure[6](https://arxiv.org/html/2608.06503#S5.F6)compares the context and execution costs of different compression methods\. On easy tasks, all methods operate within a relatively narrow range, as these shorter trajectories require little compression\. The differences become more pronounced on medium and hard tasks, where the peak context of the full\-context agent grows substantially\.
Compression generally reduces peak context size, but aggressive reduction can increase execution cost\. FIFO illustrates this trade\-off most clearly: it uses the fewest tokens, yet requires substantially more steps on medium and hard tasks, suggesting that discarded state must be repeatedly recovered during execution\. Other compression baselines exhibit similar, though less severe, increases in trajectory length\.
In contrast,TRACEmaintains an average step count close to the full\-context reference while substantially reducing peak tokens\. This advantage is most visible on hard tasks, whereTRACEremains near the full\-context execution length despite using less than half of its peak context\. The results indicate that optimizing against compression\-induced regressive exploration improves not only task performance but also the context–execution efficiency trade\-off\.
### 5\.4Cross\-Model Transferability
Table 2:Cross\-model transfer of the compression template optimized with MiniMax\-M3 and evaluated with Kimi\-K2\.7\-Code on AppWorld test\-normal\.We further evaluate whether the compression template optimized with MiniMax\-M3 transfers to a different model\. Without any additional prompt optimization, we apply the same template to Kimi\-K2\.7\-Code, using Kimi\-K2\.7\-Code as both the compressor and downstream agent\.
As shown in Table[5\.4](https://arxiv.org/html/2608.06503#S5.SS4), the transferredTRACEtemplate substantially outperforms all compressed baselines\. It also exceeds no compression in overall accuracy \(84\.584\.5vs\.82\.782\.7\) and Pass2\(79\.279\.2vs\.73\.873\.8\), while achieving a slightly lower Pass@2 \(89\.989\.9vs\.91\.791\.7\)\. This pattern suggests that the transferred template improves the consistency of successful execution, although it does not fully match the task coverage of uncompressed context\.
The gains are particularly strong on medium tasks, whereTRACEoutperforms no compression across all three metrics, including a20\.820\.8\-point improvement in Pass2\(81\.281\.2vs\.60\.460\.4\)\. It also exceeds no compression on easy tasks\. On hard tasks,TRACEremains below the uncompressed reference but substantially outperforms every compressed baseline\.
These results provide evidence that the compression policy learned with MiniMax\-M3 transfers to Kimi\-K2\.7\-Code without further adaptation\. However, because the evaluation considers a single target model, broader cross\-model generalization remains to be established\.
## 6Related Work
Long\-horizon LLM agents\.LLM agents extend pretrained models from one\-shot generation to interactive decision\-making, where the model repeatedly reasons, calls tools, observes outcomes, and revises its plan\(Yaoet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib1); Shinnet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib2); Wanget al\.,[2024b](https://arxiv.org/html/2608.06503#bib.bib3)\)\. These trajectories turn context into an operational state rather than a passive input: the agent must retain goals, tool outputs, object identifiers, intermediate decisions, and failure signals over many steps\. Context\-management systems such as MemGPT manage long interactions through explicit memory tiers\(Packeret al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib4)\), but they do not directly optimize which compact context best preserves a specified downstream system’s future actions\. We study this dynamic context bottleneck for long\-horizon agents, where compression must support action rather than only preserve a transcript\.
Context compression for action\.Prompt and context compression reduces the cost of long inputs by pruning tokens, generating compact textual contexts, or learning continuous compressed representations\. Discrete or textual methods include Selective Context, LLMLingua, LongLLMLingua, LLMLingua\-2, RECOMP, and TACO–RL\(Liet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib5); Jianget al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib6);[2024](https://arxiv.org/html/2608.06503#bib.bib7); Panet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib8); Xuet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib9); Shandilyaet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib10)\); continuous compression methods include AutoCompressor, Gist tokens, ICAE, Activation Beacon, 500×\\timesCompressor, and ComprExIT\(Chevalieret al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib11); Muet al\.,[2023](https://arxiv.org/html/2608.06503#bib.bib12); Geet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib13); Zhanget al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib14); Liet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib15); Yeet al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib16)\)\. These methods mainly optimize information retention, answer quality, or decoding efficiency\. TACO–RL\(Shandilyaet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib10)\)is closest within this family because it optimizes prompt compression with task rewards, but it targets static prompts and single\-shot downstream outputs rather than repeated compact contexts for preserving future behavior\.
Recent work moves closer to agent\-specific context management\. ReSum and SUPO adapt agents to operate with summaries by optimizing summarization together with downstream tool\-use behavior\(Wuet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib17); Luet al\.,[2025](https://arxiv.org/html/2608.06503#bib.bib18)\)\. In contrast, we keep the downstream system fixed and optimize only the compression module\. ACON is closest to our setting because it also optimizes natural\-language compression guidelines for fixed long\-horizon agents\(Kanget al\.,[2026](https://arxiv.org/html/2608.06503#bib.bib19)\)\. However, ACON derives feedback from terminally successful and failed trajectories, whereas TRACE evaluates individual compression events through paired closed\-loop continuations from the same execution state\. Our method therefore optimizes the compression prompt using boundary\-local preferences over compression\-induced execution burden\.
## 7Conclusion and Future Work
We show that recurrent context compression can make previously established execution state less actionable, inducing blocked actions, repeated exploration, and unstable task performance\. To address this, we introduceTRACE, a boundary\-local framework that evaluates compression through paired closed\-loop continuations and optimizes the compression prompt using preference\-only feedback\. On AppWorld,TRACEimproves task performance and multi\-run stability while approaching full\-context execution efficiency relative to existing compressed baselines\.
Our current verifier focuses on observable execution regressions, particularly blocked and repeated actions, and may not capture silent state corruption\. Future work will develop richer boundary\-local signals, evaluate transfer across additional agents and benchmarks, and extend prompt optimization to learned compressors\.
## References
- τ2\\tau^\{2\}\-Bench: evaluating conversational agents in a dual\-control environment\.arXiv preprint arXiv:2506\.07982\.External Links:[Link](https://arxiv.org/pdf/2506.07982)Cited by:[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p4.9)\.
- A\. Chevalier, A\. Wettig, A\. Ajith, and D\. Chen \(2023\)Adapting language models to compress contexts\.InThe 2023 Conference on Empirical Methods in Natural Language Processing,External Links:[Link](https://openreview.net/forum?id=kp1U6wBPXq)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- T\. Ge, H\. Jing, L\. Wang, X\. Wang, S\. Chen, and F\. Wei \(2024\)In\-context autoencoder for context compression in a large language model\.InThe Twelfth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=uREj4ZuGJE)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- H\. Jiang, Q\. Wu, C\. Lin, Y\. Yang, and L\. Qiu \(2023\)LLMLingua: compressing prompts for accelerated inference of large language models\.InProceedings of the 2023 Conference on Empirical Methods in Natural Language Processing,H\. Bouamor, J\. Pino, and K\. Bali \(Eds\.\),Singapore,pp\. 13358–13376\.External Links:[Link](https://aclanthology.org/2023.emnlp-main.825/),[Document](https://dx.doi.org/10.18653/v1/2023.emnlp-main.825)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- H\. Jiang, Q\. Wu, X\. Luo, D\. Li, C\. Lin, Y\. Yang, and L\. Qiu \(2024\)LongLLMLingua: accelerating and enhancing LLMs in long context scenarios via prompt compression\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),L\. Ku, A\. Martins, and V\. Srikumar \(Eds\.\),Bangkok, Thailand,pp\. 1658–1677\.External Links:[Link](https://aclanthology.org/2024.acl-long.91/),[Document](https://dx.doi.org/10.18653/v1/2024.acl-long.91)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- M\. Kang, W\. Chen, D\. Han, H\. A\. Inan, L\. Wutschitz, Y\. Chen, R\. Sim, and S\. Rajmohan \(2026\)ACON: optimizing context compression for long\-horizon LLM agents\.InForty\-third International Conference on Machine Learning,External Links:[Link](https://openreview.net/forum?id=5EmOOLtH5P)Cited by:[§A\.4](https://arxiv.org/html/2608.06503#A1.SS4.p1.1),[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§2\.2](https://arxiv.org/html/2608.06503#S2.SS2.p1.7),[§4\.2](https://arxiv.org/html/2608.06503#S4.SS2.p1.1),[§4](https://arxiv.org/html/2608.06503#S4.p2.1),[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p3.1),[§6](https://arxiv.org/html/2608.06503#S6.p3.1)\.
- Y\. Li, B\. Dong, F\. Guerin, and C\. Lin \(2023\)Compressing context to enhance inference efficiency of large language models\.InProceedings of the 2023 Conference on Empirical Methods in Natural Language Processing,H\. Bouamor, J\. Pino, and K\. Bali \(Eds\.\),Singapore,pp\. 6342–6353\.External Links:[Link](https://aclanthology.org/2023.emnlp-main.391/),[Document](https://dx.doi.org/10.18653/v1/2023.emnlp-main.391)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- Z\. Li, Y\. Su, and N\. Collier \(2025\)500xCompressor: generalized prompt compression for large language models\.InProceedings of the 63rd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),W\. Che, J\. Nabende, E\. Shutova, and M\. T\. Pilehvar \(Eds\.\),Vienna, Austria,pp\. 25081–25091\.External Links:[Link](https://aclanthology.org/2025.acl-long.1219/),[Document](https://dx.doi.org/10.18653/v1/2025.acl-long.1219)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- M\. Lu, W\. Sun, W\. Du, Z\. Ling, X\. Yao, K\. Liu, and J\. Chen \(2025\)Scaling llm multi\-turn rl with end\-to\-end summarization\-based context management\.arXiv preprint arXiv:2510\.06727\.External Links:[Link](https://arxiv.org/pdf/2510.06727)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§2\.2](https://arxiv.org/html/2608.06503#S2.SS2.p1.7),[§6](https://arxiv.org/html/2608.06503#S6.p3.1)\.
- MiniMax \(2026\)MiniMax m3: frontier coding, 1m context, native multimodality — all in one model\.External Links:[Link](https://www.minimax.io/blog/minimax-m3)Cited by:[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p2.1),[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p2.1)\.
- Moonshot AI \(2026\)Kimi k2\.7 code: an open\-source, coding\-focused agentic model built for long\-horizon software engineering\.\.External Links:[Link](https://www.kimi.com/resources/kimi-k2-7-code)Cited by:[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p2.1)\.
- J\. Mu, X\. L\. Li, and N\. Goodman \(2023\)Learning to compress prompts with gist tokens\.InThirty\-seventh Conference on Neural Information Processing Systems,External Links:[Link](https://openreview.net/forum?id=2DtxPCL3T5)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- Nous Research \(2026\)Hermes Agent Documentation: context compression and caching\.Note:[https://hermes\-agent\.nousresearch\.com/docs/developer\-guide/context\-compression\-and\-caching](https://hermes-agent.nousresearch.com/docs/developer-guide/context-compression-and-caching)Accessed: 2026\-06\-15Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§2\.2](https://arxiv.org/html/2608.06503#S2.SS2.p1.7),[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p2.1),[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p3.1)\.
- OpenClaw Contributors \(2026a\)OpenClaw Documentation: compaction\.Note:[https://docs\.openclaw\.ai/concepts/compaction](https://docs.openclaw.ai/concepts/compaction)Accessed: 2026\-06\-15Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§2\.2](https://arxiv.org/html/2608.06503#S2.SS2.p1.7),[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p2.1),[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p3.1)\.
- OpenClaw Contributors \(2026b\)OpenClaw Documentation: session pruning\.Note:[https://docs\.openclaw\.ai/concepts/session\-pruning](https://docs.openclaw.ai/concepts/session-pruning)Accessed: 2026\-06\-15Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1)\.
- C\. Packer, V\. Fang, S\. Patil, K\. Lin, S\. Wooders, and J\. Gonzalez \(2023\)MemGPT: towards llms as operating systems\.\.External Links:[Link](https://arxiv.org/pdf/2310.08560)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p1.1)\.
- Z\. Pan, Q\. Wu, H\. Jiang, M\. Xia, X\. Luo, J\. Zhang, Q\. Lin, V\. Rühle, Y\. Yang, C\. Lin, H\. V\. Zhao, L\. Qiu, and D\. Zhang \(2024\)LLMLingua\-2: data distillation for efficient and faithful task\-agnostic prompt compression\.InFindings of the Association for Computational Linguistics: ACL 2024,L\. Ku, A\. Martins, and V\. Srikumar \(Eds\.\),Bangkok, Thailand,pp\. 963–981\.External Links:[Link](https://aclanthology.org/2024.findings-acl.57/),[Document](https://dx.doi.org/10.18653/v1/2024.findings-acl.57)Cited by:[§A\.2](https://arxiv.org/html/2608.06503#A1.SS2.p3.1),[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p3.1),[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- S\. Shandilya, M\. Xia, S\. Ghosh, H\. Jiang, J\. Zhang, Q\. Wu, V\. Rühle, and S\. Rajmohan \(2025\)Taco\-rl: task aware prompt compression optimization with reinforcement learning\.InFindings of the Association for Computational Linguistics: ACL 2025,pp\. 1582–1597\.External Links:[Link](https://aclanthology.org/2025.findings-acl.81.pdf)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- N\. Shinn, F\. Cassano, A\. Gopinath, K\. R\. Narasimhan, and S\. Yao \(2023\)Reflexion: language agents with verbal reinforcement learning\.InThirty\-seventh Conference on Neural Information Processing Systems,External Links:[Link](https://openreview.net/forum?id=vAElhFcKW6)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p1.1),[§6](https://arxiv.org/html/2608.06503#S6.p1.1)\.
- H\. Trivedi, T\. Khot, M\. Hartmann, R\. Manku, V\. Dong, E\. Li, S\. Gupta, A\. Sabharwal, and N\. Balasubramanian \(2024\)Appworld: a controllable world of apps and people for benchmarking interactive coding agents\.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 16022–16076\.External Links:[Link](https://aclanthology.org/2024.acl-long.850/)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p1.1),[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p2.1),[§5\.1](https://arxiv.org/html/2608.06503#S5.SS1.p1.1)\.
- C\. Wang, Q\. Wu, and the AG2 Community \(2024a\)AG2: open\-source agentos for ai agentsNote:Available at https://docs\.ag2\.ai/External Links:[Link](https://github.com/ag2ai/ag2)Cited by:[§2\.2](https://arxiv.org/html/2608.06503#S2.SS2.p1.7),[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p2.1)\.
- X\. Wang, Y\. Chen, L\. Yuan, Y\. Zhang, Y\. Li, H\. Peng, and H\. Ji \(2024b\)Executable code actions elicit better LLM agents\.InForty\-first International Conference on Machine Learning,External Links:[Link](https://openreview.net/forum?id=jJ9BoXAfFa)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p1.1),[§6](https://arxiv.org/html/2608.06503#S6.p1.1)\.
- Z\. Wang, Y\. Cui, L\. Zhong, Z\. Zhang, D\. Yin, B\. Y\. Lin, and J\. Shang \(2024c\)Officebench: benchmarking language agents across multiple applications for office automation\.arXiv preprint arXiv:2407\.19056\.External Links:[Link](https://arxiv.org/pdf/2407.19056)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p1.1)\.
- X\. Wu, K\. Li, Y\. Zhao, L\. Zhang, L\. Ou, H\. Yin, Z\. Zhang, X\. Yu, D\. Zhang, Y\. Jiang,et al\.\(2025\)Resum: unlocking long\-horizon search intelligence via context summarization\.arXiv preprint arXiv:2509\.13313\.External Links:[Link](https://arxiv.org/pdf/2509.13313)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§6](https://arxiv.org/html/2608.06503#S6.p3.1)\.
- F\. Xu, W\. Shi, and E\. Choi \(2024\)RECOMP: improving retrieval\-augmented LMs with context compression and selective augmentation\.InThe Twelfth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=mlJLVigNHp)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p2.1),[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- S\. Yao, N\. Shinn, P\. Razavi, and K\. R\. Narasimhan \(2025\)τ\\tau\-Bench: a benchmark for tool\-agent\-user interaction in real\-world domains\.InThe Thirteenth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=roNSXZpUDN)Cited by:[§3\.1](https://arxiv.org/html/2608.06503#S3.SS1.p4.9)\.
- S\. Yao, J\. Zhao, D\. Yu, N\. Du, I\. Shafran, K\. R\. Narasimhan, and Y\. Cao \(2023\)ReAct: synergizing reasoning and acting in language models\.InThe Eleventh International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=WE_vluYUL-X)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p1.1),[§6](https://arxiv.org/html/2608.06503#S6.p1.1)\.
- J\. Ye, H\. Yan, Z\. Shen, H\. Chang, Y\. Mao, and Y\. He \(2026\)Context compression via explicit information transmission\.arXiv preprint arXiv:2602\.03784\.External Links:[Link](https://arxiv.org/pdf/2602.03784)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- P\. Zhang, Z\. Liu, S\. Xiao, N\. Shao, Q\. Ye, and Z\. Dou \(2025\)Long context compression with activation beacon\.InThe Thirteenth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=1eQT9OzfNQ)Cited by:[§6](https://arxiv.org/html/2608.06503#S6.p2.1)\.
- S\. Zhou, F\. F\. Xu, H\. Zhu, X\. Zhou, R\. Lo, A\. Sridhar, X\. Cheng, T\. Ou, Y\. Bisk, D\. Fried,et al\.\(2024\)Webarena: a realistic web environment for building autonomous agents\.InInternational Conference on Learning Representations,Vol\.2024,pp\. 15585–15606\.External Links:[Link](https://arxiv.org/pdf/2307.13854)Cited by:[§1](https://arxiv.org/html/2608.06503#S1.p1.1)\.
## Appendix ADetails of Baselines
This section describes the compression baselines used in our experiments\. Unless otherwise specified, all conditions are evaluated under the same frozen\-agent protocol: the downstream agent model, tool\-use prompt, decoding configuration, tool APIs, output parser, and execution environment are fixed\. Only the context supplied to the agent is changed\. This protocol isolates the effect of context representation from changes in the downstream agent policy\.
Shared Evaluation Protocol\.All compression and truncation baselines use the same recurrent\-compaction trigger and preserve the most recent interaction turn verbatim\. The full\-context reference bypasses compaction and retains the complete interaction history\. Across all conditions, we keep the downstream tool\-use prompt, tool descriptions, output\-format instructions, few\-shot examples, decoding configuration, parser, and execution environment fixed\. Replacement contexts are inserted at the same continuation point, so differences in downstream behavior arise from the supplied context representation rather than from a changed agent policy or interface\.
Because prompt\-defined baselines can be sensitive to small wording changes, we freeze all prompt templates before evaluation and record hashes of the rendered prompts used in each run\. For ACON, the source of truth is the original Microsoft repository and commit specified below\. For LLMLingua\-2, the source of truth is the official Microsoft implementation and released compression model\.
### A\.1Full\-Context Reference
No compression\.The agent receives the full uncompressed interaction history\. This condition serves as the full\-context reference for behavior preservation and as the reference point for token\-cost measurements\. It is not a compressor and does not separately consume the task instruction, which is already included in the agent context\.
### A\.2Token Pruning and Truncation Baselines
This group contains two non\-generative baselines\. Rather than producing a new free\-form summary, they retain selected portions of the original interaction history\. Both use the same compaction trigger, downstream context slot, and recent\-turn preservation policy as the generative baselines\. Compaction is triggered when the compressible history exceeds the context budget, while the most recent interaction turn remains verbatim\.
FIFO\.FIFO is a recency\-based sliding\-window control\. When the rendered compressible history exceeds the context budget, complete turns are discarded from the front, oldest first, until the history fits\. The system prompt, original task instruction, and most recent interaction turn are always retained\. FIFO therefore isolates how much behavior can be preserved through recent action–observation continuity alone, without learned salience estimation or generated summary text\.
LLMLingua\-2\.LLMLingua\-2 formulates prompt compression as token classification and distills a smaller compressor for efficient and faithful extractive compression\(Panet al\.,[2024](https://arxiv.org/html/2608.06503#bib.bib8)\)\. We apply it task\-agnostically to the compressible interaction history using the releasedmicrosoft/llmlingua\-2\-xlm\-roberta\-large\-meetingbankmodel\. When compaction is triggered, LLMLingua\-2 selects tokens from the existing history up to the target budget\. The resulting extractive context replaces the older turns, while the most recent turn remains verbatim\. This baseline tests whether token\-level salience alone preserves the execution state required for future agent actions\.
Implementation\.We use the official Microsoft LLMLingua implementation\.444[https://github\.com/microsoft/LLMLingua](https://github.com/microsoft/LLMLingua), version0\.2\.2\(release tagv0\.2\.2, commita411a3fa61df74411157b2512b592d5357bd8f17\)\.For LLMLingua\-2, the target token count is set to the budget allocated to the compressible history, excluding the most recent turn that is retained verbatim\. Its compressed output is inserted into the same downstream context slot used by the other compression baselines\.
### A\.3Structured\-Summary Compression Baselines
Our two structured\-summary baselines are adapted from compaction modules in open\-source agent frameworks\. We preserve their original summary schemas and prompt text while integrating them into the same recurrent\-compaction harness\. Unlike the token\-dropping LLMLingua\-2 baseline and the recency\-based FIFO control, both invoke an auxiliary LLM to rewrite the compressible history into a structured Markdown checkpoint after the context exceeds the token budget\. They preserve the most recent interaction turn and support iterative updates that fold new turns into the previous checkpoint\.
#### Prompting\-O \(OpenClaw compaction\)\.
`OpenClaw summarization system prompt OpenClaw first\-compaction prompt OpenClaw iterative\-update prompt`
`Prompting\-H \(Hermes\-agent compaction\)\. The Hermes baseline666Adapted from the Hermes agent context compressor: https://github\.com/NousResearch/hermes\-agent/blob/cca3b77a4b4217bb13288f0c4cac9710d82432c8/agent/context\_compressor\.py \(commit cca3b77a4b4217bb13288f0c4cac9710d82432c8\)\. summarizes middle turns while protecting a token\-budgeted head and tail\. Its schema is richer than OpenClaw’s, with separate fields for Active Task, Resolved Questions, and Pending User Asks\. Every emitted checkpoint is also prefixed with a reference\-only instruction that asks the downstream agent to treat the summary as background rather than as live instructions, providing an explicit guard against re\-executing already\-completed actions\. Hermes summarizer preamble Hermes structured checkpoint template Hermes reference\-only summary prefix \(prepended to every checkpoint\) A\.4 ACON Prompt Baselines We compare against two compression guidelines from ACON \(Kang et al\., 2026\), a recent framework for optimizing context compression for long\-horizon LLM agents\. Both guidelines are loaded verbatim from the original Microsoft ACON repository\.777https://github\.com/microsoft/acon\. We use commit d63f9ae18959dc7215ff62899c94c5e8c56847ae\. We do not hand\-author or rewrite their prompt text\. The same guideline is used for the first compaction and every subsequent iterative compaction\. The prompt accepts the most recent previous summary as an additional input, so no separate update prompt is required\. Shared system prompt for ACON ACON\-UT\. ACON’s utility\-oriented, state\-preserving history\-compression guideline\. It organizes the summary into reasoning, a vars table of runtime values the next session must re\-declare, todo, completed, and guardrails\. It instructs the compressor to preserve essential facts, parameters, and artifacts\. ACON\-UT compression guideline ACON\-UTCO\. ACON’s utility\-and\-compression\-optimized guideline\. It retains the output schema of ACON\-UT while adding explicit compression rules that encourage a shorter checkpoint\. These rules collapse narratives, truncate long token or credential strings unless verbatim reuse is required, remove unused state and verbose tool output, and impose a fixed character target\. Relative to ACON\-UT, it preserves the same output schema while trading finer operational detail for a shorter checkpoint\. ACON\-UTCO compression guideline Appendix B Trace Prompts B\.1 Optimized Prompt Trace Optimized Update Prompt B\.2 Proposer Prompt We use MiniMax\-M3 for proposing\. Proposer Prompt`相似文章
上下文压缩应该保留什么?我观察了六种智能体的处理方式[D]
分析六种AI编程智能体(Claude Code、Codex CLI、OpenCode、Cline、Cursor、Amp)如何趋同于分层渐进式压缩以处理长上下文,它们在保护内容(用户消息、有状态工具输出)以及是否告知模型压缩方面存在差异,并在成本与准确性之间进行权衡。
超越压缩:面向长周期智能体的结构化上下文驱逐
介绍了上下文窗口生命周期(CWL),这是一种面向长周期LLM智能体的结构化上下文驱逐方案,通过基于依赖图驱逐内容来维持有效无界的工作视野,避免了基于摘要的压缩和最近截断的局限性。
@dair_ai:微软新论文:在测试时压缩智能体上下文。如果你的智能体随着交互历史变多而性能下降……
Microsoft 的 M365 Research 提出了 FOCUS,这是一种无需训练的测试时方法,通过仅保留对未来决策产生因果影响的单元来压缩 LLM 智能体的交互历史,最多可将峰值上下文降低 48%,并将任务成功率相比全历史执行提升最多 8.9 个百分点。
TRACE:面向长周期智能体安全的轨迹风险感知压缩方法
本文提出 TRACE,一种面向长周期 LLM 智能体的轨迹级安全检测方法,通过将完整轨迹证据压缩为潜在状态,更好地聚合分散的风险信号,在多个基准上达到最先进的准确率。
一种基于观测上下文压缩的高效终端智能体自我演化框架
TACO 提出了一种自我演化压缩框架,可自动学习压缩冗余的终端交互历史,在 TerminalBench 及其他代码智能体基准上将 token 开销降低约 10%,准确率提升 1–4%。