RECAP: Training Long-horizon LLM Agents with Context Compaction

Yulun Jiang, Maria Brbic, Michael Moor

EPFL · ETH Zurich

Published October 19, 2026 · on the feed November 25, 2026 · ▲ 4 · arXiv 2611.31258

AgentsLLM training & RLCode & software Full code arXiv ↗Hugging Face ↗

The abstract

Context compaction enables large language model agents to tackle long-horizon tasks within limited context budgets by replacing interaction histories with compressed summaries. However, learning effective compaction jointly with the agent policy remains challenging, as summaries affect task success over many subsequent interactions. We introduce RECAP, a reinforcement learning (RL) framework based on the principle that a summary should preserve the behavior induced by the original interaction history. We formalize this principle with a behavior distortion objective that measures the divergence between the agent's subsequent behavior under compressed and original contexts. We show that the gradient of the distortion objective decomposes into two complementary learning signals: distortion-based reward for summary generation and self-distillation for subsequent actions. Experiments on Qwen3.5-4B show that RECAP consistently outperforms the task-reward-only RL baselines on both environments, leading to an absolute improvement of 4.6% and 4.3% on BrowseComp-plus and SWE-bench Verified, respectively. Ablations further highlight the value of jointly supervising summary generation and post-compaction behavior for RECAP.

The Brief

1:46

A short podcast summary of the paper. Written and voiced by AI.

Transcript

RECAP. Training Long-horizon LLM Agents with Context Compaction. By Yulun Jiang and two others, from EPFL and ETH Zurich. Published on the nineteenth of October.

Long-horizon tasks outgrow a language model agent's context budget. Context compaction is one answer: replace the interaction history with a compressed summary and carry on. The hard part is learning to compact well while also learning the agent's policy. A summary's effect on success does not show up right away. It plays out over many interactions that come after it, which makes it difficult to tell a good summary from a bad one.

RECAP is a reinforcement learning framework built on one principle. A summary should preserve the behavior that the original history would have induced. If the agent acts the same way after reading the summary as it would have after reading everything, the summary has done its job.

That principle is made precise as a behavior distortion objective. It measures the divergence between the agent's subsequent behavior under the compressed context and its behavior under the original context. The authors then show that the gradient of this objective splits into two complementary learning signals. One is a distortion-based reward, which trains summary generation. The other is self-distillation, which trains the actions that follow a summary.

Experiments use Qwen3.5-4B on two environments. RECAP consistently beats reinforcement learning baselines that use only the task reward. The absolute improvement is four point six percent on BrowseComp-plus and four point three percent on SWE-bench Verified. Ablations point to the value of supervising both pieces together: the generation of the summary, and the behavior after compaction.

The principle gives the summary a target it can be measured against right away. Rather than waiting for a distant task reward to say whether compression helped, RECAP asks a nearer question: does the agent still behave as it would have with the full history in view.

More with an account

Listen to every day’s papers

Daily playlists, deep dives, quests for the papers, and quizzes on their key terms.

Join free
KipQuest: the day’s AI research, as podcasts and quests. All papers Android app Privacy Contact Episodes are written and voiced by AI from each paper. Summaries can contain mistakes: the paper is the source.