Source-linked AI summary

Learning Agent-Compatible Context Management for Long-Horizon Tasks

Lu Yi, Runlin Lei, Liuyi Yao, Yuexiang Xie, Yuyang Li, Wenhao Zhang, Zhewei Wei, Yaliang Li, Jian-Yun Nie

arXiv:2605.30785v1cs.AI

TL;DR

Long-horizon context accumulation can degrade agent reasoning, while prior context-management approaches often depend on agent-side adaptation or fixed operations. AdaCoM trains a flexible external manager around a frozen agent, improving benchmark performance and revealing capability-linked context and transfer patterns.

  • Problem

    Long-horizon tasks accumulate context that can obscure salient evidence and undermine reliable decisions, while existing management often relies on agent-side adaptation or fixed strategies.

    Source: §1 · p. 1
  • Method

    AdaCoM trains an external manager with flexible context-modification actions while keeping the target agent frozen.

    Source: §1 · p. 2, §3.1 · p. 3
  • Results

    Across web search and deep research, AdaCoM substantially improves diverse agents; learned strategies balance fidelity against reliability, and transfer best between capability-similar agents.

    Source: §1 · p. 2, §6 · pp. 8–9
  • Takeaways & Limitations

    Managers can be reused most effectively across agents with comparable vanilla ReAct capability.

    Source: §1 · p. 2

    The manager is a relatively small Qwen3-4B-Instruct model, and its capacity may limit lossless evidence preservation or compression for very strong agents.

    Source: Limitations · p. 9

Abstract

from arXiv · show

LLM agents increasingly face long-horizon tasks such as web search and deep research in real-world applications, where accumulated context can cause long-context degradation and reasoning failures. Prior work mitigates this through context management with agent-side context control or fixed strategies such as summarization, which require training the agent itself for adaptation - making it impractical for closed-source agents and ignoring that different agents may require different strategies. We introduce Adaptive Context Management (AdaCoM), which trains an external LLM to manage the context of a frozen agent through flexible modification actions and end-to-end reinforcement learning. Across diverse agents on web search and deep research benchmarks, AdaCoM substantially improves performance by preserving task constraints and progress while pruning stale content. The learned strategies reveal a Fidelity-Reliability Trade-off: agents with higher vanilla ReAct performance benefit from higher-fidelity context preservation, whereas lower-performing agents require more aggressive compression to stay within a reliable reasoning regime. Transfer experiments show that AdaCoM generalizes most effectively across agents with similar capability (measured by vanilla ReAct performance), suggesting a practical path toward reusable context managers for agent systems.

1 Introduction

Long-horizon context accumulation can degrade agent reasoning, while prior context-management approaches often depend on agent-side adaptation or fixed operations. AdaCoM instead trains a flexible external manager around a frozen agent, improving benchmark performance and revealing capability-linked context and transfer patterns.

1 Introduction

  • Long-horizon tasks accumulate stale or irrelevant content that can obscure salient evidence, amplify positional bias, and make later decisions less reliable.Prior context management often requires the agent to follow new patterns or tool protocols, making training-dependent methods poorly matched to closed-source deployment and fixed operations ill-suited to varied agents.Source: §1 · pp. 1–2
  • AdaCoM uses an external manager to flexibly modify context and learns its strategies with reinforcement learning while keeping the agent unchanged.The manager updates the running context before each agent step.Source: §1 · p. 2
  • AdaCoM substantially improves diverse agents on web search and deep research, reducing constraint forgetting, premature abandonment, and redundant exploration.The reported gains come from retaining task-relevant context while pruning stale content.Source: §1 · p. 2
  • Stronger agents benefit from preserving more raw trajectory context, while weaker agents need more aggressive compression to keep reasoning reliable.The paper frames this pattern as a Fidelity–Reliability Trade-off, using vanilla ReAct performance as a measure of capability.Source: §1 · p. 2
  • Trained managers transfer most effectively between agents with comparable capability, suggesting a basis for reuse without retraining the manager.Capability is measured by vanilla ReAct performance.Source: §1 · p. 2

2 Related Work

Prior context-management work commonly prescribes operations such as summarization or exposes management tools to the agent, often coupling these approaches with agent training. Long-term memory instead targets persistent information across sessions, whereas this paper addresses working context within a single task.

2 Related Work

  • Prior methods reduce long trajectories through predefined operations or agent-directed tools, often requiring the agent to learn when and how to manage its own context.AdaCoM differs by training an external manager while keeping the underlying agent fixed.Source: §2 · p. 2
  • Long-term-memory systems store and retrieve information across sessions, tasks, or users; AdaCoM instead manages working memory within one long-horizon task.The two directions are presented as complementary.Source: §2 · p. 2

3 Adaptive Context Management

AdaCoM manages a frozen agent’s running context through flexible message-level edits, then trains the external manager using task outcomes and process feedback.

3.1 Flexible Context Management Paradigm

  • At each turn, an external manager edits the accumulated context after the agent acts, and the frozen agent conditions its next action on the managed context.The managed context begins with the task query; each new action and observation is appended before management.Source: §3.1 · p. 3
  • The manager can rewrite, delete, or merge selected messages, or leave context unchanged, supporting both compression and fidelity.Untargeted messages are copied unchanged, and an empty action list leaves the context unchanged.Source: §3.1 · p. 3

3.2 Training the Context Manager

  • Training initializes the manager with supervised fine-tuning, then uses GRPO rollouts scored by the frozen agent’s final answer.Deterministic tasks receive binary judge scores; open-ended tasks are scored against task-specific rubrics.Source: §3.2 · p. 3
  • Process rewards penalize over-length contexts, repeated identical tool calls, and invalid outputs, while incorporating benchmark-specific intermediate signals when available.The redundant-action penalty is applied to the manager action between consecutive calls using the same tool and parameters.Source: §3.2 · p. 4
  • The manager combines separately normalized rollout outcome and step-level process advantages, then optimizes a PPO-style clipped objective over its emitted tokens.Outcome advantage is shared across a rollout’s steps, while process rewards are normalized across steps in the rollout group.Source: §3.2 · p. 4

4 Experiments and Analysis

Experiments show AdaCoM improves results across web search and deep research, while its learned context strategies vary with agent capability and task needs.

4.1 Experimental Setup

  • Evaluation covers BrowseComp-Plus web search and MCP-Bench-Wiki deep research, scoring three research dimensions: task fulfillment, information grounding, and parallelism and efficiency.BrowseComp-Plus reports mean@3 and pass@3; MCP-Bench-Wiki reports mean@3.Source: §4.1 · pp. 4–5

4.2 Main Results

4.1 Experimental Setup

  • AdaCoM is initialized with supervised fine-tuning and then reinforcement-learning-trained; comparisons include fixed-summarization SumCoM and an untrained manager with the same action space.Source: §4.1 · p. 5

4.3 Analysis: How AdaCoM Helps Agents

  • AdaCoM increases correct-answer shares across agents and reduces incorrect answers and early give-ups for Qwen, DeepSeek, and GLM by retaining requirements, evidence, and search progress.The manager is not explicitly prompted about what to record or how to organize context; it learns to update task requirements, progress, and prior attempts.Source: §4.3 · pp. 6–7
  • For Kimi, AdaCoM reduces max-iteration failures by recording prior attempts and pruning repetitive or unhelpful results; 42.6% of its ReAct tool-use steps per task are repetitive.Source: §4.3 · p. 7

4.4 Analysis: Specific Strategies across Agents

  • Mean post-management context length rises from about 1.9K tokens for DeepSeek to 7.0K for GLM, aligning with increasing vanilla ReAct performance; GLM and Qwen use tiered compression, while DeepSeek and Kimi distill eagerly.Source: §4.4 · p. 7
  • The Fidelity–Reliability Trade-off balances preserving raw evidence against keeping reasoning reliable: fixed-summary SumCoM helps weaker agents more, but is less suitable for GLM and Qwen and degrades GLM.Source: §4.4 · p. 7

5 Cross-Agent Transferability

Trained AdaCoM managers often improve results when reused across agents, with transfer patterns linked to capability similarity and agent-specific style compatibility.

5 Cross-Agent Transferability

  • 23 of 28 cross-agent pairs and all 4 self-trained pairs improve over ReAct; mean relative gains are 25.0% across all 32 pairs and 22.1% across cross-agent pairs.The largest cross-agent gain is 79.6% on Kimi under the DeepSeek-trained manager.Source: Figure 4 · p. 8, §5 · p. 8
  • Similar cross-agent transfer improvements also appear on MCP-Bench-Wiki, suggesting transfer extends beyond web search to tool-use-intensive deep research.Source: §5 · p. 8
  • Transfer generally favors capability-similar source and target agents: higher-baseline targets tend to benefit more from GLM- or Qwen-trained managers, and lower-baseline targets from DeepSeek- or Kimi-trained managers.Source: §5 · p. 8
  • Capability proximity is an incomplete predictor: DeepSeek, GLM, and Gemini show exceptions linked to differences in preferred memory content or reasoning style.DeepSeek prefers concise working memories while Kimi’s manager records detailed histories; Gemini does not use Qwen’s report-style memory effectively.Source: §5 · p. 8
  • A practical strategy is to train managers for representative agents and reuse them on capability-similar targets, while checking style compatibility when choosing within a capability group.Source: §5 · p. 8

6 Conclusion

AdaCoM trains an external manager to modify a frozen agent’s context, and its analysis identifies a fidelity–reliability trade-off in context management.

6 Conclusion

  • AdaCoM trains an external manager with flexible context modifications while keeping the underlying agent frozen.The framework learns agent-compatible strategies through reinforcement learning.Source: §6 · p. 8
  • Experiments show AdaCoM improves diverse agents and transfers to unseen agents with similar baseline capability.Source: §6 · p. 8
  • Effective context management balances preserving task-relevant information against keeping agent reasoning reliable.Source: §6 · p. 9

Limitations

The evaluation is limited to two knowledge-intensive search benchmarks, and the manager’s capacity, inference overhead, and cache effects constrain deployment conclusions.

Limitations

  • Evaluation covers web search and deep research, not code agents, embodied agents, or longform writing; MCP-Bench-Wiki includes only two agents.Source: Limitations · p. 9
  • A 4B manager may limit lossless context handling for very strong agents, and larger managers were not evaluated.The paper notes that this capacity mismatch could underestimate AdaCoM’s potential on stronger closed-source agents.Source: Limitations · p. 9
  • Manager inference at every agent step increases rollout token cost and wall-clock latency over vanilla ReAct.The authors suggest that invoking the manager less often could reduce overhead while preserving benefits.Source: Limitations · p. 9
  • Context edits can reduce KV-cache reuse, an issue shared with summarization methods and not optimized in this work.Tiered management that preserves raw context longer is proposed as a possible cache-aware direction.Source: Limitations · p. 9

A Additional Experimental Settings

The appendices specify benchmark tools and training settings, then describe how MCP-Bench-Wiki tasks are generated, validated, and filtered.

A.1 Available Tools

  • BrowseComp-Plus provides article fact, related-topic, section, and link tools, plus a shared finish tool for submitting answers.Source: §A.1 · p. 11
  • The listed Wikipedia tools include keyword search, full-article retrieval, article summaries, query-focused summaries, and section summaries.Source: §A.1 · p. 11

A.2 Detailed Parameter Settings

  • Process rewards penalize token use (−0.8), redundant actions (−0.4), and format errors (−0.5); BrowseComp-Plus adds 0.6 gold-doc and 0.3 key-doc rewards.Source: §A.2 · p. 11
  • Training uses 32-trajectory rollout batches, 768 manager-step samples, a 5×10−6 learning rate, and a 0.006 KL coefficient.Other settings include a 0.2 PPO clipping range, temperature 1.0, and up to 40 epochs with early stopping.Source: §A.2 · p. 11
  • AdaCoM caps agent input at 32K tokens; Table 3 reports BrowseComp-Plus Pass@3 (%) across four agents with same-agent ReAct comparisons.Source: §A.2 · p. 11, Table 3 · p. 12

B Construction of the MCP-Bench-Wiki Dataset

  • MCP-Bench-Wiki data comprise 4,740 SFT samples, 1,000 RL training tasks, and a 150-task held-out test set; each task has three identifying or analytical fields.Tasks are structured requests requiring coordinated Wikipedia MCP calls, with task_id, task_description, and dependency_analysis fields.Source: B Construction of the MCP-Bench-Wiki… · p. 12, §B.1 · p. 12

B.1 Upstream: task synthesis pool

  • The upstream pipeline drafts tasks with five LLMs, retains those judged solvable, dry-runs them, and filters execution logs for quality.Three judges assess solvability; dry runs require successful tool calls and a non-trivial answer, followed by log-based acceptance.Source: §B.1 · p. 12
  • The upstream training pool retains 2,517 tasks from roughly 3,500 raw generations, while the held-out pool retains 879 candidates from 1,000 generations.The held-out pipeline uses a training-topic blacklist and additional length, similarity, and frequency filters.Source: §B.1 · p. 12

B.2 Downstream: from pool to datasets

The downstream pipeline turns an upstream task pool into SFT, RL, and held-out test data through rollouts and task-level filtering.

B.2 Downstream: from pool to datasets

  • The downstream stage runs upstream tasks with a Wikipedia agent and context manager, converting resulting trajectories into SFT, RL, and test datasets.Source: §B.2 · p. 13
  • Benchmark rollouts use Claude Opus 4.6 as manager and Qwen3-Max as solver, with a 24,576-token context cap and 2,000-token extract threshold.Rollouts supply the context-manager invocations used to extract SFT samples.Source: §B.2 · p. 13
  • SFT examples label manager invocations as modify, delete, no_change, or extract, yielding roughly 73% modify, 20% extract, and 7% delete/no_change combined.Samples are screened for valid JSON, minimum reduction for modify actions, and near-duplicates.Source: §B.2 · p. 13
  • RL training samples 1,000 tasks that completed with fulfillment ≥3 and ran 10–39 reasoning rounds, excluding near-duplicates and overly prescriptive requests.Source: §B.2 · p. 13

B.3 Summary

  • The held-out test set contains 150 tasks selected for 30–150 tool calls and reference answers over 500 characters; its task source does not overlap SFT or RL.Source: §B.2 · p. 13, §B.3 · p. 13

C.1 Additional Experiment Results

Additional evaluations find that AdaCoM improves BrowseComp-Plus pass@3 and transfers across target agents on MCP-Bench-Wiki. Dimension scores show a Kimi-K2-Instruct efficiency trade-off, while removing process rewards lowers performance.

C.1 Additional Experiment Results

  • AdaCoM achieves the best average pass@3 and improves all four agents over ReAct on BrowseComp-Plus.AdaCoM without training and self-management remain unstable across agents; SumCoM improves several agents but still trails AdaCoM on average.Source: §C.1 · p. 14
  • GPT-4o-mini, DeepSeek-V3, and Seed-1.6-Flash improve on all three dimensions, while Kimi-K2-Instruct gains TF and IG but loses PE relative to ReAct.Because TF and IG carry larger weights, Kimi-K2-Instruct still achieves a higher overall score; the overall score is 0.4 × TF + 0.4 × IG + 0.2 × PE.Source: §C.1 · p. 14
  • Both trained managers improve all four target agents over ReAct on MCP-Bench-Wiki, extending transfer gains beyond BrowseComp-Plus.The two managers were trained with DeepSeek-V3 and Kimi-K2-Instruct; the figure groups results by target agent and shows mean@3.Source: Figure 5 · p. 14, §C.1 · p. 14

C.2 Ablation Study on Process Reward

  • mean@3 fell from 26.19% to 24.38% for DeepSeek-V3 and from 36.67% to 33.33% for Qwen3-Max without process rewards on BrowseComp-Plus.The authors interpret the drops as evidence that process rewards provide useful intermediate supervision beyond the sparse final-answer reward.Source: Table 5 · p. 14, §C.2 · p. 14

C.3 Analysis: Transfer Exceptions and Agent Specific Factors

Capability proximity explains the dominant transfer pattern, but transfer can also depend on whether a manager’s modification style fits the target agent. The examples show different memory-style mismatches for DeepSeek, GLM, and Gemini.

C.3 Analysis: Transfer Exceptions and Agent Specific Factors

  • Similar baseline capability does not guarantee the best transfer when a manager’s modification style mismatches the target agent’s reasoning style.The analysis identifies capability proximity as the dominant transfer pattern, with modification-style fit explaining exceptional cases.Source: §C.3 · p. 14
  • DeepSeek gains little from AdaCoM (Kimi): its concise key findings and document IDs contrast with Kimi’s detailed search-history memory.The different working-memory styles suggest DeepSeek fits compact, exact clues better, while Kimi benefits more from detailed attempt histories.Source: §C.3 · p. 15
  • Other agents’ managers often compress evidence more aggressively than GLM prefers, risking loss of fine-grained information GLM could use.AdaCoM (GLM) compresses only occasionally and in larger batches, better preserving GLM’s required information density.Source: §C.3 · p. 15
  • AdaCoM (Qwen) underperforms AdaCoM (Kimi) on Gemini despite similar Qwen and Gemini ReAct baselines; Gemini may mirror Qwen’s report-style memory and give up early.The described early abandonment can occur without a valid answer, linking transfer quality to compatibility with the target’s reasoning behavior.Source: §C.3 · p. 15

D Case Study

The case study contrasts GLM-4.5-Air’s selective working-note updates with DeepSeek-V3’s frequent rewriting or deletion of recent tool results. Both agents reach the correct answer through different context-management strategies.

D Case Study

  • GLM-4.5-Air’s AdaCoM intervenes 11 times and usually edits only a roughly 1 K-token working note, leaving raw tool results untouched.It later adds discovered clues and document IDs alongside pending constraints, then removes or summarizes stale tool results in a final batch; GLM returns the answer with constraint verifications.Source: D Case Study · pp. 15–16
  • DeepSeek-V3’s AdaCoM intervenes 18 times, often paraphrasing or deleting the latest tool result before the agent sees it.It preserves refined constraints and progress in a working note; raw results are retained only when they support unresolved constraints, for at most three rounds.Source: D Case Study · p. 16

F Artifact Licenses and Terms of Use

  • Trinity-RFT and AgentScope use Apache 2.0, MEM1 uses MIT, and MCP-Bench and BrowseComp-Plus repositories had no explicit open-source license at the time of use.The authors state that artifacts were used solely for non-commercial academic research and in accordance with their intended research purposes.Source: F Artifact Licenses and Terms of Use · p. 16
  • BrowseComp-Plus and MCP-Bench use publicly available web sources and benchmark corpora; the authors report no new human-subject data collection.A manual random-sample inspection found no content naming or uniquely identifying private individuals and no offensive material.Source: F Artifact Licenses and Terms of Use · p. 16

G AI Assistant Usage Disclosure

  • Claude and ChatGPT assisted with proofreading and language polishing; the authors assign scientific claims, designs, analyses, and conclusions to themselves..Source: G AI Assistant Usage Disclosure · p. 16

H Adopted Prompts

  • The AdaCoM prompt’s Background placeholder receives benchmark-specific information; the listed tables provide benchmark agent prompts and the manager prompt’s runtime inputs.The Background is the only part of the AdaCoM prompt that differs between BrowseComp-Plus and MCP-Bench-Wiki.Source: H Adopted Prompts · p. 16, Table 7 · p. 17, Table 8 · p. 17
  • The MCP-Bench-Wiki judge prompt adds finer-grained percentage-based scoring rubrics, and oversized document results are split into overlapping chunks with notes refined iteratively.The extraction prompt applies to get_document results for BrowseComp-Plus or get_article / get_sections results for MCP-Bench-Wiki.Source: H Adopted Prompts · p. 16, Table 12 · p. 24
Loading 2605.30785v1…