As large language models (LLMs) evolve into autonomous agents for long-horizon information-seeking, managing finite context capacity has become a critical bottleneck. Existing context management methods typically commit to a single fixed strategy throughout the entire trajectory. Such static designs may work well in some states, but they cannot adapt as the usefulness and reliability of the accumulated context evolve during long-horizon search. To formalize this challenge, we introduce a probabilistic framework that characterizes long-horizon success through two complementary dimensions: search efficiency and terminal precision. Building on this perspective, we propose AgentSwing, a state-aware adaptive parallel context management routing framework. At each trigger point, AgentSwing expands multiple context-managed branches in parallel and uses lookahead routing to select the most promising continuation. Experiments across diverse benchmarks and agent backbones show that AgentSwing consistently outperforms strong static context management methods, often matching or exceeding their performance with up to 3× fewer interaction turns while also improving the ultimate performance ceiling of long-horizon web agents. Beyond the empirical gains, the proposed probabilistic framework provides a principled lens for analyzing and designing future context management strategies for long-horizon agents.
Figures & tables
Figure 1: Performance on BrowseComp under different interaction budgets. Dashed lines denote the baselines without context management.
Figure 2: Performance on BrowseComp under Discard-All with different context budgets.
Figure 3: Comparison of context management strategies through the efficiency-precision lens. (a) Pass@1 on BrowseComp. (b) Search efficiency η vs. terminal precision ρ . (c) Aligned terminal precision, where Align-Finish refers to the common finished cases shared by different strategies within the same model.
Figure 4: Overview of AgentSwing. AgentSwing triggers context management once the accumulated context exceeds a predefined threshold, executes multiple candidate strategies in parallel, extends each branch for K new turns, and dynamically routes to the most promising continuation.
Model / Framework
Context Management
BrowseComp
BrowseComp-ZH
HLE
Foundation Models with Tools
Claude-4.5-Opus ( Anthropic, 2025a )
w/o CM
37.0 ‡
62.4
43.4 ‡
Gemini-3.0-Pro ( DeepMind, 2025 )
w/o CM
37.8 ‡
66.8
45.8 ‡
GPT-5.1 High ( OpenAI, 2025a )
w/o CM
50.8 ‡
–
42.7 ‡
OpenAI-o3 ( OpenAI, 2025c )
w/o CM
49.7 ‡
58.1
–
Deep Information-Seeking Agents
Table 1: Overall performance on long-horizon agentic benchmarks. Scores marked with ‡ represent full-benchmark results, whereas unmarked scores correspond to our benchmark settings.
Figure 5: Performance of different context management strategies on BrowseComp over maximum interaction turns.
Model
Strategy
Nalign
Nfinish
Ncorrect
η (%)
ρ (%)
Pass@1 (%)
Nturn
GPT-OSS-120B
Discard-All
122
51
35
41.8
68.6
28.7
297.2
Summary
68
35
55.7
51.5
28.7
248.0
Keep-Last-N
91
43
74.6
47.3
35.2
205.4
AgentSwing
90
51
73.8
56.7
41.8
190.3
DeepSeek-v3.2
Discard-All
73
40
24
54.8
60.0
32.9
268.3
Summary
72
22
98.6
30.6
30.1
132.2
Table 2: Performance comparison of different context management methods on aligned cases that trigger context management under all evaluated strategies ( ρAlign-CM ).
Routing Mechanism
GPT-OSS-120B
Tongyi-DR-30B-A3B
random
51.0
56.5
w/o Lookahead
50.0
57.0
Lookahead ( k=1 )
52.5
58.0
Lookahead ( k=3 )
60.0
60.5
Lookahead ( k=5 )
55.0
59.0
Table 3: Ablation on lookahead strategy.
Figure 6: Token efficiency on the aligned cases used in Table 2 . Each point corresponds to one finished task and is plotted by its total interaction turns and cumulative token count at termination.
Figure 7: Case Study.
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 8: Performance of Tongyi-DR-30B-A3B on BrowseComp under AgentSwing with different context management combinations.
Figure 9: Statistical analysis of strategy transitions under AgentSwing. Each entry gives the probability of routing to the next strategy conditioned on the current one.
Turn ID
Tool Call
Content
Key State
Turn 1
search
American rapper born in October in the 1990s; Libra zodiac sign; joined a gang at 14.
Started with broad candidate retrieval based on birth month, zodiac sign, and gang involvement; surfaced candidates such as Lil Durk.
Turn 2
search
Rapper joined gang at age 14; American rapper gang member at 14.
Narrowed the search to rappers who explicitly joined a gang at age 14; exposed promising clues including $tupid Young and Nipsey Hussle.
Turn 3
visit
Nipsey Hussle (Wikipedia)
Verified that Nipsey Hussle was born in August and therefore did not satisfy the October/Libra clue.
Turn 4
search
October-born rapper who joined a gang at 14; Libra rapper with gang affiliation.
Searched again for October-born gang-affiliated rappers; Lil Durk became a stronger candidate.
Turn 5
visit
Lil Durk (Wikipedia)
Confirmed that Lil Durk was born on October 19, 1992 (Libra), but his gang-entry age remained unsupported and appeared inconsistent with the clue.
Turn 6
search
Lil Durk joined gang at 14; Durk Banks gang age.
Tried to verify whether Lil Durk joined a gang at age 14; no direct evidence supported this claim.
Appendix
Table 4: Main-branch trajectory for the "Mando" case (Part I).
Turn ID
Tool Call
Content
Key State
Turn 17
search
Hit-Boy father 15-year sentence; Big Hit prison timeline.
Further validated the 15-year imprisonment timeline around Hit-Boy’s father, strengthening the father-side clue.
Turn 18
search
Songs featuring Hit-Boy in 2015–2018.
Looked for songs where Hit-Boy was explicitly credited as a featured artist; results were still fragmented.
Turn 19
visit
Racks in the Middle (Wikipedia)
Checked “Racks in the Middle” and confirmed that although Hit-Boy was involved, Nipsey Hussle did not fit the October/1990s clue.
Turn 20
search
Viral songs featuring Hit-Boy in 2017–2019.
Continued searching for a viral song featuring Hit-Boy; no decisive match was found yet.
Turn 21
search
October-born Crips/Bloods member in the 1990s.
Explored West Coast gang-affiliated rappers born in October; results were mostly generic gang references.
Turn 22
search
January 21, 2016 and father served 15 years in prison.
Investigated the date anchor around January 21, 2016, but this direction produced little value.
Appendix
Table 5: Main-branch trajectory for the "Mando" case (Part II).
Branch
Turn ID
Tool Call
Content
Key State
LA Turn 1
search
American rapper born in October in the 1990s; Libra zodiac sign; joined a gang at 14; father served 15 years in prison.
Restarted from scratch with broad retrieval. It surfaced generic October-born candidates such as Lil Durk, but made no decisive progress on the real target.
Discard-All
LA Turn 2
search
Rapper whose father served 15 years in prison.
Focused on the father clue and rediscovered Hit-Boy, but still lacked a correct main-rapper hypothesis.
LA Turn 3
search
January 21, 2016 and father served 15 years in prison.
Pursued the date-anchored clue without traction. This branch remained broad and under-focused.
LA Turn 1
visit
$tupid Young (Wikipedia page lookup)
Attempted to open a Wikipedia page for $tupid Young, but the page was unavailable.
Keep-Last-N
LA Turn 2
search
$tupid Young birthday; Stupid Young birth date.
Verified the rapper’s identity: $tupid Young was born on October 3, 1992, matching both the 1990s and Libra clues.
LA Turn 3
search
tupidYoungviralsong;tupid Young hit song; $tupid Young featuring.
Searched his discography and identified “Mando” as a strong candidate due to popularity and its feature with Mozzy.
Appendix
Table 6: Lookahead branches triggered by context management in the "Mando" case.
Turn ID
Tool Call
Content
Key State
Turn 1
search
Performer who stapled paper to his forehead; sideshow stapling act.
Started with direct retrieval on the stapling clue, but results were dominated by noisy modern pages, social media posts, and irrelevant literal uses of “stapled paper.”
Turn 2
search
Paper-to-forehead sideshow performer who ate something live.
Tried to combine the stapling clue with the “ate live creatures” clue; surfaced sideshow-related entities such as Jim Rose Circus, but no stable performer identity.
Turn 3
search
Strongwoman associated with “beef, game, and plenty of vegetables.”
Shifted to a secondary clue in the question, but the retrieved results were largely noisy and did not yet identify the relevant strongwoman.
Used the Bethel / museum / Feejee Mermaid clue to infer the publication domain; this pointed toward P. T. Barnum and the historical oddities / sideshow space.
Repeated the supporting-entity search, but the results were still not sufficiently specific to identify the source publication.
Turn 6
search
Strongwoman who threw a heckler across a tent.
Switched to another distinctive supporting clue in order to identify the common source through a secondary figure.
Appendix
Table 7: Main-branch trajectory for the "live-crickets" case (Part I).
Turn ID
Tool Call
Content
Key State
Turn 19
search
Stapled paper; forehead; sideshow; eaten.
Combined the snippet clues again, but the results still revolved around the unresolved PDF source.
Turn 20
search
Full snippet phrase including “eaten a mouthful.”
Queried the visible snippet directly; this helped confirm the source phrase, but still did not reveal the missing object after “eaten a mouthful of …”
Turn 21
search
Performer name from the stapling clue.
Tried to infer the performer identity directly from the snippet description, but the retrieval remained inconclusive.
Turn 22
search
Exact phrase: “has willingly stapled paper to his forehead.”
Repeated exact-phrase retrieval to localize the passage more precisely, but still without extractable full text.
Turn 23
search
The Victorian Sideshow PDF.
Re-confirmed that The Victorian Sideshow was the likely shared source behind the unusual individuals in the question.
Turn 24
visit
The Victorian Sideshow PDF (targeted extraction attempt).
Made a more targeted attempt to extract the paragraph about the stapling performer and the live-creature clue, but the visit tool still failed.
Appendix
Table 8: Main-branch trajectory for the "live-crickets" case (Part II).
Branch
Turn ID
Tool Call
Content
Key State
LA Turn 1
search
Stapled paper to forehead performer.
Restarted from scratch and quickly re-entered the correct search space around the stapling-performer clue, without inheriting the noisy local loop around failed PDF extraction.
Used multiple supporting entities together to verify that the publication family was correct and that the search was grounded in the historical sideshow domain.
LA Turn 3
visit
Jo-Jo the Dog-Faced Boy article.
Also revisited supporting clues from the question, indicating that the branch was reconstructing the source-publication hypothesis through multiple entities rather than overfitting to one failed access path.
LA Turn 1
visit
Scribd mirror of Sideshow .
Preserved the most recent local context, which was already dominated by failed source-extraction attempts; immediately re-entered the same bottleneck.
Keep-Last-N
LA Turn 2
search
The Victorian Sideshow PDF.
Continued searching for alternative access points to the same PDF, but remained trapped in the same unresolved extraction problem.
LA Turn 3
visit
The Victorian Sideshow PDF.
Attempted direct PDF access again and failed, showing that preserving the most recent context mainly preserved the local dead end rather than useful progress.
Appendix
Table 9: Lookahead branches triggered by context management in the "live-crickets" case.
Long-horizon search agents must manage a rapidly growing working context as they reason, call tools, and observe information. Naively accumulating all intermediate content can overwhelm the agent, increasing costs and the risk of errors. We propose that effective context management should be adaptive: parts of the agent's trajectory are maintained at different levels of detail depending on their current relevance to the task. To operationalize this principle, we introduce Context-ReAct, a general agentic paradigm for elastic context orchestration that integrates reasoning, context management, and tool use in a unified loop. Context-ReAct provides five atomic operations: Skip, Compress, Rollback, Snippet and Delete, which allow the agent to dynamically reshape its working context, preserving important evidence, summarizing resolved information, discarding unhelpful branches, and controlling context size. We prove that the Compress operator is expressively complete, while the other specialized operators provide efficiency and fidelity guarantees that reduce generation cost and hallucination risk. Building on this paradigm, we develop LongSeeker, a long-horizon search agent fine-tuned from Qwen3-30B-A3B on 10k synthesized trajectories. Across four representative search benchmarks, LongSeeker achieves 61.5% on BrowseComp and 62.5% on BrowseComp-ZH, substantially outperforming Tongyi DeepResearch (43.2% and 46.7%) and AgentFold (36.2% and 47.3%). These results highlight the potential of adaptive context management, showing that agents can achieve more reliable and efficient long-horizon reasoning by actively shaping their working memory.
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.
Lu Yi, Runlin Lei, Liuyi Yao +6
1Renmin University of China · Work done during internship at Tongyi Lab, Alibaba Group · 2Tongyi Lab, Alibaba Group +2
Harness evolution improves LLM agents by learning from execution trajectories, but existing experience- and skill-based methods are less effective on long-horizon tasks. As interactions grow, useful evidence can be buried by redundant or outdated context, making context management itself a key bottleneck. We introduce ContextEvo, a framework that learns a context policy from long-horizon trajectories. ContextEvo reconstructs the model-visible context at key decision points, identifies context-related failures, and applies targeted policy updates. Starting from the open-source Pi-agent harness, ContextEvo improves performance across three long-horizon task benchmarks, achieving results comparable to or better than several prominent agent harnesses, including Codex, OpenCode, and OpenClaw. Additional analyses show that fixed or locally evolved context strategies can fall short under long-horizon information pressure, while our methods adapt to the information demands of each environment.
Weiyuan Li, Jinghan Xu, Aili Chen +4
School of Data Science, Fudan University · Shanghai Key Laboratory of Data Science · College of Computer Science and Artificial Intelligence, Fudan University