Back to articles

RECAP Trains Agents to Preserve Behavior After Context Compression

3 min read

Introduction

Long-horizon agents need more than a record of what happened. They must retain task constraints, completed steps, and information that determines what to do next. As conversations and tool interactions accumulate, however, they can exceed a model’s context budget. Summarizing the history makes room, but a fluent summary may quietly drop a detail that changes the agent’s next decision. RECAP, a reinforcement-learning framework, asks how to train agents so that compressing context does not alter the behavior needed to finish a task.

The central idea: preserve behavior, not wording

A conventional approach can train a model to produce concise summaries and then use the final task reward to assess the overall run. RECAP adds a different criterion: after compression, the agent should behave as much as possible as it would have behaved with access to the original interaction history. The summary does not need to reproduce the full transcript; it needs to retain what matters for subsequent actions.

The authors formalize the difference between behavior under the original and compressed contexts as a behavior-distortion objective. They describe its gradient as providing two complementary learning signals. First, a distortion-based reward guides summary generation toward retaining information that supports the original behavior. Second, self-distillation trains the agent’s subsequent actions after compaction to match its behavior under the uncompressed context. This means training addresses both what the summary contains and how the agent acts once it has been given that summary.

Results reported

The paper evaluates RECAP with Qwen3.5-4B in two environments, comparing it with reinforcement-learning baselines trained using task reward alone:

  • BrowseComp-Plus rises from 58.2% to 62.8%, an absolute gain of 4.6 percentage points.
  • SWE-bench Verified rises from 46.8% to 51.1%, an absolute gain of 4.3 percentage points.

The project summary also reports fewer tool calls and shorter trajectories. Ablations are said to highlight the value of supervising summary generation and post-compaction behavior jointly, rather than relying on only one of those signals. The supplied material does not specify compression ratios or the additional training and inference costs, so the benchmark gains alone do not establish the full cost-benefit picture for deployment.

Why it matters—and what remains open

RECAP treats context compaction as part of agent policy learning rather than as a standalone text-cleanup step. Its focus is consequential: a summary can read well to a person yet fail to preserve the conditions that guide an agent’s next move. Measuring whether behavior changes offers a way to train against that failure mode, particularly in tasks that require repeated tool use and consistent constraints over many steps.

The reported results are promising, but they do not settle how well the approach transfers to every production setting. Important questions include how much compression can be achieved before behavior begins to drift, whether the method remains reliable when a task changes mid-run, and whether added computation offsets the reported reduction in tool calls. Those details are not available in the supplied description. For now, RECAP provides evidence that jointly training summaries and subsequent actions can outperform task-reward-only baselines in two tested environments; broader generalization and practical costs still need to be established.

Source: Hugging Face Daily Papers

Comments

Checking sign-in status...

Loading comments...

Related articles