AgentSwing: Adaptive Parallel Context Management Routing for Long-Horizon Web Agents
Organizations: Tongyi Lab, Alibaba Group
Abstract
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 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
| 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 | ||||
| Model | Strategy | (%) | (%) | Pass@1 (%) | ||||
| 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 |
| Routing Mechanism | GPT-OSS-120B | Tongyi-DR-30B-A3B |
| random | 51.0 | 56.5 |
| w/o Lookahead | 50.0 | 57.0 |
| Lookahead ( ) | 52.5 | 58.0 |
| Lookahead ( ) | 60.0 | 60.5 |
| Lookahead ( ) | 55.0 | 59.0 |
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
| 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. |
| 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. |
| 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 | 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. |
| 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. |
| Turn 4 | search | Bethel, Connecticut; Manhattan museum; Feejee Mermaid. | Used the Bethel / museum / Feejee Mermaid clue to infer the publication domain; this pointed toward P. T. Barnum and the historical oddities / sideshow space. |
| Turn 5 | search | Bethel, Connecticut; sideshow; Manhattan museum; Feejee Mermaid. | 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. |
| 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. |
| 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. | |
| Discard-All | LA Turn 2 | search | Feejee Mermaid; Minerva; Jo-Jo; supporting clue bundle. | 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. |
LLM Context Management
Large language model context management studies how to select, compress, retrieve, and organize information within bounded model inputs.
See all 248 papers