Papers
arxiv:2611.31258

RECAP: Training Long-horizon LLM Agents with Context Compaction

Published on Oct 19
· Submitted by
Yulun Jiang
on Nov 25
Authors:
,
,

Abstract

A reinforcement learning framework, RECAP, optimizes context compaction by aligning compressed-context behavior with original-history behavior, improving long-horizon agent performance.

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.

Community

Paper submitter

How can we train AI agents to solve long-horizon tasks with limited context? We introduce RECAP🎞️, an RL recipe for training long-horizon agents with context compaction.

The central idea is simple: a good summary should preserve the agent’s behavior under the original interaction history. RECAP combines final task rewards with the measure of how compaction changes the agent's behavior.

We evaluate RECAP on two environments and demonstrate consistent improvements over task-reward-only baselines:
🔎 BrowseComp-Plus: 58.2% → 62.8% (+4.6 pp)
🛠️ SWE-bench Verified: 46.8% → 51.1% (+4.3 pp)
These gains come with fewer tool calls and shorter trajectories.

Paper: https://arxiv.org/pdf/2611.31258
Code: https://github.com/eth-medical-ai-lab/recap
Project page: https://recap-site.github.io

I've had hand-rolled compaction running in a production agent for months, and the failure always has the same shape: the summary passes human review and quietly loses the constraint the agent was two steps from satisfying. The "don't touch staging" line, the half-finished migration. Reads fine, behaves wrong.

Behavior distortion is the right thing to optimize for, but the number I want out of this is the compression ratio where it falls apart. A summary good enough to preserve induced behavior is going to be fat — if it lands at 60% of the original tokens, the win over just keeping the history gets thin fast, and you're paying an extra model call for it.

The other test I'd add: a task switch mid-episode. In prod the queue doesn't stop handing you new work while you're halfway through the old thing, and that's exactly where a compaction policy tuned on single-task rollouts should crack.

Sign up or log in to comment

Get this paper in your agent:

hf papers read 2611.31258
Don't have the latest CLI?
curl -LsSf https://hf.co/cli/install.sh | bash

Models citing this paper 0

No model linking this paper

Cite arxiv.org/abs/2611.31258 in a model README.md to link it from this page.

Datasets citing this paper 0

No dataset linking this paper

Cite arxiv.org/abs/2611.31258 in a dataset README.md to link it from this page.

Spaces citing this paper 0

No Space linking this paper

Cite arxiv.org/abs/2611.31258 in a Space README.md to link it from this page.

Collections including this paper 0

No Collection including this paper

Add this paper to a collection to link it from this page.