Rethinking Self-Repair in Code-as-Policy Agents: What Drives Retry Success?

Siddharth Aphale, Ayushman SingharXiv 2026 · arXiv

TL;DR

Self-repair in robot agents works, but not for the reasons we usually think. This paper demonstrates that the success of "retrying" a failed task is driven primarily by additional sampling and general task guidance, rather than the model understanding its specific failure. In fact, providing a fixed guided prompt from the very first attempt is often more efficient than waiting for a failure to provide feedback.

What Problem Does This Paper Address?

In the "Code-as-Policy" paradigm, large language models (LLMs) generate executable code to control robots. When these programs fail—perhaps the robot misses a grasp or drops an object—a common strategy is "self-reflection": the model reads its failed code and an execution trace, critiques itself, and tries again.

While this iterative repair often improves success rates, it’s unclear why. Is the model actually learning from its specific mistake? Or is it just benefiting from having more chances to try (resampling) and better general instructions? The authors set out to decouple these factors to see if failure-specific feedback is truly necessary for robot self-repair.

Methods

The researchers evaluated frozen Qwen2.5-Coder models (3B and 7B) in a simulated robot manipulation environment (robosuite). They used a "reset-and-retry" setup: if a program fails, the simulator resets to the exact initial state, and the model gets another shot.

They compared several feedback strategies:

  • Resample: Simply retrying with the original prompt (no feedback).
  • Compiled: A rule-based system that detects a failure (e.g., "missed grasp"), looks up a corresponding human-written template (e.g., "MUST grasp the object before lifting"), and adds it to the prompt.
  • Different-Label: Providing the model with feedback from a different type of failure than the one it actually committed.
  • Fixed Task Template: Providing a single, static piece of guidance for the task regardless of how the robot failed.
  • Static-from-Start: Including the task guidance in the very first prompt, before any failure occurs.

Crucially, they tested regeneration (writing a fresh program from scratch) versus editing (revising the failed code), a distinction often blurred in self-repair literature.

Figure 1: Template-based feedback improves recovery over resampling. (a) Reset-and-retry loop and feedback methods. (b) Recovery on 252 initial failures, with similar outcomes for Compiled, Different-Label Feedback, and Fixed Task Template.

Datasets

The study utilized simulated robot tasks including:

  • Primary Tasks: Cube lifting and stacking.
  • Generalization Tasks: Cube-to-zone, place-in-bin, nut insertion, and door opening.
  • Evaluation Set: 252 initial failures were used to test recovery, along with a larger set of 700 fresh scenes for end-to-end evaluation.

Key Insights and Ideas

  • Specificity is Overrated: Surprisingly, matching the feedback to the specific failure didn't provide a significant boost. The "Different-Label" and "Fixed Task Template" conditions performed almost identically to the "Compiled" feedback. This suggests that the model isn't "debugging" its specific error so much as it is benefiting from general reminders of good behavior.
  • Static Guidance Wins on Efficiency: If general guidance is what matters, why wait for a failure? The "Static-from-Start" approach—giving the robot the "tips" upfront—nearly doubled initial success rates (from 19.3% to 36.9%) and solved tasks using significantly fewer tokens.
  • Fresh Starts > Edits: In this domain, asking the model to edit its previous failed code was much less effective than asking it to generate a new program from scratch with better instructions.
  • Guidance Can Be a Double-Edged Sword: Guidance that helps in one task can hurt in another. For example, a template suggesting a "center grasp" (useful for cubes) actually lowered the success rate on a nut-insertion task that required a "rim grasp."

Key Results

  • Recovery Rate: The "Compiled" feedback recovered 85.3% of initial failures within five retries, significantly outperforming simple "Resample" at 68.3%.
  • Token Budget: Even when limiting the total number of tokens allowed, the advantage of providing guidance (whether specific or fixed) persisted over simple resampling.
  • Overall Success: In the end-to-end study, "Static-from-Start" reached a 92.4% overall success rate, the highest of all methods, while being the most token-efficient.
Figure 3: A fixed guided prompt improves initial success. (a) Initial and overall success on 700 fresh scenes. (b) Total model tokens per solved episode. Static-from-Start changes both the initial instruction and guidance.

Limitations and Future Work

The study was conducted in a simulated environment with privileged state information (the model knows exactly where objects are without needing to process raw pixels). The feedback was also "coarse"—based on 14 high-level failure labels rather than a detailed, nuanced understanding of the robot's trajectory.

The authors suggest that future work should:

  1. Test these findings with visual feedback and raw sensor data.
  2. Evaluate physical recovery, where the robot must try to fix a mistake from the state it ended up in, rather than resetting the scene.
  3. Investigate if larger models (like 32B+ parameters) show a greater ability to utilize specific, nuanced feedback compared to the smaller models tested here.

Summary updated

Abstract

Code-as-policy agents often use execution feedback to retry failed programs. Additional sampling and task guidance can also improve success, leaving the contribution of failure-specific feedback unclear. We study this question in simulated robot manipulation. A fixed lookup selects feedback templates using failure labels and the API variant. A frozen code model generates a fresh program after each scene reset. On the same 252 initial failures, Qwen2.5-Coder-7B recovers 85.3% within five retries, compared with 68.3% for resampling with the same retry cap. The advantage persists under fixed total-token budgets. Feedback from other episodes and fixed task guidance yield similar recovery point estimates, with no detected benefit from matching the coarse failure label. In a separate study, a fixed guided prompt used from the first attempt achieves an observed overall success rate similar to that of template-based feedback. Template-based feedback also lowers recovery on a nut-insertion task requiring a rim grasp, consistent with an incompatible center-grasp instruction. Evaluations of robot self-repair should include resampling, mismatched feedback, and concise, task-compatible static guidance as baselines.
BibTeX
@misc{aphale2026rethinking,
  author = {Siddharth Aphale and Ayushman Singh},
  title = {{Rethinking Self-Repair in Code-as-Policy Agents: What Drives Retry Success?}},
  year = {2026},
  eprint = {2611.06863},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.06863},
}
Figure