Large language model (LLM) agents typically append raw tool outputs to their context. Over multi-step interactions, long and noisy observations incur substantial context overhead and dilute the agent's attention to task-relevant information. Existing token pruning and summarization methods remain constrained by discrete text representations, limiting the achievable compression ratios. In this work, we challenge the prevailing assumption that agents must consume tool observations as explicit text tokens. To this end, we propose Coca-Cola, a continuous latent context compression model for LLM agents. Coca-Cola compresses tool observations into latent tokens and embeds them into the input embedding space of the agent. We further introduce Action-Preserving Training, which aligns the agent's next-action distributions under full and compressed observations. This trains the compression model to learn action-sufficient latent tokens that retain decision-critical information. Experiments with web-search agents on four QA benchmarks and two model families show that Coca-Cola reduces the agent's token consumption by 70.01%-89.24% and end-to-end runtime by 24.45%-55.97%, while consistently improving task performance. These results suggest that Coca-Cola offers a promising approach for context compression in agents. Our code is available at https://github.com/THU-Agent/Coca-cola.
Figures & tables
Figure 1: Tool observation redundancy in LLM agents. Left: Tool returns increasingly dominate the agent context, accounting for 96.7% of total tokens by Step 4, while individual observations exhibit substantial length. Right: A representative web-search example illustrating that only a few fragments of a lengthy tool output are relevant to the agent’s next decision.
Figure 2: Overview of Coca-Cola. Left: The latent tool bottleneck encodes raw tool observations into compact continuous latent representations, conditioned on the task instruction and current reasoning state. Middle: Action-preserving distillation aligns the next-action distributions of a full-observation teacher and a latent-conditioned student, updating only the compressor while keeping the agent backbone frozen. Right: During inference, raw tool observations are replaced by latent representations after each tool call, enabling efficient multi-step agent interactions.
NQ
TriviaQA
Vanilla
LongLLM Lingua
LLM Summary
ICAE
Coca-Cola
Vanilla
LongLLM Lingua
LLM Summary
ICAE
Coca-Cola
Itoken↓
14362.12
8607.04
6099.83
5926.23
1766.53 [1.5pt] ↓ 87.7%
10022.93
5445.57
3791.53
3038.35
1413.12 [1.5pt] ↓ 85.9%
Otoken↓
992.69
1232.61
1080.51
665.57
417.69 [1.5pt] ↓ 57.9%
779.34
1048.02
679.36
535.42
349.36 [1.5pt] ↓ 55.2%
Comp_rate↑
–
35.92%
53.24%
57.07%
85.78%
–
39.89%
58.61%
66.92%
83.68%
Time (s) ↓
96.19
109.48
121.02
87.06
64.64 [1.5pt] ↓ 32.8%
73.30
86.91
91.67
64.89
55.38 [1.5pt] ↓ 24.4%
2Wiki
HotpotQA
Table 1: Efficiency comparison across four web-search QA datasets using Qwen3.5-35B-A3B and Qwen3.5-4B. Best results are in bold. Blue annotations under Coca-Cola indicate reductions (%) relative to Vanilla in token usage and runtime.
NQ
TriviaQA
Vanilla
LongLLM Lingua
LLM Summary
ICAE
Coca-Cola
Vanilla
LongLLM Lingua
LLM Summary
ICAE
Coca-Cola
Itoken↓
17388.56
5779.61
3903.19
5068.65
4265.42 [1.5pt] ↓ 75.5%
11176.91
4689.20
2842.51
3510.28
2595.00 [1.5pt] ↓ 76.8%
Otoken↓
887.74
797.81
734.77
805.93
536.37 [1.5pt] ↓ 39.6%
738.96
688.27
634.84
617.94
413.28 [1.5pt] ↓ 44.1%
Comp_rate↑
–
64.01%
74.62%
67.86%
73.73%
–
54.87%
70.82%
65.36%
74.75%
Time (s) ↓
89.29
91.06
106.47
83.63
42.17 [1.5pt] ↓ 52.8%
91.36
89.93
128.36
72.33
41.97 [1.5pt] ↓ 54.1%
2Wiki
HotpotQA
Table 2: Efficiency comparison across four web-search QA datasets using GLM-4.7-Flash and GLM-Z1-9B. Best results are in bold. Blue annotations under Coca-Cola indicate reductions (%) relative to Vanilla in token usage and runtime.
Method
Single-hop QA
Multi-hop QA
NQ
TriviaQA
2Wiki
HotpotQA
EM
F1
EM
F1
EM
F1
EM
F1
Qwen3.5-35B-A3B & Qwen3.5-4B
Vanilla Model
23.67
33.17
56.10
62.87
17.30
26.94
11.00
16.41
LongLLMLingua
19.00
25.81
44.30
48.69
21.30
34.25
11.90
19.75
LLMSummary
24.65
32.35
54.70
61.38
21.06
31.77
23.10
29.60
Table 3: Web search performance comparison. Best results within each model setting are in bold. Arrows in the Coca-Cola rows indicate relative changes (%) over the Vanilla Model for each metric.
Figure 3: Effect of the number of latent tokens m on NQ (GLM-4.7-Flash & GLM-Z1-9B). F1 improves steadily as the latent budget increases.
As LLM agents tackle longer tasks, they increasingly compress growing histories of reasoning, actions, and tool outputs. Compression can reduce token use, but it also changes the information available for later decisions. Existing agentic harnesses bundle decisions about what to compress, when to compress, and how much to remove into fixed policies. A systematic characterization is needed to disentangle these decisions and reveal how each affects task success and execution cost. We systematically vary these decisions across three open-weight models on SWE-bench Verified and Terminal-Bench 1.0. Across nearly 35,000 agent runs, we measure task success, token use, end-to-end latency, and estimated cost. We find that fewer tokens need not mean faster or cheaper execution: on Terminal-Bench with Qwen, policies using roughly one-third as many tokens can take 20-80% longer than the uncompressed agent. Policies with similar overall success can solve different tasks, while the same policy can perform quite differently across models. Our results motivate evaluating compression by its effects on agent execution and tailoring policies to the task, model, and workload.
LLM agents accumulate interaction histories that grow linearly with task length, causing quadratic inference cost scaling and performance degradation from attention dilution. Existing context-compression methods learn what to discard offline: by contrastively optimizing guidelines, distilling compressors, or training compression policies. This incurs a substantial cost. Further, the compression policy is learned a priori and is not dynamically conditioned on the evolving test-time trajectories. In this paper we ask a complementary question: Which past interactions causally shape the agent's future decisions? We recast context compression as a causal decision preservation problem over discrete interaction units and introduce FOCUS, a training-free context compression framework that operates entirely at test time. Our method requires no offline data collection or fine-tuning, and is architecture-agnostic, attaching to any closed-API frontier model as a modular compression layer. We evaluate FOCUS on diverse agentic benchmarks including API and tool-calling, QA, web domain and multi-turn dialogue. Our method establishes new state of the art performance, cutting peak context by up to 48% and dependency by 73% while improving task success by up to 8.9 percentage points over uncompressed execution.
Long-horizon LLM agents play an important role in solving complex and sustained tasks, with ever-growing interaction contexts. However, these accumulated contexts will raise substantial computational cost and obscure key decision-relevant evidence. Existing methods typically train external compressors or context-management agents to rewrite context as shorter hard-token sequences, but such external selection may not align with the LLM's evolving representation and is necessarily lossy. In this paper, we introduce Agentic Soft-Token Compression (ASTC), a training-free compression method using soft tokens within LLM agent for long-horizon tasks. Specifically, ASTC uses the model's native recurrent dynamics to determine the already absorbed information, leveraging the commonly-used hybrid Gated Delta Network (GDN)-attention. It then carries this information forward as agentic soft tokens while retaining exact values as hard tokens. The resulting compact sequence reduces later-layer computation and yields reusable KV caches, extending the savings across the agent's trajectory. Extensive experiments on long-horizon tasks show that ASTC matches or exceeds the uncompressed agent's accuracy with up to 50.68% fewer end-to-end Attention Pairs, while trained compressors require 15.4 to 103.7 times more Attention Pairs per successful task. These findings highlight agentic soft tokens as a model-native way to carry absorbed context forward as the task representation evolves.
Xuning He, Kai Fan, Runyu Zhang +4
Shanghai Jiao Tong University · Nanyang Technological University · Nankai University +2