NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MURPHY: Multi-Turn GRPO for Self Correcting Code Generation

Chanakya Ekbote, Vijay Lingam, Behrooz Omidvar-Tehrani, Jun Huan, Sujay Sanghavi, Anoop Deoras, Stefano SoattoarXiv 2025 · DOI

Introduction

Reinforcement Learning with Verifiable Rewards (RLVR) has emerged as a powerful technique for enhancing the reasoning capabilities of Large Language Models (LLMs), as demonstrated by recent breakthroughs like DeepSeek-R1. However, most existing RL frameworks are fundamentally "single-turn": a model receives a prompt, generates a single response, and is rewarded based on its correctness. This paradigm fails to capture the iterative nature of real-world software engineering, where developers write code, interpret compiler errors or test failures, and refine their solutions.

To bridge this gap, we introduce MURPHY (Multi-turn RLVR), a novel reinforcement learning framework that extends Group Relative Policy Optimization (GRPO) to a multi-turn setting. MURPHY explicitly trains models to learn from execution feedback, enabling them to "fail up" by iteratively correcting their own mistakes.

The Methodological Gap in Single-Turn RL

Standard RL methods struggle with credit assignment in iterative tasks. If a model's first attempt fails but its third attempt—informed by feedback from the first two—succeeds, a single-turn RL approach might penalize the initial attempts as failures. This discourages the model from exploring viable, albeit initially imperfect, paths that could lead to a solution. MURPHY addresses this by treating the generation process as an agentic, multi-step journey rather than a one-shot event.

The MURPHY Framework

MURPHY transforms the flat generation process into a feedback-conditioned rollout tree. The framework consists of three core components:

1. Multi-turn Rollouts

When a model’s initial code generation fails a unit test, the resulting error message or stack trace is appended to the original prompt. The model is then prompted to generate a corrected version. This process can repeat for multiple turns, creating a tree of trajectories where each node represents a code attempt and its associated feedback.

2. Max Reward Strategy (MARS)

The primary innovation of MURPHY is its credit assignment mechanism, termed the Max Reward Strategy (MARS). Unlike traditional methods that might average the rewards across turns (Mean Reward Strategy, or MERS), MARS propagates the maximum reward achieved by any descendant node back up the tree.

If an initial "bad" attempt eventually leads to a successful solution in a subsequent turn, that initial attempt receives a high reward. This signals to the model that the first attempt was a productive starting point for correction. The authors found that MARS is significantly more effective than MERS in coding tasks, where rewards are typically binary (pass/fail). MARS prevents the dilution of the success signal, allowing rare but successful "redemption" paths to guide the learning process.

3. Efficiency through Pruning

Multi-turn training is computationally expensive, as the rollout tree can grow exponentially. MURPHY introduces two pruning strategies to maintain efficiency:

  • Intra-Group Pruning (INTRAP): This strategy discards trajectories within a group that exhibit low variance, focusing the model's updates on more diverse and informative attempts.
  • Inter-Group Pruning (INTERP): Inspired by Upper Confidence Bound (UCB) algorithms, INTERP selects only the most "informative" groups of attempts for training. This focuses computational resources on problems that are at the edge of the model's current capabilities—neither too easy nor too difficult.

Experimental Results

The authors evaluated MURPHY by fine-tuning models on 1,000 samples from the KodCode dataset, a verifiable synthetic dataset for coding. Testing was conducted across several industry-standard benchmarks, including HumanEval, MBPP, and the more complex BigCodeBench-Hard.

Performance Gains

MURPHY achieved up to an 8% absolute gain in pass@1 compared to compute-matched single-turn GRPO baselines. It also outperformed $μ$Code, a leading multi-turn method that requires more complex auxiliary components like learned verifiers. These improvements were consistent across different model families (such as Qwen3 and OLMo) and scales (from 1.7B to 7B parameters), demonstrating the framework's robustness.

Training-Inference Synergy

A key finding was that MURPHY-trained models do not just become better at writing code; they become better agents. When evaluated using various inference-time scaffolding frameworks (like LATS or DoT), MURPHY models consistently outperformed those trained with standard RL. This suggests that the ability to effectively utilize feedback is a transferable skill learned during the MURPHY training process.

Limitations and Future Outlook

While MURPHY represents a significant step forward, it faces challenges regarding computational overhead due to increased sequence lengths as feedback is accumulated. Furthermore, the current implementation relies on structured, verifiable feedback from unit tests. Generalizing MURPHY to handle "noisier" feedback, such as ambiguous human comments, remains a subject for future research.

The research team plans to explore adaptive turn selection, where the model learns to decide autonomously when it has sufficient feedback to proceed or when it should pivot to a completely different strategy. By teaching LLMs to navigate the iterative process of trial and error, MURPHY paves the way for more resilient and capable AI coding assistants.

Summary updated

BibTeX
@misc{ekbote2025murphy,
  author = {Chanakya Ekbote and Vijay Lingam and Behrooz Omidvar-Tehrani and Jun Huan and Sujay Sanghavi and Anoop Deoras and Stefano Soatto},
  title = {{MURPHY: Multi-Turn GRPO for Self Correcting Code Generation}},
  year = {2025},
  eprint = {2511.07833},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.07833},
}
Figure