TL;DR
Long-horizon LLM agents frequently suffer from "context rot"—performance degradation caused by the accumulation of stale reasoning and irrelevant tool outputs in their context window. To solve this, the authors introduce SelfCompact, a training-free scaffold that uses a lightweight rubric to let the agent dynamically decide when and how to compress its own history. This adaptive approach matches or exceeds traditional fixed-interval compression while slashing token costs by 30% to 70%.
What Problem Does This Paper Address?
As LLM agents tackle increasingly complex, long-horizon tasks (like competitive mathematics or deep web research), their generation traces grow exponentially, sometimes reaching tens of thousands of tokens. However, longer contexts carry a hidden tax: context rot. Early mistakes, abandoned search paths, and redundant thoughts remain in the context window, anchoring and distracting subsequent generations.
Existing systems typically handle this using rigid, content-agnostic heuristics—such as summarizing the context every fixed number of tokens or turns. The problem? A fixed clock doesn't care if the agent is in the middle of a crucial derivation or a complex search. Compacting at the wrong moment can wipe out vital intermediate facts, forcing the model to fall back on blind guesses.
Methods
Instead of relying on hardcoded token thresholds, SelfCompact hands the decision of when to compact back to the agent itself using a training-free, inference-time scaffold. It pairs two core elements:
- An Inline Compaction Tool ($S$): A prompt-based tool that instructs the model to generate a condensed summary of the accumulated context, preserving key insights and final answers while discarding the "junk."
- A Lightweight Rubric Prompt ($P_R$): A task-specific set of binary conditions evaluated at periodic intervals. The rubric explicitly instructs the model to check if a sub-task has successfully resolved (a safe stopping point to
COMPRESS) or if it is currently stuck mid-derivation (meaning it shouldCONTINUE).
Crucially, the system is highly optimized for KV-cache reuse. Rather than re-encoding the entire history for evaluation, the scaffold appends the rubric or summarizer prompt as a user-role message. This keeps the meta-cognitive judging step nearly free in terms of compute, executing a hard reset and resuming from the summary only when a COMPRESS verdict is reached.
Datasets
The authors evaluated SelfCompact across seven models on six challenging benchmarks split into two domains:
- Multi-turn Competition Math:
IMO-AnswerbenchHMMT Nov 2025HMMT Feb 2026- Agentic Search:
BrowseCompBrowseComp-PlusDeepSearch QA
Key Insights and Ideas
- The Meta-Cognitive Gap: Unprompted models are notoriously bad at recognizing when their own context is rotting. However, they don't need expensive fine-tuning to fix this; providing a structured, lightweight rubric at inference time successfully bridges this meta-cognitive gap.
- Structural vs. Temporal Boundaries: Fixed-interval approaches compress context based purely on time or token counts. SelfCompact naturally aligns its compression with structural boundaries in reasoning (e.g., immediately after a fact is verified or a sub-problem is solved).
- Firing Earlier is Better: Empirical analysis shows that SelfCompact's rubric-driven summaries consistently trigger earlier than standard 30% context thresholds, preventing stale tokens from polluting the generation loop in the first place.
Key Results
SelfCompact demonstrated substantial performance gains and cost reductions across the board:
- Math Reasoning: On the thinking-enabled
Qwen3.5-9B, SelfCompact outperformed the no-compaction baseline by 16.4, 10.0, and 18.1 points on IMO-Answerbench, HMMT Nov, and HMMT Feb, respectively, while matching the token budget of fixed-interval methods. - Agentic Search: Across deployed web agents (
GLM-4.7-Flash,MiniMax-M2.5,MiMo-V2-Flash), SelfCompact improved absolute accuracy by 5 to 9 points on BrowseComp-Plus. - Dramatic Cost Reductions: Because it condenses long trajectories into tight 1k–3k token summaries early on, subsequent LLM calls face much shorter prompts. This resulted in a 30% to 70% reduction in per-question USD costs compared to the baseline.
- Impact on Hard Problems: The accuracy gains were most pronounced on the hardest subsets of questions that require deep search and heavily accumulate context.
Limitations and Future Work
- Open-Weight Focus: The study exclusively evaluated open-weight models. Deployed frontier models (like GPT-5.5 or Claude 4.7) might possess stronger native meta-cognition and could potentially manage context rot without an explicit rubric.
- Lack of Reinforcement Learning: The current intervention is entirely training-free to isolate the rubric's impact. The authors note that integrating Reinforcement Learning (RL) represents a natural next step, as the rubric could serve as a behavioral target to distill optimal compaction directly into the model's weights.
Summary updated