Source-linked AI summary
SWE-AGILE: A Software Agent Framework for Efficiently Managing Dynamic Reasoning Context
Shuquan Lian, Juncheng Liu, Yazhe Chen, Yuhong Chen, Hui Li
TL;DR
Existing SWE agents either lack explicit System-2 reasoning or face inefficiency and context degradation when handling long reasoning histories. SWE-AGILE uses a dynamic reasoning context with a sliding window and compressed historical digests, supported by snapshot training and compression-aware RLVR. It achieves 24.1% success on SWE-Bench Verified using 2.2k training trajectories and is reported to surpass existing 7B/8B baselines.
Problem
ReAct-style SWE agents often lack explicit System-2 reasoning, while retaining or discarding long reasoning histories creates competing context-growth and redundant-reasoning problems.
Method
SWE-AGILE keeps detailed reasoning in a sliding window, compresses older reasoning into digests, and trains this behavior with trajectory snapshots and compression-aware RLVR.
Results
24.1% success on SWE-Bench Verified using 2.2k training trajectories, surpassing existing 7B/8B baselines.
Takeaways & Limitations
SWE-AGILE reconciles explicit System-2 reasoning with manageable context for long-horizon SWE tasks.
Takeaways & Limitations
The sliding reasoning window is randomly set between 2 and 5, and its size has not been fully analyzed.
Abstract
from arXiv · showhide
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
Multi-turn SWE agents must balance deep System-2 reasoning against rapidly growing contexts, redundant re-reasoning, and degraded retrieval from long histories. SWE-AGILE addresses this tension with dynamic context management, snapshot-based training, backfilling, and compression-aware optimization.
- Limited-context ReAct-style agents generate shallow thought traces, making deep analysis and correct handling of edge cases difficult.
- Discarding reasoning after each turn forces agents to redundantly re-reason, whereas retaining full histories causes rapid context growth in tool-intensive SWE tasks.
- Long contexts can trigger Lost-in-the-Middle degradation and impose excessive GPU-memory and training-speed costs.
- SWE-AGILE preserves detailed long Chain-of-Thought within a Last-N-Steps sliding window while compressing older reasoning into concise digests.
- Trajectory Snapshot Training aligns training with dynamic inference by exposing transient reasoning only within snapshots and converting each trace into a later digest.
- Compression-aware RLVR rewards detailed problem-solving reasoning alongside concise digests, while SWE-AGILE reaches 24.1% on SWE-Bench Verified using 2.2k training trajectories.
2 Our Method
SWE-AGILE manages multi-turn software-engineering reasoning by retaining recent detailed thoughts while compressing older reasoning into structured digests. Its training aligns with this dynamic visibility through trajectory snapshots and hindsight backfilling, while RLVR rewards successful task solving alongside context compression.
- Framework Overview: SWE-AGILE combines trajectory snapshot training, hindsight backfilling, and trajectory-level compression-aware RLVR.These three components align training with dynamic inference context, synthesize reasoning data, and optimize task success with token efficiency.
- Dynamic Reasoning Context: The hybrid context retains all environmental observations and actions, but replaces reasoning outside the sliding window with concise per-step digests.Recent detailed reasoning remains available for cognitive continuity, while older reasoning is compressed for long-term retention.
- Trajectory Snapshot Training: Trajectory snapshots expose compressed historical context as a frozen prompt and train only the current reasoning, digest, and executable action.Each reasoning trace is optimized once as an active target, then serves as a compressed digest in later snapshots, resolving training-inference mismatch.
- Backfilling Reasoning and Digest: Hindsight Backfill uses a reasoning model to synthesize detailed reasoning and digests from successful trajectories conditioned on future actions, semantic hints, and dynamic context.The future ground-truth action guides a reasoning trace toward the recorded correct decision while preserving the trajectory’s initial intent and visibility constraints.
- RLVR with Trajectory-Level Compression: RLVR conditions compression efficiency on task success and clips the compression reward to prevent reasoning traces from being artificially bloated.The optimization separates transient detailed reasoning from permanent digest retention, balancing problem-solving depth with context conciseness.
3 Experiment
Experiments evaluate SWE-AGILE on SWE-Bench-Verified using Qwen3 models and analyze performance, context management, reasoning efficiency, and compression. Results indicate that dynamic reasoning context and compression-aware training improve efficiency while preserving task success and avoiding degradation from excessive historical reasoning.
- Overall Performance: SWE-AGILE achieves a 24.05% success rate on SWE-Bench-Verified with Qwen3-8B, surpassing reported baselines of comparable size using 2.2k training trajectories.SWE-AGILE (SFT) reaches 21.45%, while compression-aware RLVR increases success to 24.05%.
- Evaluation Analysis: The experiments report accuracy, average steps, and token consumption while decomposing each response into Reasoning, Textual Summary, and Action.For SWE-AGILE, the Textual Summary corresponds to the Reasoning Digest; for the Current-Step baseline, it is the standard Thought trace.
- Context Management: Retaining full reasoning history yields 12.42% performance, below the 15.83% achieved when historical reasoning is discarded.The comparison is presented as evidence of the Lost-in-the-Middle phenomenon despite the richer retained context.
- Training Strategy: Training on 2.2k original SWE-Dev trajectories lowers success to 14.83%, below the 15.83% base-model result.The authors attribute this to shallow traces encouraging superficial dataset heuristics rather than deep problem-solving.
- Reasoning Efficiency: SWE-AGILE reduces active reasoning from approximately 1,075 to 819.6 tokens per step, a 28% decrease relative to Current-Step Thinking.Reasoning Digests and the Sliding Reasoning Window are described as a cognitive cache supporting incremental rather than redundant analysis.
- Compression Efficiency: Compression Reward reduces the Textual Summary from 41 to 27.3 tokens, a 33.4% reduction, while maintaining comparable task success.The authors suggest that combining reasoning-digest compression with tool-output compression could permit more interaction turns before context limits are reached.
4 Related Work
Related work spans agentic SWE scaffolds, environment and trajectory construction, post-training, inference-time scaling, and Chain-of-Thought compression. SWE-AGILE is positioned as complementary to single-turn CoT compression because it targets cognitive continuity across multi-turn environmental interactions.
- Agentic SWE Scaffolds and Pipelines: Agentic SWE research includes scaffolds that navigate repositories, edit files, and execute shell commands, alongside pipeline-based approaches for decision-making and environment construction.Examples include SWE-agent, OpenHands, SWE-Search, and several environment-curation pipelines.
- Training and Inference-Time Scaling: Post-training methods such as rejection-sampling fine-tuning, DPO, and GRPO build on SWE datasets to improve software-engineering agents.The related work also identifies inference-time scaling as a complementary route for improving deployment performance.
- System-2 Reasoning and CoT Efficiency: Longer CoT can improve problem solving, but overlong reasoning may increase computational overhead, attention dilution, and narrative overfitting.Related methods address this trade-off through length penalties, token skipping, harmonized rewards, or length-preference training.
- CoT Compression: Single-turn CoT compression methods target internal thinking, whereas SWE-AGILE targets cognitive continuity across multi-turn environmental interactions.The paper characterizes SWE-AGILE as orthogonal to these methods and therefore combinable with them.
5 Conclusion
SWE-AGILE reconciles reasoning depth with context constraints in long-horizon SWE by decoupling transient reasoning overhead from permanent context retention. This supports reducing redundant re-analyzing while improving agent cognitive efficiency.
- SWE-AGILE reconciles reasoning depth with context constraints in long-horizon SWE through Dynamic Reasoning Context, trajectory snapshot training, and compression-aware RLVR.The framework enables explicit System-2 reasoning while preventing context explosion.
- Decoupling transient reasoning overhead from permanent context retention supports explicitly identifying and minimizing redundant re-analyzing.The paper presents this as groundwork for optimizing agent cognitive efficiency in future research.
Limitation
The current SWE-AGILE implementation randomly sets the sliding reasoning window size between 2 and 5 across training and inference, leaving its size insufficiently analyzed.
- The sliding reasoning window is randomly set to an integer between 2 and 5 during backfilling, SFT, RLVR, and inference.The authors state that further analysis of window size remains unexplored.
A Scaffold
The scaffold equips the agent with file editing, search, bash execution, and submission tools, while supplementing SFT data with approximately 200 four-tool R2E-Gym trajectories.
- The scaffold provides file editing, search, bash execution, and submission tools for diverse SWE tasks.The submit tool ends the trajectory while returning expected outputs.
- SWE-Dev trajectories lack the search tool, although bash can largely provide the same search functionality.The authors therefore collect additional four-tool trajectories for SFT supplementation.
- Approximately 200 R2E-Gym task trajectories using four tools supplement the SFT data.
B Detailed Hyperparameters
Table 3 provides more detailed hyperparameters for the training configuration described in the paper.
- Table 3 provides more detailed hyperparameters.
C Tool Calling Format
SWE-AGILE adopts XML-based tool calling to make code-containing arguments more robustly parseable. This avoids the nesting and escaping problems that often affect JSON tool calls in SWE tasks.
- XML-based tool calling is adopted to mitigate nesting and escaping issues in SWE tool arguments.Tool arguments often contain code snippets with strings and special characters.
- JSON-based tool calling can produce syntax errors when code snippets require multi-level escaping.The passage attributes this challenge particularly to limited model capabilities.
- The XML format is intended to provide more robust parsing for software-engineering tool calls.