SWE-AGILE: A Software Agent Framework for Efficiently Managing Dynamic Reasoning Context

Shuquan Lian, Juncheng Liu, Yazhe Chen, Yuhong Chen, Hui Li · 2026

Read SWE-AGILE: A Software Agent Framework for Efficiently Managing Dynamic Reasoning Context by Shuquan Lian, Juncheng Liu, Yazhe Chen, Yuhong Chen, Hui Li (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-11716.txt.

Introduction

Lian and four colleagues present SWE-AGILE, a software agent framework that manages reasoning context. ReAct-style methods lack explicit System-2 reasoning, while long chain-of-thought creates a trade-off: keeping full reasoning history explodes context and lowers quality, while discarding it forces repeated re-reasoning. SWE-AGILE keeps a sliding window of detailed reasoning for continuity and shortens older reasoning into brief Reasoning Digests. On SWE-Bench-Verified, it sets a new bar for 7B-8B models using only 2,200 trajectories and 896 tasks.

Catalog record

CREATORShuquan Lian, Juncheng Liu, Yazhe Chen, Yuhong Chen, Hui Li
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE38192
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2604.11716

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

SWE-AGILE: A Software Agent Framework for Efficiently Managing Dynamic Reasoning Context Shuquan Lian, Juncheng Liu, Yazhe Chen, Yuhong Chen, Hui Li Abstract Prior representative ReAct-style approaches in autonomous Software Engineering (SWE) typically lack the explicit System-2 reasoning required for deep analysis and handling complex edge cases. While recent reasoning models demonstrate the potential of extended Chain-of-Thought (CoT), applying them to the multi-turn SWE task creates a fundamental dilemma: retaining full reasoning history leads to context explosion and “Lost-in-the-Middle” degradation, while discarding it would force the agent to redundantly re-reason at every step. To address these challenges, we propose SWE-AGILE, a novel software agent framework designed to bridge the gap between reasoning depth, efficiency, and context constraints. SWE-AGILE introduces a Dynamic Reasoning Context strategy, maintaining a “sliding window” of detailed reasoning for immediate continuity to prevent redundant re-analyzing, while compressing historical reasoning content into concise Reasoning Digests. Empirically, SWE-AGILE sets a new standard for 7B-8B models on SWE-Bench-Verified using only 2.2k trajectories and 896 tasks. Code is available at https://github.com/KDEGroup/SWE-AGILE . 1 Introduction The blossoming of Large Language Models (LLMs) and Code Models ( 13 ; 18 ) has revolutionized software engineering (SWE), enhancing efficiency in various tasks. Particularly, there is a surge of works on SWE agents for autonomously navigating repositories, localizing bugs, and fixing bugs ( 17 ; 51 ) , i.e., the SWE task. The SWE task is difficult because it involves using tools, writing code, and debugging over multiple turns. These activities are closely connected, requiring heterogeneous reasoning capabilities. Prior representative REACT-style ( 56 ) approaches like SWE-Dev ( 38 ) and SWE-smith ( 52 ) train models with limited context length (e.g., Qwen2.5 ( 50 ) and Qwen3 ( 49 ) ) to generate actions alongside shallow thought traces. However, without explicit System-2 reasoning 19 that is more analytical and deliberate, it is hard for these methods to perform deep analysis and handle edge cases correctly. Recent advancements in System-2 reasoning models, such as OpenAI o1 ( 15 ) and DeepSeek-R1 ( 7 ) , suggest that extending the Chain-of-Thought (CoT) ( 43 ) length significantly enhances LLM’s problem-solving capabilities. Attempting to harness this potential in automatic SWE, agentic scaffolds relying on powerful reasoning LLMs allow for long CoT during generation but discard these reasoning traces in the historical context, retaining only a concise description and the final action. One key observation emerges from the recent progress in System-2 reasoning models is that discarding reasoning content upon the arrival of the second round of messages results in significant token inefficiency , forcing the model to redundantly re-reason through the entire problem for each subsequent tool call, as observed on DeepSeek-V3.2 ( 6 ) . MiniMax M2 ( 25 ) also claims that Agents require Interleaved Thinking and retaining the full session history, including the reasoning content. This approach is made possible by its massive context capacity of 204,800 tokens. Figure 1: A comparison of context growth patterns in the multi-turn SWE task: (1) Shallow Thinking maintains low context cost but lacks reasoning depth. (2) Interleaved Thinking enables deep System-2 reasoning but suffers from rapid, linear context growth (steep context bar). (3) SWE-AGILE enables a sustainable “Sawtooth” growth pattern. Within the Sliding Reasoning Window , the agent engages in deep reasoning (steep slope similar to Interleaved Thinking); however, as steps progress, historical thoughts are compressed into concise Reasoning Digests . However, indiscriminately applying full-history Interleaved Thinking to the multi-turn SWE task presents fundamental scalability and efficiency challenges. SWE agents typically engage in frequent interactions involving extensive code retrievals and verbose execution logs. When retaining the long CoT from every step, the context window expands rapidly . This creates two critical issues. First, even for models capable of processing long inputs, performance often degrades as context length increases, a phenomenon known as “Lost-in-the-Middle” or attention dilution ( 21 ) , where the model struggles to retrieve relevant information from the middle of a long sequence. Second, processing such massive sequences demands excessive GPU memory and drastically reduces training speed due to computational overhead. To address the above issues, we propose a novel framework SWE-AGILE designed to bridge the gap between reasoning depth, efficiency, and context constraints in in the multi-turn SWE tasks. Fig. 1 contrasts our approach with Shallow Thinking and Interleaved Thinking at the level of inference. The main contributions of this work are summarized as follows: • Dynamic Reasoning Context: We propose a hybrid dynamic context management strategy that compresses every historical reasoning content into a concise reasoning digest for long-term retention, while preserving a “Last-N-Steps” sliding reasoning window of long CoT to maintain cognitive continuity in the working context and avoid redundantly re-analyzing the global state at every turn. • Trajectory Snapshot Training: We introduce a snapshot-based training objective to address the misalignment between standard training and dynamic inference. By decomposing trajectories into discrete snapshots with context-aware masking, we force the model to learn under the constraints of dynamic context at runtime. • Backfilling Data Synthesis: We develop a “Hindsight Backfill” pipeline that augments successful trajectories with detailed reasoning content and reasoning digests. This process leverages future ground-truth actions to synthesize high-quality, format-compliant training data tailored to our dynamic context constraints. • Compression-Aware Optimization: We design a trajectory-level Compression Rate Reward within the Reinforcement Learning with Verifiable Rewards (RLVR) process. This mechanism incentivizes the model to generate sufficiently detailed reasoning for problem-solving while maximizing the conciseness of the digests, effectively balancing performance with token efficiency. Empirically, we validate SWE-AGILE on the SWE-Bench Verified benchmark. Utilizing merely 2.2k training trajectories, SWE-AGILE achieves a 24.1% success rate, surpassing all existing 7B/8B baselines. We attribute this success to the effectiveness of our proposed paradigm: by fundamentally resolving the conflict between reasoning depth and context constraints, SWE-AGILE effectively elicits latent System-2 reasoning ability. 2 Our Method Fig. 2 provides an overview of SWE-AGILE. To enable deep reasoning within a sustainable context window, our framework is realized through three parts: (1) Trajectory Snapshot Training (Sec. 2.1 ); (2) Backfilling Reasoning and Digest (Sec. 2.2 ); and (3) RLVR with Trajectory Level Compression (Sec. 2.3 ). Figure 2: Overview of SWE-AGILE. (1) Trajectory Snapshot Training : We decompose long trajectories into discrete snapshots. In each snapshot, historical reasoning traces outside the Sliding Reasoning Window are replaced by digests ( d_{i} ) and masked from the loss, forcing the model to learn the target Y_{t} (Reasoning r_{t}\to Digest d_{t}\to Action a_{t} ) based on a compact context C_{t} . (2) Backfilling Reasoning and Digest : We synthesize high-quality training data by employing a reasoning model to augment raw trajectories. Conditioned on the ground-truth future action, the semantic hint and the dynamic context, the model backfills detailed reasoning ( r_{t} ) and concise digest ( d_{t} ). (3) RLVR with Trajectory Level Compression: We introduce a compression-aware reward function. The model is incentivized to maximize the reduction ratio between the actual hybrid context ( \mathcal{L}_{hybrid} ) and the hypothetical full context ( \mathcal{L}_{full} ), thereby learning to efficiently compress historical information without sacrificing task success ( \mathbb{I}_{success} ). 2.1 Dynamic Reasoning Context and Trajectory Snapshot Training SWE-AGILE formalizes the agent’s interaction as a sequence of steps t=\{1,2,3,\cdots,T\} . At each step, the generation

Read the complete text