TL;DR
AgentSwing is an adaptive, state-aware context management framework for long-horizon web agents that dynamically selects the best way to prune or summarize interaction history. By expanding multiple context-managed branches in parallel and using a short lookahead phase to route the agent down the most promising path, AgentSwing breaks the traditional efficiency-precision trade-off, matching or exceeding static methods with up to 3× fewer interaction turns.
What Problem Does This Paper Address?
As large language models (LLMs) transition into autonomous web agents, they are increasingly tasked with long-horizon information-seeking problems that require tens or hundreds of sequential steps (searching, visiting pages, verifying clues, and backtracking). In these deep searches, agents quickly run into the limits of finite context windows.
To prevent context saturation, current systems use static context management strategies—such as summarizing the history (Summary), keeping only the last $N$ turns (Keep-Last-N), or aggressively wiping the history entirely (Discard-All). However, applying a single fixed strategy across an entire trajectory is brittle. A long search trajectory is dynamic: some states contain crucial intermediate structures that must be preserved, while others are bogged down by noise, drift, or repetitive loops that demand a hard reset.
Methods
The authors first formalize the problem through a new probabilistic framework that decomposes an agent's end-to-end success (Pass@1) into two complementary dimensions:
- Search Efficiency ($\eta$): The probability that an agent successfully reaches a stopping point and emits an answer before exhausting its resource budget.
- Terminal Precision ($\rho$): The probability that the final answer is correct, conditioned on the agent actually reaching a stopping point.
Building on this framework, they introduce AgentSwing, which treats context management as a state-dependent routing problem rather than a fixed heuristic.
When an agent's context length crosses a predefined threshold ($r\%$ of the maximum capacity), AgentSwing triggers a two-step pipeline:
- Parallel Context Management: It forks the current trajectory into multiple parallel branches, each processed by a different context management strategy (
Keep-Last-N,Summary, andDiscard-All). - Lookahead Routing Mechanism: Instead of choosing a branch immediately, AgentSwing lets each branch roll out for a short horizon of $K$ additional turns (experimentally optimized at $K=3$). The agent model then reviews the candidate continuations alongside real environmental feedback and selects the most promising path to become the new main trajectory.
Datasets
The framework was evaluated across three challenging long-horizon benchmarks using diverse open-source backbones (GPT-OSS-120B, DeepSeek-v3.2, and Tongyi-DR-30B-A3B):
- BrowseComp: A complex web browsing benchmark (evaluated on a randomly sampled subset of 200 tasks).
- BrowseComp-ZH: The Chinese counterpart of BrowseComp (evaluated on the full set of 289 tasks).
- Humanity’s Last Exam (HLE): A benchmark designed to assess deep search and reasoning capabilities (evaluated on a sampled subset of 500 text-only tasks).
Key Insights and Ideas
- The Efficiency-Precision Trade-off: Static strategies occupy distinct, rigid spaces on the efficiency-precision plane. For example, a baseline with no context management has high search efficiency (it easily finds an answer) but terrible terminal precision due to "context rot." Conversely,
Discard-Alloffers pristine terminal precision but suffers from low search efficiency because it constantly forces the agent to restart from scratch. - Adaptive Routing Breaks the Trade-off: AgentSwing dynamically shifts between strategies based on the trajectory's health. If an agent is trapped in a broken tool-use loop, lookahead routing naturally favors the
Discard-Allbranch to clear out the noise. If the agent just uncovered a fresh local clue, it favorsKeep-Last-Nto maintain immediate momentum.
- Modest Token Overhead: While parallel lookahead rollouts sound computationally expensive, the overall token overhead remains modest in practice. Because AgentSwing frequently routes the agent toward more compact context states (like
Discard-AllorKeep-Last-N), the reduction in main-branch context length offsets the tokens spent during the short lookahead phases.
Key Results
- Fewer Turns, Higher Ceilings: On BrowseComp, AgentSwing consistently outperformed strong static baselines. Remarkably, under constrained interaction budgets, it achieved or exceeded the accuracy of static strategies while saving up to 3× the interaction turns.
- State-of-the-Art Open-Source Performance: Integrating AgentSwing pushed DeepSeek-v3.2 to 71.3 on BrowseComp-ZH and 44.4 on HLE, outperforming several prominent proprietary foundation models. It also established leading performance for the Tongyi-DR-30B-A3B model among information-seeking agents of a similar scale.
Limitations and Future Work
The authors note that AgentSwing operates purely as an external control mechanism at test time. A compelling future direction would be to translate these principles directly into model-level training, creating agents that are intrinsically robust to context constraints. Additionally, the lookahead routing is currently performed by the agent model itself. The authors suggest that developing a dedicated, highly specialized trajectory evaluator or verifier with better foresight could unlock even greater performance gains.
Summary updated