Long-horizon language-model agents accumulate increasingly large interaction histories, making context compaction essential for efficient execution. Existing learned compaction methods often rely on downstream task outcomes or solver behavior, coupling training to specific tasks or agents. We introduce SumOne, a standalone summarizer trained to preserve information in agent histories through masked reconstruction. Given a summary of the expired history, a frozen reconstructor recovers randomly masked portions of the original trajectory; reconstruction quality, combined with a length penalty, provides a task-agnostic reward for optimizing the summarizer with GRPO. This yields self-supervision directly from raw trajectories, without reference summaries or downstream task execution. At inference time, only the lightweight summarizer is retained, enabling plug-and-play context compression for otherwise unchanged agents. We conduct a systematic evaluation of SumOne in long-horizon search and software-engineering tasks. SumOne reduces estimated inference cost by approximately 78% on DeepSearchQA and 75% on SWE-bench Verified relative to operating with full context, with absolute decreases of 0.04. The same checkpoint also transfers across downstream models and agent harnesses without additional fine-tuning.
Figures & tables
Figure 1: SumOne is an efficient and scalable memory compressor for long-horizon agents. (a) A single 2B SumOne , trained solely from raw trajectories, can be plugged into different tasks, downstream models, and agent harnesses without specific adaptation. (b) SumOne consistently improves over self-summary in both task performance and inference cost, yielding a better performance–cost trade-off. The y -axis shows task success rate (resolved rate) on the SWE-bench Verified ( Jimenez et al., 2024a ) benchmark, while the x -axis shows total inference cost per query normalized by that of self-summary.
Figure 2: Overview of SumOne . The summarizer compresses the expired history into a short summary. A frozen reconstructor then attempts to recover masked parts of the original history conditioned on the summary and retained context, and the reconstruction score (with a length penalty) provides the reward to optimize the summarizer.
DeepSearchQA
Method
Score ↑
C. Ratio ↑
Input Tok. ↓
Sum. Cost ↓
Total Cost ↓
Comp./Q ↓
Full History
0.52
–
2.83M
–
$0.170
–
Recent Truncation
0.16
–
752K
–
$0.047
1.24
Self-Summary
0.44
91%
652K
$0.002
$0.044
1.68
Prompt-2B
0.29
92%
468K
$0.001
$0.031
1.24
CoMem
0.32
88%
577K
$0.001
$0.036
1.48
Table 1: Main results on DeepSearchQA and SWE-bench Verified. Score denotes task performance, measured by F1 on DeepSearchQA and the resolved rate on SWE-bench Verified. C. Ratio, Input Tok., Sum. Cost, Total Cost, and Comp./Q denote the compression ratio, the number of input tokens consumed by the agent, the summarization cost per query, the total inference cost per query, and the average number of compactions per query, respectively. Costs are reported in USD.
Table 4
Method
Overall ↑
Single ↑
Multi ↑
Temporal ↑
Update ↑
Sum. Cost ↓
C. Ratio ↑
Oracle
0.85
0.94
0.72
0.8
0.93
–
–
Full History
0.77
0.81
0.5
0.8
0.86
–
–
Prompt-2B
0.43
0.38
0.51
0.38
0.24
0.003
94%
CoMem
0.31
0.41
0.08
0.24
0.61
0.003
93%
SumOne
0.47
0.48
0.41
0.36
0.43
0.003
89%
Table 4: Isolated memory evaluation on LongMemEval-S. Single , Multi , Temporal , and Update denote single-session retrieval, multi-session reasoning, temporal reasoning, and knowledge-update questions, respectively. Sum. Cost denotes the normalized cost of memory summarization, and C. Ratio denotes compression ration defined in Section 4.1.
Downstream Agent Tasks
LongMemEval-S
Method
DSQA ↑
SWE ↑
Overall ↑
Single ↑
Multi ↑
Temp. ↑
Update ↑
Full History
0.52
0.63
0.77
0.81
0.5
0.8
0.86
Prompt-2B
0.29
0.51
0.43
0.38
0.51
0.38
0.24
Summ.-Judge-RL
0.41
0.54
0.36
0.40
0.14
0.31
0.71
Recon-RL (ours)
0.48
0.59
0.47
0.48
0.41
0.36
0.43
Table 5: Ablation on the training objective. All compressed variants use the same Qwen3.5-2B initialization and are evaluated under the same compression setting. We report downstream performance on DeepSearchQA and SWE-bench, together with direct memory evaluation on LongMemEval-S. Full History provides an uncompressed reference.
Table 6: Ablation on mask ratio and length penalty. We report performance on DeepSearchQA (DSQA) and LongMemEval-S (LongMem).
Hyperparameter
Value
Model and System
Base model
Qwen3.5-2B
Training framework
veRL
Hardware
8 × H20-141G
Sharding
FSDP full shard
Gradient checkpointing
Yes
Table 7: Training configuration and hyperparameters of SumOne .
Full History
Self-Summary
SumOne
Model
Score ↑
Cost ↓
Score ↑
Cost ↓
Score ↑
Cost ↓
Gemini 3.7 Flash
0.63
$0.82
0.52
$0.47
0.55
$0.39
GLM-5.3
0.74
$1.36
0.61
$0.78
0.66
$0.64
GPT-6 Luna
0.65
$0.14
0.54
$0.08
0.58
$0.07
DeepSeek V4.1 Flash
0.78
$0.42
0.66
$0.24
0.74
$0.20
Table 8: Cross-model generalization on SWE-bench Verified. We compare Full History, Self-Summary, and SumOne across different downstream agent models. Score denotes the resolved rate, and Cost denotes the average total inference cost per task in USD.
Full History
Self-Summary
SumOne
Model
F1 ↑
Cost ↓
F1 ↑
Cost ↓
F1 ↑
Cost ↓
Gemini 3.7 Flash
0.54
$0.58
0.51
$0.36
0.56
$0.29
GLM-5.3
0.42
$1.14
0.33
$0.72
0.40
$0.51
GPT-6 Luna
0.38
$0.04
0.40
$0.05
0.46
$0.04
DeepSeek V4.1 Flash
0.74
$0.38
0.59
$0.18
0.66
$0.15
Table 9: Cross-model generalization on DeepSearchQA. We compare Full History, Self-Summary, and SumOne across different downstream agent models. Cost denotes the average total inference cost per query in USD.
Model
Provider
Input
Output
GPT-6 Luna
OpenAI
$0.20
$1.20
DeepSeek V4.1 Flash
DeepSeek
$0.15
$0.60
Qwen3.5-35B-A3B
Alibaba Cloud Bailian
$0.0592
$0.4739
Qwen3.5-2B
DeepInfra via Requesty
$0.02
$0.10
Qwen3.5-4B
Alibaba Cloud Bailian
$0.03
$0.15
Gemini 3.7 Flash
Google Gemini API
$0.75
$3.75
Table 10: API prices used for cost estimation. Prices are in USD per one million tokens. We use standard list prices without cache discounts, promotional discounts, or other temporary pricing adjustments.
Long-horizon agents continuously accumulate interaction history during task execution, yet the importance of past interactions changes as the agent state evolves. Existing context management methods largely compress history based on fixed windows, periodic schedules, or current relevance, overlooking a more fundamental question: when has a past interaction become safe to replace? Premature compression may remove information still needed for future actions, while overly conservative retention leads to substantial context overhead. To address this, we propose State Conditioned Compression (StateComp), a framework that determines when historical interactions can be safely compressed according to the current agent state. StateComp constructs KEEP and READY supervision through a two-stage annotation procedure and trains an imbalance-aware router on hidden representations from a frozen language model. A bounded state representation further reduces the cost of evaluating long histories, while adjacent READY interactions are grouped into continuous spans and replaced with compact summaries during execution. Experiments on WorkBuddyBench show that StateComp reduces total agent and summarization tokens by 52.27% while maintaining task performance, and achieves a 12.67-fold speedup in representation extraction.
Mingxuan Wang, Hongyue Chen, Yinglong Guo +6
TierFlow Team · Gaoling School of Artificial Intelligence, Renmin University of China · Tsinghua University
Context compaction lets long-horizon coding agents continue beyond their context windows, but can erase the state needed to finish a task. Prior evaluations measure efficiency, retained information, or end-to-end success, leaving the effect of a specific history replacement difficult to isolate. Compact-Bench pairs full-history and summary-only continuations from a shared repository state, and evaluates recurring details and successive production compactions. It covers 35 SWE-bench repairs, 146 agentic sessions, and 106 production chains. Across 14 summarizer backbones, stable damage ranges from 5-64% of 22 full-history successes: Claude Opus 4.8 preserves the most repairs, while DeepSeek-Flash damages the most. With Kimi-K3 as summarizer, the Kimi Code prompt preserves the most task continuations (19/22), whereas Claude Code retains the most recurring details (15.0%). LLM summaries retain at most 16.0% of recurring details, compared with 79.1% for mechanical extraction; production summaries retain 15.7% at the first boundary. Failures recur across methods: one repair is damaged by 13/14 backbones, and another by all 5 prompts. These results show that reliable compaction requires preserving the progress needed to complete a task, and that retaining relevant information alone does not ensure successful continuation. Code is available at https://github.com/cai-jianfeng/compact-bench and data is available at https://huggingface.co/datasets/caijanfeng/compact-bench.
Long-horizon LLM agents rely on context compaction: when the interaction history outgrows the context window, a compressor replaces it with a natural-language summary. We show that these summaries contain more than a record of what happened. Compaction prompts ask for decisions and next steps, so each summary mixes facts established by the environment with reasoning written by the compressor, and the agent cannot tell the two apart afterwards. In an analysis of a widely used structured compressor, 83% of failed runs trace back to an action that carries out a specific summary entry, most of which no environment output supports. We propose Source-Judged Compaction (SJC), a training-free post-processing step that scores each summary entry for whether it has a source in the environment outputs or the previous summary, and removes the entries that do not. It changes neither the agent nor the compressor and adds one inexpensive judge request per compaction. The judge is Jev, a non-generative decision model that answers the source question with a calibrated probability instead of text. On AppWorld and OfficeBench with two agent models, SJC improves cross-run reliability over the underlying compressor by 2.1%-8.9% without increasing the agent's token usage.
Guanghui Min, Chen Chen
Department of Computer Science, University of Virginia