PreprintCited by 3Software Engineering ResearchSoftware Engineering Techniques and PracticesAI-based Problem Solving and Planning

Context as a Tool: Context Management for Long-Horizon SWE-Agents

Open access
Liu, Shukai, Yang, Jian, Jiang, Bo, Li, Yizhi, Guo, Jinyang, Liu, Xianglong, Dai, Bryan·2025·arXiv

Abstract

Agents based on large language models have recently shown strong potential on real-world software engineering (SWE) tasks that require long-horizon interaction with repository-scale codebases. However, most existing agents rely on append-only context maintenance or passively triggered compression heuristics, which often lead to context explosion, semantic drift, and degraded reasoning in long-running interactions. We propose CAT, a new context management paradigm that elevates context maintenance to a callable tool integrated into the decision-making process of agents. CAT formalizes a structured context workspace consisting of stable task semantics, condensed long-term memory, and high-fidelity short-term interactions, and enables agents to proactively compress historical trajectories into actionable summaries at appropriate milestones. To support context management for SWE-agents, we propose a trajectory-level supervision framework, CAT-GENERATOR, based on an offline data construction pipeline that injects context-management actions into complete interaction trajectories. Using this framework, we train a context-aware model, SWE-Compressor. Experiments on SWE-Bench-Verified demonstrate that SWE-Compressor reaches a 57.6% solved rate and significantly outperforms ReAct-based agents and static compression baselines, while maintaining stable and scalable long-horizon reasoning under a bounded context budget.

AI snapshot

Written from the paper’s full text.

TL;DR

CAT proposes treating context management as a callable tool for long-horizon SWE agents, using a structured workspace and proactive compression. With CAT-GENERATOR trajectory supervision, SWE-Compressor reaches a 57.6% solved rate on SWE-Bench Verified.

Key findings

  • SWE-Compressor achieves 57.6% solved rate on SWE-Bench Verified (N=500), outperforming the ReAct Agent (49.8%) and Threshold-Compression Agent (53.8%) under the same 32B/OpenHands setting.
  • In Table 3, CAT at 500 max steps reaches 57.8% pass with 2.75M tokens, versus ReAct at 48.8% with 2.54M tokens and Threshold-Compression at 53.8% with 5.18M tokens; at 150 steps CAT uses the fewest tokens (1.89M) and reaches 54.8% pass.
  • CAT maintains compact context: average token count stabilizes after approximately 100 rounds and remains below 32k tokens, with more than 40% of tasks still interactive after 100 rounds; Figure 5 reports CAT context usage stable at approximately 35k tokens while ReAct rapidly exhausts the context window.
  • CAT-Instruct statistics include average trajectory length 87.4 steps (median 77.5, max 500), average 4.22 context-management actions per trajectory, and compression from average 15,585 tokens before to 4,676 tokens after (30% ratio).

Methods

  • CAT formalizes a structured context workspace C(t) = (Q, M(t), I(k)(t)): fixed system prompt and key user intent, condensed long-term memory, and the most recent k ReAct interaction steps; context management is modeled as a callable tool at the same decision level as environment-interaction tools.
  • CAT-GENERATOR is a two-stage offline pipeline: first generate complete base ReAct trajectories without context compression, then inject context-management tool invocations at candidate positions, generate structured long-term memory summaries, stitch trajectories with minimal intrusion, and apply rejection sampling; this yields 20k CAT-Instruct SFT instances.
  • The model SWE-Compressor is trained from Qwen2.5-Coder-32B on CAT-Instruct for up to three epochs using AdamW with weight decay 0.01, cosine learning rate schedule, warm-up ratio 0.1, peak learning rate 5 × 10^-5, and context length 65,536 tokens; evaluation uses OpenHands on SWE-Bench Verified (500 instances), temperature 0.0, up to 500 interaction rounds, reporting Pass@1.

Limitations

  • The paper does not state a limitations section.
  • Evident from the text: evaluation is limited to SWE-Bench Verified (500 instances) and a single base model, Qwen2.5-Coder-32B; no cross-model or cross-benchmark validation is reported.
  • Evident from the text: training data are drawn from SWE-smith and SWE-ReBench, and the main comparison uses 20k CAT-Instruct versus 20k BASE-INSTRUCT; broader generalization to other repositories or agent scaffolds is not tested.

Model-written summary. Check it against the paper before relying on it.

Integrity signals

Registry

DataCite · 10.48550/arxiv.2512.22087

Cites

0 citation errors · 0 not checkable

Statistics

Nothing to recompute.

Claims the paper makes

4 of 12 cited sources checked · 0 supported · 0 flagged · accuracy not yet measured

  • Premisecitation
    § 5 Related Work · p. 8

    Most prior context management approaches rely on static compression or fixed memory policies.

    “However, most rely on static compression or fixed memory policies”
    Quote in the paperSubstantial claim1 of 3 sources checked
    • cites Li, 2023

      Couldn’t be matched to a paper in Crossref, so it can’t be checked.

    • cites Jiang et al., 2023

      The Introduction describes Selective-Context as an earlier prompt-compression method, while the Methodology describes LLMLingua’s dynamic allocation of compression ratios. Neither passage says that most prior context-management approaches use static compression or fixed memory policies; searches for those characterizations found no supporting passage in our copy. Page numbers were not available. (LLM, conf=0.70)

      Experimental — accuracy not yet measured
    • cites Pan et al., 2024b

      Couldn’t be matched to a paper in Crossref, so it can’t be checked.

  • Premisereasoning
    § 1 Introduction · p. 1

    Prior context compression, summarization, or multi-level memory approaches treat context management as a passively triggered heuristic mechanism, lacking flexibility to adapt compression timing and content across task phases.

    “Nevertheless, previous approaches treat context management as a passively triggered heuristic mechanism, so they lack the flexibility to adapt compression timing and content across different task phases, limiting their adaptability and scalability in complex environments.”
    Quote in the paperSubstantial claim2 of 3 sources checked
    • cites Jiang et al., 2023

      The Introduction and Methodology sections describe limitations of earlier prompt-compression methods and propose dynamically allocating compression ratios across prompt components. They do not characterize prior context-management approaches as passively triggered, or assess whether those approaches can adapt compression timing across task phases in complex environments. No page numbers are available in our copy. (LLM, conf=0.78)

      Experimental — accuracy not yet measured
    • cites Shinn et al., 2023 source

      The Self-reflection section describes Reflexion’s short- and long-term memory, and §5 Limitations says its long-term memory uses a capacity-limited sliding window. Neither passage assesses prior compression, summarization, or multi-level memory approaches as passive heuristics, or discusses their ability to adapt compression timing and content across task phases. Searches for those terms found no passage addressing that comparison; page numbers were unavailable in our copy. (LLM, conf=0.76)

      Experimental — accuracy not yet measured
    • cites Wang et al., 2025b

      Couldn’t be matched to a paper in Crossref, so it can’t be checked.

  • Findingreasoning
    § 4 Further Analysis · p. 7

    The performance gains are substantially larger on the medium and hard subsets than on the easy subset.

    “The performance gains are substantially larger on the medium and hard subsets than on the easy subset.”
    Quote in the paperSubstantial claim
  • Findingown data
    § 1 Introduction · p. 2

    The proposed CAT/SWE-Compressor substantially outperforms ReAct without context management and static compression baselines on SWE-Bench under the same model scale and interaction budget.

    “Experimental results on SWE-Bench show that CAT substantially outperforms ReAct without context management and baselines with static compression strategies under the same model scale and interaction budget, demonstrating the strong context scalability in long-horizon interaction settings.”
    • Also stated in: § Abstract · p. 1 · plain
      “Experiments on SWE-BenchVerified demonstrate that SWE-Compressor reaches a 57.6% solved rate and significantly outperforms ReAct-based agents and static compression baselines, while maintaining stable and scalable long-horizon reasoning under a bounded context budget.”
    Quote in the paperSubstantial claim
  • Findingown data
    § 4 Further Analysis · p. 7

    In the experiments, more than 40% of tasks remain interactive after 100 rounds.

    “Moreover, the trajectory survival curve indicates that, in our experiments, more than 40% of tasks remain interactive after 100 rounds.”
    Quote in the paperSubstantial claim
  • May combine two claims. 21
  • Classified as probably not a substantial claim. 10
  • May combine two claims.

    Premisecitation
    § A Related Work · p. 12

    Existing approaches rely on static compression, heuristic retrieval, or fixed memory, limiting adaptability and long-term coherence.

    “Yet, these approaches rely on static compression, heuristic retrieval, or fixed memory, limiting adaptability and long-term coherence.”
    Quote in the paperSubstantial claim1 of 3 sources checked
    • cites Li, 2023

      Couldn’t be matched to a paper in Crossref, so it can’t be checked.

    • cites Jiang et al., 2023

      The Introduction describes a prior prompt-compression method that drops less informative content and overlooks dependencies between retained tokens; Section 5.3 reports that it can lose critical reasoning information. That supports a limitation of prior compression, but the paper does not characterize existing approaches as relying on heuristic retrieval or fixed memory, or establish that they limit long-term coherence. Pages are not identified in our copy. (LLM, conf=0.84)

      Experimental — accuracy not yet measured
    • cites Pan et al., 2024b

      Couldn’t be matched to a paper in Crossref, so it can’t be checked.

  • May combine two claims.

    Findingreasoning
    § 4 Further Analysis · p. 8

    Under a smaller interaction budget (150 steps), CAT both maintains competitive performance and uses the fewest tokens across all methods.

    “Under a smaller interaction budget (150 steps), CAT both maintains competitive performance and uses the fewest tokens across all methods.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data
    § 3 Experiments · p. 6

    Under the same fine-tuning data budget, SWE-Compressor significantly outperforms both the ReAct Agent and the Threshold-Compression Agent baselines.

    “Under the same fine-tuning data budget, SWE-Compressor significantly outperforms both the ReAct Agent and the Threshold-Compression Agent baselines.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data
    § 3 Experiments · p. 6

    SWE-Compressor's performance is comparable to substantially larger models, and in some settings surpasses them, under the same agent framework.

    “Moreover, its performance is comparable to that of substantially larger models, and in some settings even surpasses them, under the same agent framework.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data
    § 4 Further Analysis · p. 7

    In Figure 5, the context token usage of CAT remains stable at approximately 35k tokens, whereas the ReAct baseline rapidly exhausts the available context window.

    “In Figure 5, the context token usage of CAT remains stable at approximately 35k tokens, whereas the ReAct baseline rapidly exhausts the available context window.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingreasoning
    § 4 Further Analysis · p. 7

    As the interaction budget increases, ReAct performance saturates after around 60 rounds and subsequently degrades.

    “As the interaction budget increases, ReAct performance saturates after around 60 rounds and subsequently degrades”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingreasoning
    § 4 Further Analysis · p. 8

    SWE-Compressor consistently outperforms the Base SFT model, especially under larger interaction budgets.

    “Results show that SWE-Compressor consistently outperforms Base SFT model, especially under larger interaction budgets”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data
    § 4 Further Analysis · p. 7

    The average context token count for CAT stabilizes after approximately 100 interaction rounds and remains below 32k tokens, without continuous growth over time.

    “As the interaction progresses, the average token count quickly stabilizes after approximately 100 rounds and remains below 32k tokens, without exhibiting continuous growth over time”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data
    § 6 Conclusion · p. 8

    CAT consistently outperforms ReAct agents and static compression baselines, while maintaining stable context usage and scalability under extended interaction budgets.

    “Experiments on SWE-Bench demonstrate that CAT consistently outperforms ReAct agents and static compression baselines, while maintaining stable context usage and scalability under extended interaction budgets”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Findingown data
    § 3 Experiments · p. 6

    SWE-Compressor achieves a 57.6% solved rate on SWE-Bench-Verified, reaching state-of-the-art performance under the setting of agent post-training on a 32B model.

    “On the challenging SWE-Bench-Verified benchmark, SWE-Compressor achieves a 57.6% solved rate, reaching state-of-the-art performance under the setting of agent post-training on a 32B model.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Interpretationreasoning
    § 4 Further Analysis · p. 7

    CAT-GENERATOR and CAT have advantages in addressing difficult tasks.

    “These findings further highlight the advantages of CAT-GENERATOR and CAT in addressing difficult tasks.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Interpretationreasoning
    § 2.1 Structured Context Workspace · p. 3

    CAT's structured context workspace mitigates both semantic drift and uncontrolled context expansion.

    “In this way, stable goals, condensed knowledge, and finegrained working memory are coordinated within a unified framework, mitigating both semantic drift and uncontrolled context expansion.”
    Quote in the paperNot a substantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing), S4 (based). May combine two claims.

    Study design and conductnone given
    § 2.4 Supervised Trajectory Construction · p. 5

    The summarizer uses the same backbone as the reasoning model, keeping summarization aligned with the agent's internal reasoning style.

    “The summarizer uses the same backbone as the reasoning model (SWE-Compressor), keeping summarization aligned with the agent's internal reasoning style.”
    Quote in the paperNot a substantial claim
  • May combine two claims.

    Interpretationown data
    § 4 Further Analysis · p. 7

    CAT can continuously integrate salient information within a bounded context budget while compressing redundant history.

    “suggesting that CAT can continuously integrate salient information within a bounded context budget while compressing redundant history.”
    Quote in the paperSubstantial claim
  • Probably not a substantial claim: may not pass S4 (based).

    Interpretationreasoning
    § 2.3 Structured Memory Generation · p. 3

    After summarization, the agent reconstructs its working context by combining fixed task semantics, condensed long-term memory, and the most recent high-fidelity interaction steps, enabling stable and consistent reasoning under a bounded context budget.

    “After summarization, the agent reconstructs its working context by combining the fixed task semantics, the condensed long-term memory, and the most recent high-fidelity interaction steps, enabling stable and consistent reasoning under a bounded context budget.”
    Quote in the paperNot a substantial claim
  • May combine two claims.

    Interpretationown data
    § 4 Further Analysis · p. 7

    CAT equips the model with stable and extensible long-horizon interaction capabilities, highlighting its strong potential for addressing highly complex and long-running software engineering tasks.

    “This observation further suggests that CAT equips the model with stable and extensible long-horizon interaction capabilities, highlighting its strong potential for addressing highly complex and long-running software engineering tasks.”
    Quote in the paperSubstantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Premisecitation
    § 3 Experiments · p. 5

    SWE-Bench Verified consists of 500 instances manually curated to provide clearer problem descriptions and more reliable evaluation criteria.

    “The Verified split is a high-quality subset of SWE-Bench consisting of 500 instances, which are manually curated to provide clearer problem descriptions and more reliable evaluation criteria.”
    Quote in the paperNot a substantial claim0 of 1 sources checked
    • cites Hou et al., 2024 source
  • Probably not a substantial claim: may not pass S4 (based). May combine two claims.

    Interpretationreasoning
    § A Related Work · p. 12

    Tool Condensor enables dynamic, execution-driven context management, flexibly removing redundancy while preserving critical information-essential for complex long-horizon tasks.

    “In contrast, Tool Condensor enables dynamic, execution-driven context management, flexibly removing redundancy while preserving critical information-essential for complex long-horizon tasks.”
    Quote in the paperNot a substantial claim
  • Classified as probably not a substantial claim. May combine two claims.

    Study design and conductnone given
    § 3 Experiments · p. 6

    For all baselines, the same base model as SWE-Compressor and the same summarizer backbone for any compression operation are used.

    “For all baselines, we use the same base model as SWE-Compressor and use the same summarizer backbone for any compression operation.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Interpretationreasoning
    § 1 Introduction · p. 2

    SWE-Compressor learns when to compress context, how to generate effective summaries, and how to reuse compressed representations during subsequent reasoning.

    “Using CATGENERATOR, we train a context-aware model, SWE-Compressor, allowing it to learn when to compress context, how to generate effective summaries, and how to reuse compressed representations during subsequent reasoning.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Interpretationreasoning
    § 2.2 Context Management as a First-Class Tool · p. 3

    The agent tends to proactively trigger context management when a subtask has been completed and requires a stage-wise summary, when the trajectory has grown sufficiently large, or when subsequent reasoning benefits more from a concise, structured summary.

    “In practice, the agent tends to proactively trigger context management when a subtask has been completed and requires a stage-wise summary, when the trajectory has grown sufficiently large that historical compression is necessary to maintain operational efficiency, or when subsequent reasoning benefits more from a concise, structured summary than from verbose raw logs.”
    Quote in the paperSubstantial claim
  • May combine two claims.

    Interpretationown data
    § Abstract · p. 1

    SWE-Compressor maintains stable and scalable long-horizon reasoning under a bounded context budget.

    “while maintaining stable and scalable long-horizon reasoning under a bounded context budget.”
    • Also stated in: § 1 Introduction · p. 2 · boosted
      “demonstrating the strong context scalability in long-horizon interaction settings.”
    Quote in the paperSubstantial claim
  • Classified as probably not a substantial claim.

    Interpretationnone given
    § 1 Introduction · p. 2

    CAT organizes context into a structured workspace consisting of stable task-semantic anchors, an evolvable long-term memory, and a short-term working memory.

    “In Figure 1, CAT organizes the context into a structured workspace consisting of stable tasksemantic anchors, an evolvable long-term memory, and a short-term working memory.”
    • Also stated in: § 2.1 Structured Context Workspace · p. 2 · plain
      “CAT models context as a controllable and dynamically updated cognitive workspace composed of three functional segments, as illustrated in Figure 2.”
    Quote in the paperSubstantial claim
  • Probably not a substantial claim: may not pass S3 (load-bearing).

    Premisecitation
    § 3 Experiments · p. 5

    SWE-Bench is a benchmark designed to assess LLMs on real-world software engineering tasks collected from 12 real-world GitHub repositories.

    “SWE-Bench is a benchmark designed to assess the ability of LLMs to solve real-world software engineering tasks collected from 12 real-world GitHub repositories.”
    Quote in the paperNot a substantial claim0 of 1 sources checked
    • cites Hou et al., 2024 source
  • Classified as probably not a substantial claim.

    Interpretationreasoning
    § 2.4 Supervised Trajectory Construction · p. 5

    The advantage of trajectory-level supervision lies in preserving the temporal continuity of context evolution, allowing the model to observe the immediate summary and learn how that summary influences reasoning and decision-making across subsequent steps.

    “The advantage of trajectory-level supervision lies in preserving the temporal continuity of context evolution, allowing the model not only to observe the immediate summary produced by a context-management tool invocation but also to learn how that summary influences reasoning and decision-making across subsequent steps.”
    Quote in the paperSubstantial claim
  • Probably not a substantial claim: may not pass S4 (based).

    Interpretationnone given
    § 5 Related Work · p. 8

    Our Tool Condensor enables dynamic, execution-driven context management that actively preserves decision-critical information over extended horizons.

    “whereas our Tool Condensor enables dynamic, execution-driven context management that actively preserves decision-critical information over extended horizons.”
    Quote in the paperNot a substantial claim
  • Probably not a substantial claim: may not pass S4 (based). May combine two claims.

    Interpretationreasoning
    § 2.1 Structured Context Workspace · p. 2

    CAT's structured context workspace provides a stable semantic anchor for the task while preserving fine-grained information from recent environment feedback, thereby supporting precise contextualized actions.

    “This design provides a stable semantic anchor for the task while preserving fine-grained information from recent environment feedback, thereby supporting precise contextualized actions.”
    Quote in the paperNot a substantial claim
27 of 27
  • The paper relies on this without support.

    Long-horizon SWE tasks often require hundreds of interaction rounds.

    “Most SWE tasks (e.g., repositorylevel issue resolution (Jimenez et al., 2023)) often require LLMs to continuously interpret environment feedback, execute actions, and revise strategies over hundreds of interaction rounds, which poses greater demands on context management.”
  • The paper relies on this without support.

    SWE-Bench-Verified tasks are representative of long-horizon interactive software engineering tasks.

    “On the challenging SWE-Bench-Verified benchmark”
  • The paper relies on this without support.

    Human solution time reported in the original dataset is a valid measure of task difficulty.

    “We partition SWE-Bench into difficulty levels based on the original dataset's reported human solution time.”
  • The paper relies on this without support.

    A context token count below 32k tokens indicates prevention of context explosion.

    “remains below 32k tokens, without exhibiting continuous growth over time, indicating the effectiveness of CAT in preventing context explosion.”
  • The paper relies on this without support.

    The 32B model post-training setting is a fair comparison to substantially larger models.

    “reaching state-of-the-art performance under the setting of agent post-training on a 32B model”
5 of 5

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

Each contradiction between two passages listed here was confirmed by an independent check.

  • CAT's 500-step solved rate differs between tables

    Major

    Table 2 reports SWE-Compressor at 57.6%, while Table 3 reports CAT at 57.8% for the same benchmark with a 500-step limit. The paper identifies SWE-Compressor as the CAT-trained model and states that Table 2 uses a limit of 500 interaction rounds.

  • ReAct's 500-step solved rate differs between tables

    Minor

    Table 2 reports the ReAct baseline at 49.8%, but Table 3 reports 48.8% for ReAct at 500 steps. The paper states that Table 2 also permits up to 500 interaction rounds.

2 of 2

Cites

The publisher hasn’t deposited this paper’s reference list.

Research works printed but not linked: 3

  1. Mengkang Hu, Tianxing Chen, Qiguang Chen, Yao Mu, Wenqi Shao, and Ping Luo. 2025. Hiagent: Hierarchical working memory management for solving long-horizon agent tasks with large language model. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) , pages 32779-32798.
  2. OpenAI. 2023. Gpt-4 technical report. arXiv preprint arXiv:2303.08774 . · arXiv
  3. Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik R Narasimhan, and Yuan Cao. 2022. React: Synergizing reasoning and acting in language models. In The eleventh international conference on learning representations .

Cited by

Sorted by citations

Authors
Liu, S., Yang, J., Jiang, B., Li, Y., Guo, J., Liu, X., & Dai, B.
Venue
arXiv
Publisher
arXiv
Published
2025
ISSN
2331-8422 (ISSN-L)
OpenAlex
W7117557793
Cited by
1
References
0
Citations by year
2026: 1
Type
posted content
Open access
Locations
arXiv (Cornell University)
Topics
  • Physical Sciences › Computer Science › Information Systems › Software Engineering Research
  • Physical Sciences › Computer Science › Information Systems › Software Engineering Techniques and Practices
  • Physical Sciences › Computer Science › Artificial Intelligence › AI-based Problem Solving and Planning
Keywords
context management, long-horizon reasoning, SWE-agent, large language models, context compression, semantic drift, long-term memory

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Claims read by deepseek-v4.1-flash under definition version 3 (extract-v3) on 2026-10-10.

Classified by jev-1.13-20260917 (gold-guideline-v0.2) on 2026-10-10.

Cited sources are checked by gpt-6-sol.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review