Software workflows · Research feature

SWE-MILE: Asynchronous Potential-Induced Milestone Credit Assignment for Long-Horizon Software Engineering Agents

A new method analyzes real-time software development workflows to provide detailed feedback to AI agents during long-term coding tasks.

Adapted from research by Chaoqun Cui, Hao Zhou, Meiqi Chen and colleagues.

arXiv preprint revision · 2026-09-26 · Attribution & reuse
In this article
Editorial illustration of stacks of coins.

Editor’s introduction

The study focuses on long-horizon software engineering agents trained with reinforcement learning. Researchers compared how different methods assign credit to individual actions based on workflow runtime signals. SWE-MILE measures progress through navigation and verification potentials, attributing milestone changes to specific actions via potential differences and backward credit. Asynchronous shadow probing enables parallel verification, reducing latency without external evaluators. The method improves agent performance by leveraging process-level signals from actual development workflows. A key boundary of the evidence is that the approach relies on the assumption that file exposure and test-state alignment reliably reflect task progress.

Introduction

In recent years, Large Language Models (LLMs) have evolved from isolated code generation toward long-horizon software engineering (SWE) agents for repository-level tasks. These SWE agents operate in real code repositories through multi-turn interaction, performing codebase navigation, inspection, editing, and testing to accomplish issue resolution and even whole-repository generation tasks. With the development of large-scale executable SWE environments such as SWE-Gym and R2E-Gym, reinforcement learning with verifiable rewards (RLVR) has gradually become an important training paradigm for further improving the ability of SWE agents to autonomously solve complex tasks. These methods use unit-test-based task-specific verifiers provided by SWE environments to provide objective reward feedback for agent policy rollouts, and then optimize the agent policy with GRPO, PPO, and their variants. However, this reliable feedback is still predominantly consumed as a terminal outcome. The final verifier determines whether a rollout succeeds, but does not reveal which intermediate actions contribute to or undermine that outcome.

RLVR relying solely on such coarse-grained supervision faces a severe temporal credit assignment problem. SWE trajectories typically contain tens or hundreds of heterogeneous actions. A successful trajectory may contain redundant exploration or temporary functional regressions, while a failed trajectory may still correctly localize the issue or partially fix it. Therefore, broadcasting the same outcome reward to all actions in a trajectory makes it difficult to reflect each action’s contribution to the final outcome. Existing work explores fine-grained supervision from three directions: 1. Rule-based methods, which assign process rewards based on predefined interaction rules, such as valid tool calls, successful tool execution, or other execution validity signals. However, these signals mainly capture protocol compliance or shallow tool behaviors rather than substantive task progress or functional regressions, while handcrafted rules remain susceptible to reward hacking. 2. Auxiliary model-based methods, which evaluate intermediate actions by training reward models or prompting external LLM evaluators with process-specific rubrics. These methods rely on model-estimated proxy signals that are not directly grounded in verifiable functional changes of the repository, while introducing additional inference workload and latency. 3. State aggregation methods, which aggregate steps reaching equivalent states across multiple rollouts and estimate step values from their downstream outcomes. However, the rich environment states in SWE tasks make state matching sparse, while process values are still inferred indirectly from downstream outcomes.

Codeflow Interaction Harness

We equip the agent with a scaffold containing multiple structured tools, termed Codeflow, which separates retrieval, inspection, editing, and testing into individual actions to facilitate attribution of agent behavior. Specifically, the Codeflow scaffold provides five structured tools: search, read_file, edit_file, execute_bash, and submit. SWE-MILE attributes navigation potential based on tool invocation behavior. Despite the availability of dedicated tools, the agent may still use execute_bash to perform file retrieval, inspection, and editing. Codeflow therefore applies static Shell analysis based on lexical tokenization and command rules to identify retrieval and inspection operations, and combines the parsed operation semantics with the standard output actually visible to the model for file-level navigation attribution. Editing behavior is attributed based on repository hash consistency before and after tool execution. In addition, to study the impact of a structured action space versus a more flexible Bash-only action space on agent performance, Codeflow also supports a Bash only mode that provides only the execute_bash and submit tools. Further details of the Codeflow scaffold are provided in Appendix B.3.

Milestone Potential and Process Credit

Inspired by, we derive the process reward of SWE-MILE from milestone potential differences. We instantiate runtime-grounded process supervision with two milestone potentials, navigation and verification, as representative signals of intermediate progress. The same principle can extend to other readily observable, task-general runtime states.

Importantly, navigation potential must be scored based on the agent’s actual observation rather than the command string alone. Failed commands should not receive credit; for example, using read_file to inspect a file and receiving Error: file not found should not be counted. Some datasets may provide line-level annotations for relevant files, enabling more precise quantification of agent navigation behavior. In this study, however, we use only file-level supervision.

Asynchronous Shadow Probing

During SWE agent RL training, both agent rollout and actor updates are GPU-bound computation, leaving substantial CPU and memory resources idle on training nodes. We therefore use the node-local SWE-MiniSandbox to deploy both the primary and shadow sandboxes. SWE-MiniSandbox maintains runtime isolation through namespaces and cgroups while sharing the underlying CPU and memory resources of the training node. This eliminates dependence on remote Docker sandbox services such as Kubernetes and their per-instance resource quotas, while improving resource utilization on local training machines.

Experimental Settings

We evaluate SWE-MILE on issue resolution and whole-repository generation tasks. For issue resolution, we train on the Python subset (1,952 tasks) of the SWE-rebench V2-Filtered-Verified dataset, and evaluate on SWE-bench Verified (500 tasks) and the public subset of SWE-bench Pro (731 tasks), with an inference budget of 200 turns and 256k context. For whole-repository generation, we train on the DeNovoSWE (3,675 tasks) dataset, and evaluate on NL2Repo-Bench (104 tasks) and the Doc2Repo subset of BeyondSWE (50 tasks), with an inference budget of 500 turns and 256k context. All training and evaluation experiments use the same Codeflow scaffold. More detailed experimental settings are provided in Appendix B.1.

Conclusion

We propose SWE-MILE, a process credit assignment method for reinforcement learning of long-horizon SWE agents. SWE-MILE characterizes task progress and functional regressions using navigation and verification potentials, and attributes feedback to specific actions through potential differences and backward credit, while asynchronous shadow probing allows intermediate verification to run in parallel with primary trajectory interaction. By retaining terminal outcome supervision without requiring an additional reward model or LLM evaluator, SWE-MILE provides a practical approach to obtaining fine-grained process supervision from SWE workflow runtime.

AI use statement

We used generative AI tools to assist with parts of the software implementation, environment setup, and statistical analysis. AI tools were also used to polish the language and correct grammar in text drafted by the authors. The research idea, method, and experimental plan were developed by the authors without AI assistance. The authors reviewed all AI-assisted work and take full responsibility for the paper’s code, analyses, claims, and text.

SWE Benchmarks and Scalable Verifiable Environments

Recent research on coding agents has shifted from single-turn function-level code generation toward multi-turn repository-level issue resolution and even more challenging whole-repository generation for SWE agents. Meanwhile, the construction of SWE agent datasets and benchmarks has evolved from static, manually curated evaluation sets toward scalable executable and verifiable training environments and automated data-generation pipelines, while gradually expanding from Python-centric ecosystems to multilingual software ecosystems. SWE-Gym first constructs real GitHub issues into repository-level training environments with executable runtimes and test-based verification, providing verifiable execution feedback for SWE agent post-training; R2E-Gym further scales executable environments through procedural task generation and automated test generation; SWE-smith automatically synthesizes software bugs in real codebases, scaling training tasks to tens of thousands. More recently, SWE-rebench V2 extends automated environment construction to 20 programming languages and thousands of repositories, while SWE-Universe further demonstrates the feasibility of scaling real-world, verifiable multilingual SWE environments to the million scale. DeNovoSWE further extends scalable training environments to whole-repository generation tasks, providing large-scale training data for generating complete code repositories from natural-language specifications.

SWE Agent Scaffolds and Environment Interaction

Improvements in SWE agent capabilities have also benefited from the development of a series of agent scaffolds, which support long-horizon SWE task solving through structured tool use and environment interaction. Prior work has explored different agent-computer interfaces. SWE-agent designs specialized interfaces for operations such as repository search, file viewing, code editing, and test execution; AutoCodeRover combines program structure with fault-localization information and provides structured retrieval interfaces over classes, methods, and code snippets to facilitate code localization. OpenHands further develops a composable and extensible platform to support SWE agents with rich tool-use capabilities. RepairAgent designs specialized tools for program repair and uses a finite-state machine to constrain the set of tools available at different stages. In contrast, mini-SWE-agent provides the model with only a general-purpose Bash interface, allowing it to compose shell commands for repository navigation, editing, and execution. Along a relatively independent design dimension, Agentless replaces open-ended agent–environment interaction with a predefined “localization–repair–validation” pipeline, showing that structured workflow decomposition can likewise achieve competitive performance.

Credit Assignment for Long-Horizon SWE Agent Reinforcement Learning

Reinforcement learning for long-horizon SWE agents typically uses the execution outcome of the final patch as a trajectory-level reward, making it difficult to identify effective steps in failed trajectories and redundant behaviors in successful ones. VeRPO, targeting function-level code generation tasks, converts per-test-case pass outcomes into dense verifiable rewards and mitigates cardinality bias through difficulty and density calibration. P2T uses a reference patch to reverse distill a process graph consisting of contextual facts and key repair progress, and employs multiple external LLM evaluators to offline filter candidate trajectories, thereby constructing privileged process-supervised SFT data. SWE-Shepherd trains an action-level process reward model (PRM) using heuristic labels based on file access, code modifications, test feedback, and repetitive behavior, and uses the PRM to score candidate actions at inference time. SWE-TRACE employs a Rubric Agent to generate issue-specific rubrics and external LLM judges to construct preference supervision for training a rubric-conditioned PRM, then combines its scores with terminal execution rewards for GRPO. Rubric-based GRM directly uses Seed1.6 to evaluate candidate actions or trajectory segments based on human-written rubrics, the gold patch, and interaction history, and filters successful trajectories for RFT. G-RA introduces rule-based immediate rewards for tool-call formatting and selection preferences when the terminal reward exceeds a threshold, mitigating policy degradation caused by reward misalignment, but does not characterize actual progress in repository state. CodePilot, from a test-time search perspective, organizes partial patches as MCTS states and backpropagates values along the search tree based on execution signals such as syntactic validity, patch applicability, and test pass rate. More generally, GraphGPO aggregates multiple rollouts into a unified state-transition graph and assigns edge-level credit according to how much a transition reduces the graph distance to a successful state.

Main Setting

Dynamic Sampling. During training, we adopt an outcome-driven asymmetric dynamic sampling strategy to improve data utilization. Specifically, we generate a group of rollouts for each task and filter task groups according to verifier outcomes before advantage computation. For issue resolution, if all trajectories in a group receive terminal rewards of either 0 or 1, the group lacks an outcome-level comparison signal and the task is filtered and returned to the sampling pool. For whole-repository generation, the same filtering is applied if all trajectories have the same number of passed verifier tests, or if their test pass rates are all close to either full or zero. Filtered tasks are resampled for a limited number of attempts, with easy tasks stopping earlier and difficult tasks receiving more retry opportunities. For example, easy tasks receive only one sampling attempt, while difficult tasks receive two. The remaining task groups are used to form the training batch, while asynchronous sampling continuously adds candidate tasks until the required batch size is reached. This strategy makes difficult tasks more likely to be resampled by an updated policy at middle and later training steps, giving them more opportunities to produce successful trajectories as the policy improves.

Baseline Implementation

G-RA We replace the group-normalized advantage estimation in G-RA with RLOO-style advantage estimation to align it with SWE-MILE, thereby isolating the process reward design as the primary variable. Since G-RA does not provide open-source code, we implement the method according to the design described in its paper.

SWE-TRACE The training of the rubric generator and trajectory judge in SWE-TRACE essentially distills MiniMax M2.5. Since our experiments focus on comparing rubric-based reward methods with SWE-MILE, we directly use an open-source model stronger than MiniMax M2.5 (namely Qwen3.8-27B ) as the rubric generator and trajectory judge, rather than training them separately. In addition, SWE-TRACE does not provide accessible open-source code, so we implement the method following the procedure described in its paper.

Codeflow Scaffold

Search and Read Attribution. For dedicated tools, attribution is based on the observation ultimately presented to the model after successful execution. Matching paths and snippets returned by search are treated as search exposure, while file contents or diff hunks returned by read_file are treated as content exposure. Outputs containing only file paths or status are not considered actual content inspection. For Bash, Codeflow uses lexical tokenization based on shlex and command rules to identify search and read operations, and applies Python AST analysis to inline Python code. It then performs file-level attribution by combining the model visible stdout, parsed target paths, and a trusted repository file inventory. Only high-confidence evidence is used to update navigation potential. Path exposure and content exposure are distinguished during updates, and the maximum potential attained by each relevant file is retained, so repeated exposure does not further increase the potential.

Edit Attribution. Codeflow compares repository snapshot fingerprints before and after tool execution and records the changed files, attributing actual repository state changes to the current action. This allows file changes caused by Bash to be identified without relying on explicit editing syntax in the command. Both tool configurations prohibit modifications to protected test files or changes to Git HEAD to preserve consistency between the evaluation basis and the initial code version. Violating actions are rejected and reverted and penalized through the format reward.

Replay Fidelity of SWE Environments

A practical property that makes asynchronous shadow probing particularly suitable for SWE agents is the high replay fidelity of SWE environments. Unlike web or GUI environments, where state transitions may be affected by transient interface elements, remote services, or other external events, SWE interactions primarily modify repository and execution states inside controlled sandboxes. Given the same initial repository state, environment configuration, and sequence of repository-changing actions, intermediate repository states can therefore typically be reconstructed with high fidelity. This enables SWE-MILE to decouple verification from the primary rollout: repository-changing actions can be replayed asynchronously in a shadow sandbox, where the verifier evaluates the reconstructed intermediate states without blocking agent interaction. More generally, the effectiveness of asynchronous shadow probing depends on the reproducibility of environment transitions, making it particularly well suited to sandboxed SWE environments, while its direct extension to more stochastic agent environments may require explicit state snapshotting, replay validation, or mechanisms for handling environmental divergence.

Issue Resolution Prompt

For issue resolution, the user prompt supplies the repository root and the natural-language issue description of the task instance, and instructs the agent to inspect and update the repository with the Codeflow tools, verify the result with relevant tests, and submit the final repository state. The issue description is used verbatim as materialized by the dataset, without adding fault localization hints, reproduction scripts, or references to the ground-truth patch or the hidden tests.

Whole-Repository Generation Prompt

For whole-repository generation, the user prompt supplies the workspace root and the package specification, and asks the agent to create or complete the repository files required by the specified interfaces and behavior. Compared with issue resolution, the instruction emphasizes constructing functionality from the specification rather than locating and repairing a defect, which is consistent with the longer horizon and the larger number of repository-changing actions observed in this task family.