MURPHY: Feedback-Aware GRPO with Retrospective Credit Assignment for Multi-Turn Code Generation

Chanakya Ekbote, Vijay Lingam, sujay sanghavi, Jun Huan, Behrooz Omidvar Tehrani, Anoop Deoras, Stefano SoattoNeurIPS 2026

TL;DR

When humans write code, a compiler error or a failing unit test isn't a dead end—it's a clue. Standard reinforcement learning recipes for LLMs treat every failed first draft as uniformly bad, missing out on how models actually debug in the wild. MURPHY extends the popular GRPO training algorithm into multi-turn territory, rewarding earlier "good failures" when they trigger informative feedback that leads to a working fix later on.

What Problem Does This Paper Address?

Post-training LLMs with Group Relative Policy Optimization (GRPO)—an efficient reinforcement learning method that skips training a separate critic model by comparing groups of responses against each other—has become the gold standard for reasoning tasks. However, GRPO is inherently single-turn: prompt goes in, code comes out, unit tests score it, done.

Real-world coding agents work in loops: write code, run tests, read stack traces, and refine. While inference-time frameworks (like Reflexion) let models self-correct at test time, they don't update the model's weights to actually get better at using feedback. Prior attempts to train models on execution feedback required heavy extra machinery like separate PPO critics, learned verifiers, or synthetic test generators. And if you naively stretch GRPO across multiple turns by broadcasting a final pass/fail score to every step in a trajectory, credit assignment gets blurry—the model can't tell whether an intermediate failure exposed a crucial edge case or just wasted a turn.

Methods

MURPHY keeps GRPO’s lightweight, critic-free architecture intact while introducing three structural upgrades:

  1. Feedback-Conditioned Rollout Trees: Given a coding prompt, the model samples a group of candidate programs and executes them. Passing solutions terminate immediately. Failing solutions are bundled with their error messages or failing test outputs to form new prompts, branching out into child groups of refinements in the next turn.
Figure 2: Overview of MURPHY. Given an input prompt q(1), the model samples multiple candidate solutions. Each output is executed to obtain a scalar reward r and executor feedback f. Solved outputs terminate, while failed outputs are converted into feedback-conditioned prompts by concatenating the original prompt, the failed output, and its feedback. The model then samples refinements for each failed output. After the rollout tree is generated, rewards from later turns are propagated backward through a credit-assignment rule ρ(·), allowing successful refinements to credit earlier failed attempts that produced useful feedback.
  1. Retrospective Credit Assignment: Once the tree is built, rewards flow backward from the leaves to the root before running standard local GRPO updates at each node. A failed first attempt earns positive credit if its error message helped a child node solve the problem. The authors test two backup rules: MARS (Max Reward), which optimistically passes up the best score achieved by any descendant, and MERS (Mean Reward), which passes up a discounted average of child scores.
  2. Post-Rollout Pruning: Because trees grow exponentially with each turn, computing gradients over every branch gets expensive. After generating the tree, MURPHY prunes uninformative branches before propagating rewards. INTRAP keeps high-variance individual trajectories within each group, while INTERP keeps entire refinement groups that show high internal reward diversity (mixing passes and fails).

Datasets

No new benchmarks are introduced; the authors rely on established datasets chosen to minimize data contamination:

  • Training: Models are fine-tuned on a 1,000-sample subset randomly drawn from KodCode, selected specifically for its minimal overlap with standard coding evaluations.
  • Evaluation: Models are tested on HumanEval, MBPP, and the contamination-resistant LiveCodeBench-v6 (stratified into Easy, Medium, and Hard subsets).

Key Insights and Ideas

  • Not all bugs are created equal: Treating a broken script that surfaces a crisp IndexError the same as gibberish leaves learning signal on the table. Retrospective credit assignment teaches the model how to fail productively and pivot from execution traces.
  • Optimism wins in code: MARS consistently beats MERS—by over 10 percentage points on HumanEval with OLMo-2-7B. In code generation, rewards are sparse; averaging across children dilutes the signal of a rare breakthrough fix, whereas taking the max lets that single working refinement light up the path that led to it.
  • Prune whole groups, not just individual samples: When cutting down compute, INTERP preserves multi-turn self-correction much better than INTRAP. Why? Because GRPO learns from contrast within a group. If every child in a refinement group fails (or every child passes), variance is near zero and there's nothing to learn. Keeping mixed-outcome groups concentrates gradient updates where the preference signal is sharpest.

Key Results

Evaluated across two model families (OLMo-2-7B-Instruct and Qwen3-1.7B/4B), MURPHY consistently outperforms multi-turn GRPO baselines and specialized execution-feedback methods ($\mu$Code and ReVeal):

  • HumanEval & MBPP: At 3 self-correction turns (Iter-3), MURPHY boosts pass@1 by up to +6.20 percentage points (pp) on HumanEval and +6.07 pp on MBPP over the strongest baselines, with the largest leaps appearing on the weaker OLMo-2-7B base model.
  • LiveCodeBench-v6: Using Qwen3-4B, MURPHY shines brightest where single-shot generation struggles, beating baselines by +4.38 pp on Medium and +4.20 pp on Hard problems at 5 turns—while requiring roughly half the training time of ReVeal (~11 hours vs. ~23 hours on 8$\times$H100s).
Figure 1: Self-correction performance on LiveCodeBench-v6. Qwen3-4B with MURPHY vs. four execution-feedback baselines (Base, GRPO-MT, µCODE, REVEAL) on the Easy, Medium, and Hard subsets. Base, GRPO-MT, µCODE, and MURPHY are evaluated under the Reflexion framework [21]; REVEAL is evaluated using its official generation-verification scaffold, which uses a method-specific prompt and parser. All methods are compared at 1, 3, and 5 inference turns. Bars show the mean and stdev across 3 runs. MURPHYshows large gains on the Medium/Hard subset (+4.38/+4.20 at Iter-5), where self-correction matters more.
  • Compute Efficiency: Applying INTERP cuts retained trajectories nearly in half (from 72 to 40 per prompt), slashing gradient optimization time by 74.1% and overall step time by 21.4%, while staying within 0.4–0.8 pp of unpruned MURPHY's accuracy.

Limitations and Future Work

Multi-turn tree expansion inevitably costs more time and memory than standard single-turn GRPO. While INTERP slashes the backward-pass optimization cost, it happens after rollouts finish, meaning code generation and execution bottlenecks remain untouched. Future engineering could exploit shared prompt prefixes between parent and child nodes via vLLM prefix caching and KV-cache reuse. Additionally, unit tests provide unusually crisp, deterministic feedback; extending MURPHY to noisier, open-ended agentic environments, longer refinement horizons, and adaptive turn budgets remains open territory.

Summary updated

Abstract

Reinforcement Learning with Verifiable Rewards (RLVR) has become a standard recipe for post-training LLMs on reasoning tasks, with Group Relative Policy Optimization (GRPO) emerging as a leading approach. However, GRPO and its variants are inherently single-turn: they optimize terminal rewards on isolated prompt-response pairs, leaving them poorly suited to agentic settings where models iteratively refine solutions using environmental feedback. We introduce MURPHY, a multi-turn extension of GRPO for self-correcting code generation. MURPHY constructs feedback-conditioned rollout trees in which failed candidate solutions are paired with executor feedback and expanded into subsequent turns. It then propagates rewards backward through the tree so that later successful refinements credit earlier attempts that surfaced informative feedback. We study two propagation strategies, Max Reward (MaRS) and Mean Reward (MeRS), and introduce post-rollout pruning mechanisms that reduce multi-turn optimization cost. Across three code generation benchmarks, HumanEval, MBPP, and LiveCodeBench-v6, and two model families, Qwen3-1.7B/4B and OLMo-2-7B, MURPHY delivers up to **6%** absolute pass@1 gains over the strongest prior multi-turn execution-feedback methods. Gains are largest on the Medium/Hard LiveCodeBench subsets, reaching **+4.38%/+4.20%** at Iter-5, where iterative self-correction matters most.
BibTeX
@inproceedings{ekbote2026murphy,
  author = {Chanakya Ekbote and Vijay Lingam and sujay sanghavi and Jun Huan and Behrooz Omidvar Tehrani and Anoop Deoras and Stefano Soatto},
  title = {{MURPHY: Feedback-Aware GRPO with Retrospective Credit Assignment for Multi-Turn Code Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=Ym3Smk7mfy},
}
Figure