FC-SWE: Failure-Conditioned RL for Long-Horizon Software Engineering Agents

Jia Liufu, Bin Hu, Linglin Jing, Terry Kong, Yuki Huang, Ashwath Aithal, Wenming Yang, Jun Yang

NVIDIA · Tsinghua University

Published October 6, 2026 · on the feed October 19, 2026 · ▲ 9 · arXiv 2610.07898

Code & softwareAgentsLLM training & RL No code arXiv ↗Hugging Face ↗

The abstract

Repository-level software engineering (SWE) is a challenging long-horizon setting: agents must reason over extended interactions, use tools, and adapt to stateful environments. Recent work trains SWE agents with reinforcement learning methods such as Group Relative Policy Optimization (GRPO), which independently sample multiple trajectories per issue, test the resulting patches, and compare terminal rewards within a fixed group. However, this training setup does not reuse verifier feedback from failed patches as context for subsequent attempts, even though this feedback contains valuable diagnostic information about what went wrong. Training on recovery trajectories is challenging because the preceding outcome determines whether the next trajectory is generated, while the failed execution determines its conditioning context. We introduce FC-SWE, a failure-conditioned RL framework that incorporates recovery attempts into policy training. After a patch fails verification, FC-SWE restores the repository to its original task state and uses the failed patch and verifier feedback as context for a recovery trajectory. FC-SWE adapts GRPO to these chains of complete, multi-turn tool-use trajectories through two mechanisms. Trajectory-local rewards preserve each attempt's verifier outcome, preventing recovery success from rewarding an earlier failed patch. Active-set advantage estimation forms a comparison group from all initial and recovery trajectories actually executed for the same issue, so failed attempts remain in the group while unexecuted attempts are excluded. On all 500 SWE-bench Verified tasks under a verifier-assisted protocol, FC-SWE with Qwen3.5-4B and SWE-agent achieves 41.7% Resolved@1 and 52.8% Resolved@2, compared with 38.9% and 48.5% for GRPO. Although trained with at most two attempts per chain, FC-SWE reaches 70.7% Resolved@11 under an eleven-attempt test-time budget.

The Brief

3:17

A short podcast summary of the paper. Written and voiced by AI.

Transcript

FC-SWE. Failure-Conditioned RL for Long-Horizon Software Engineering Agents. By Jia Liufu and seven others, from NVIDIA and Tsinghua University. Published on the sixth of October. No code repository is linked to it.

Software engineering at the level of a whole repository is a long-horizon setting. An agent has to reason across extended interactions, use tools, and adapt to an environment that keeps state. Recent work trains such agents with reinforcement learning methods like Group Relative Policy Optimization, or GRPO. For each issue, GRPO samples several trajectories independently, tests the patches they produce, and compares the terminal rewards within a fixed group.

What that setup never does is reuse the verifier's feedback on a failed patch as context for another try. That feedback carries diagnostic information about what went wrong, and it is left unused. Each sample in the group starts fresh, as though the others had never happened. Training on recovery is not straightforward, though. Two things tie a recovery trajectory to what came before it. Whether it is generated at all depends on the preceding outcome, since there is nothing to recover from unless an earlier patch failed. And what it is conditioned on is set by the failed execution itself. Samples that depend on one another in this way do not fit neatly into a method built on independent draws.

FC-SWE is a failure-conditioned reinforcement learning framework that brings those recovery attempts into policy training. When a patch fails verification, FC-SWE restores the repository to its original task state, then hands the agent the failed patch and the verifier feedback as context for a recovery trajectory. The second attempt begins from a clean repository, but with a record of the first.

GRPO is adapted to these chains of complete, multi-turn tool-use trajectories through two mechanisms. The first is trajectory-local rewards. Each attempt keeps its own verifier outcome, so a successful recovery does not end up rewarding the failed patch that came before it. The second is active-set advantage estimation. The comparison group is formed from every initial and recovery trajectory actually executed for the same issue. Failed attempts stay in the group; attempts that were never executed are left out. Between them, the two mechanisms deal with the dependency the problem described: credit stays with the attempt that earned it, and the group reflects what really ran.

Evaluation covers all five hundred SWE-bench Verified tasks, under a verifier-assisted protocol, with Qwen3.5-4B and SWE-agent. FC-SWE resolves forty-one point seven percent at one attempt, against thirty-eight point nine percent for GRPO.

Allowing two attempts, it reaches fifty-two point eight percent, where GRPO reaches forty-eight point five. Training used at most two attempts per chain. Even so, given an eleven-attempt budget at test time, FC-SWE reaches seventy point seven percent resolved. In each comparison the gain holds, and it widens from the first attempt to the second.

A failed patch and its verifier report used to be the end of a sample. FC-SWE turns them into the start of the next one, and the engineering lies in keeping the reinforcement signal honest when attempts depend on each other. That the gains keep extending past the two attempts seen in training, out to eleven, is the result the authors close on.

More with an account

Listen to every day’s papers

Daily playlists, deep dives, quests for the papers, and quizzes on their key terms.

Join free
KipQuest: the day’s AI research, as podcasts and quests. All papers Android app Privacy Contact Episodes are written and voiced by AI from each paper. Summaries can contain mistakes: the paper is the source.