Research
Rethinking Self-Repair in Code-as-Policy Agents: What Drives Retry Success?
Controlled retries show generic task guidance matches failure-specific feedback for code-as-policy recovery, so effort spent labeling failure modes may be wasted.

- arXiv
- 2611.06863 · accepted · CORL workshop
- Published
- 2026-11-04
- Authors
- Siddharth Aphale, Ayushman Singh
In plain words
Code-as-policy agents typically respond to a failed robot program by feeding the failure back to the model and retrying. It is easy to assume that the content of that failure feedback — a diagnosis matched to what went wrong — is what produces the improvement.
AI summary
Overview
Research area: Robotics, specifically code-as-policy agents — language models that write executable robot programs — and the evaluation of iterative self-repair from execution feedback.
Technical level: Intermediate. The paper assumes familiarity with language-model code generation and robot manipulation benchmarks, but its core argument is conceptual rather than mathematical.
Scope (one sentence): The paper asks which part of a retry prompt actually drives recovery after a robot program fails, using matched-budget comparisons against resampling, mismatched feedback, and fixed task guidance in simulated manipulation.
What This Paper Is About
Code-as-policy agents typically respond to a failed robot program by feeding the failure back to the model and retrying. It is easy to assume that the content of that failure feedback — a diagnosis matched to what went wrong — is what produces the improvement. This paper tests that assumption directly: it holds the retry loop, model, task, API and retry cap fixed, and varies only what information appears in the retry prompt. The goal is to determine whether failure-specific, label-matched feedback beats simply sampling again, feeding feedback from a different failure, or giving the model one fixed piece of task guidance.
Key Contributions
-
A matched-budget comparison of feedback content against resampling. On the same 252 held-out initial failures, template-based feedback ("Compiled") recovers 85.3% within five retries versus 68.3% for resampling, and the advantage survives fixed total-token budgets (2,000, 5,000 and 9,500 tokens).
-
A label-matching control that isolates the value of failure specificity. Different-Label Feedback and a single Fixed Task Template per task both recover 86.1%, versus 85.3% for Compiled, so no benefit is detected from matching the coarse failure label to the current episode.
-
A static-guidance baseline applied from the first attempt. On 700 fresh scenes, Static-from-Start raises initial success from 19.3% to 36.9% and reaches 92.4% overall success@6 versus 89.6% for Compiled, while using the fewest total model tokens per solved episode (2,087 versus 2,578 for Compiled and 3,623 for Resample).
-
A generalization study plus a documented failure case. Across seven eligible Qwen2.5-Coder-3B/7B settings (four tasks, 354 initial failures), Compiled beats Resample by +18.1 pp, but on nut insertion — where a rim grasp is required — Compiled recovers 82.5% versus 97.5% for Resample, consistent with the template's center-grasp instruction conflicting with the task.
Main Findings
-
Feedback beats resampling, but not by being failure-specific. Compiled recovers 85.3% of 252 initial failures within five retries; Resample recovers 68.3%, a +17.1 pp difference (95% CI [+9.9, +24.2]).
-
The advantage holds under fixed token budgets. Compiled improves over Resample by +15.9 pp at 2,000 tokens and +14.7 pp at 5,000 tokens, and uses fewer total model tokens including prompts and completions.
-
Matching the failure label does not help. Different-Label Feedback scores 86.1% versus Compiled's 85.3% (−0.8 pp, 95% CI [−6.3, +4.8]); Fixed Task Template also scores 86.1% (−0.8 pp, 95% CI [−6.7, +5.2]). All 627 selected records in the Different-Label condition carried a different failure label from the observed failure. The authors state the intervals do not establish equivalence.
-
Editing the previous program performs far worse. Direct+Compiled reaches 21.4% recovery, a +63.9 pp gap relative to Compiled (95% CI [+56.7, +70.6]). Because it changes both code exposure and the generation instruction, the cause remains unresolved.
-
Model-written reflection underperforms resampling. Reflection reaches 56.0% recovery in the earlier core evaluation versus 70.6% for Resample, while using more completion tokens and wall-clock time. Reflection Repair reaches 25.0% versus 21.4% for Direct+Compiled and 89.7% for Compiled in a later evaluation.
-
A fixed guided prompt from the first attempt is competitive. Static-from-Start reaches 92.4% overall success@6 versus 89.6% for Compiled; the +2.9 pp advantage is not statistically significant after multiplicity correction (95% CI [+0.0, +5.7], Holm-adjusted p = 0.13). It changes both the initial instruction and the presence of guidance, so individual contributions are unresolved.
-
Gains generalize, with exceptions. Across seven Qwen2.5-Coder-3B/7B settings, Compiled beats Resample by +18.1 pp (95% CI [+13.3, +22.9]) and beats Other-Episode Feedback by only +2.3 pp (95% CI [−1.1, +5.6]). At temperature 0.2 on lifting with pose shift, Compiled's recovery is 19.6 pp lower than Resample's (90% CI [−28.6, −10.7]).
-
Task-incompatible guidance can hurt. On nut insertion, Compiled recovers 82.5% versus 97.5% for Resample (n = 40; −15.0 pp, 95% CI [−27.5, −2.5]), while attempt validity stays similar (85.1% versus 84.9%).
-
Large models leave little headroom. With Qwen2.5-Coder-32B, all 80 lift scenes succeed initially, and on stacking Compiled and Resample solve the same 52 of 55 remaining failures (94.5%), producing a paired interval of zero width.
-
Simpler baselines also beat resampling. DeepSeek-Coder-6.7B, which fell below the inclusion threshold, shows 50.8% for Compiled versus 41.7% for Resample (n = 120; +9.2 pp, 95% CI [−1.7, +20.0]).
Methodology in Plain English
The setup is a reset-and-retry loop in simulation. A frozen code model writes a Python program for a task and scene; if it fails, the simulator resets to the original scene and the model writes a completely fresh program, with the failed program hidden from the prompt. The episode can try up to five retries.
To study feedback content, the authors build a rule-based labeler that assigns one of 14 failure labels, then a fixed lookup maps the label plus the API variant to a canned feedback template with a diagnosis and short MUST/NEVER instructions. Because this lookup requires no model call, the feedback is fully controlled. The key move is substitution: the same retry loop can be run with matched feedback, with feedback taken from a different failure of the same task, with one fixed template per task, or with nothing at all (resampling). Keeping everything else identical turns "does the feedback match the failure?" into a measurable contrast.
Comparisons are paired on the same 252 held-out initial failures (with 40 development failures used to pick the fixed templates). Statistical analysis uses 10,000 bootstrap replicates for confidence intervals and exact McNemar tests with Holm correction. A separate end-to-end study uses 700 fresh scenes and measures overall success across six executions, and another 700 fresh scenes test the guided prompt applied from attempt 0. The generalization study pools seven Qwen2.5-Coder-3B/7B settings that met a predefined initial-success range of 10%–70%.
Why This Matters
Impact on research. Self-repair results are often reported against a weak baseline: the agent's own naive first attempt. This paper shows that on these tasks, a large share of the apparent benefit comes from reusable task guidance rather than from reading the current failure, and that a fixed prompt applied before any failure occurs can match adaptive feedback while using fewer tokens. It argues that evaluations of robot self-repair should routinely include resampling, mismatched feedback, static guidance from the first attempt, and previous-program editing as baselines, with retry and token budgets matched.
Real-world applications:
- Warehouse and pick-and-place robot fleets, where a small library of task-compatible instructions may be cheaper and safer than a feedback loop that requires extra model calls.
- Code-generating agent frameworks for robot APIs, where the choice between regenerating and editing a failed program has a large measured effect on recovery.
- Deployment triage for manipulation tasks, where guidance validated on one task family (center grasps) can actively degrade performance on another (rim grasps on a nut).
- Agent evaluation tooling, where matched-token replays reveal that an apparent improvement disappears or reverses at tighter budgets.
Industry relevance. The result that mismatched feedback and fixed templates are indistinguishable from matched feedback, combined with Static-from-Start's lower token cost per solved episode, suggests that systems reporting self-repair gains should state their baseline; otherwise, the value of the adaptive machinery is unmeasured.
Future Directions
- Separate guidance from instruction changes. Static-from-Start alters both the initial instruction and the presence of guidance, so their individual contributions remain unresolved; the same confound applies to Direct+Compiled and Reflection Repair.
- Test larger models on harder tasks or tighter budgets. Qwen2.5-Coder-32B already saturates stacking (94.5% for both methods), leaving limited room to detect differences; the paper also notes no call fit within the original 1,000-token budget.
- Move beyond privileged state and coarse labels. Extending evaluation to visual feedback, post-failure physical states, and action costs would clarify when adaptive feedback improves on static guidance.
- Audit the feedback pipeline. Failure labels were checked only on scripted faults, with no human audits of natural failures, and oracle-hint performance and template-authoring cost were not measured.
Target Audience
Researchers and engineers building or evaluating language-model agents for robot control, especially those reporting iterative self-repair or reflection results. It is also useful for practitioners choosing between program regeneration and program editing, and for benchmark designers who need matched-budget baselines for feedback-driven agents. Readers without a robotics background can follow the experimental logic, since the comparisons are conceptual rather than technical — though the appendices assume comfort with prompt construction and statistical intervals.
Authors’ 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%…
The full abstract on arXivRelated papers
- CaPtain: A Pipeline for Post-Training Code-as-Policy Robot Agents 2026-10-29 · cs.RO · Key terms of the title in common
- CodeActionBench: Evaluating Agentic Code-as-Policy for Embodied Manipulation 2026-09-27 · cs.RO · Key terms of the title in common
- AquaCap: A Training-Free Underwater Embodied Agent with Code-as-Policy 2026-09-19 · cs.RO · Key terms of the title in common
- PhysCaP: Grounding Code-as-Policy Agent with Physics-Informed Exploration 2026-08-21 · cs.RO · Key terms of the title in common
- Policy Search in Code Space for Multi-Agent Pathfinding 2026-10-19 · cs.RO · Key terms of the title in common