TL;DR
When AI agents write code to control robots, a 100% pass rate on test scenes can create a false sense of security—some programs glide to victory while others barely beat the buzzer. MARGIN looks past binary pass/fail scores by measuring how much time is left on the clock during successful runs, using these "near-misses" to turn fragile robot code into fast, resilient policies that hold up in the wild.
What Problem Does This Paper Address?
Imagine two students who both ace a timed exam. One finishes with forty minutes to spare; the other scribbles the final answer as the bell rings. On paper, their scores are identical, yet one is clearly far better prepared for a slightly harder test.
Today’s LLM-powered robot-programming agents—systems that write, test, and debug manipulation code—run into this exact blind spot. By repeatedly testing code in simulation, agents have gotten remarkably good at hitting 100% success on their development scenes. The authors call this success saturation. Once a program passes every test, binary pass/fail feedback goes flat: the agent thinks its job is done. Yet when deployed on unseen scene layouts, many of these "perfect" programs fail. Clunky motion detours, fumbled grasps, and repeated retries eat up the step budget until a minor change pushes the robot past the time limit. How can an agent keep improving its code when it’s already scoring 100%?
Methods
Built on top of a standard LLM debugging loop (specifically, ASPIRE powered by Claude Opus 5.5), MARGIN introduces a decision layer that extracts continuous risk signals from already-recorded rollouts without running extra trials:
- Near-miss margin ($m$): For a program that passes all development tests, MARGIN looks at its slowest successful run and calculates the fraction of the step budget remaining (e.g., finishing at step 990 out of 1,000 yields a razor-thin margin of $0.010$). Taking the minimum across scenes spotlights worst-case bottlenecks rather than letting easy runs average them away.
- Margin-aware repair & constrained acceptance: Once a task hits 100% dev success, if its margin falls below a risk threshold, the coding agent is tasked with streamlining the code—consolidating motion segments, cutting redundant waypoints, or simplifying wrist rotations. A revision is accepted only if it maintains 100% dev success while boosting the worst-case margin by at least 20 steps ($\delta = 0.02$).
- Safe racing (pre-saturation): Before a program reaches 100%, evaluating bad candidates across all test seeds wastes compute. Safe racing tracks the mathematical upper bound of a candidate’s score and aborts evaluation the moment it becomes impossible to beat the current champion—saving over half the simulation budget with zero change in which programs win.
- Trace-guided execution probes: Faster code can accidentally introduce subtle bugs. MARGIN monitors physical trace shifts (like gripper height or aperture changes) and, if an alarm triggers, runs a tie-breaker against the old code on 20 separate diagnostic scenes to catch hidden regressions.
Datasets
No new benchmarks were introduced; instead, MARGIN was evaluated across three established robotic manipulation simulation suites (177 tasks total, using seeded initial states with a 1,000-step horizon):
- LIBERO-Pro (80 tasks): Tests object, spatial, goal, and multi-step manipulation under challenging position and task perturbations.
- LIBERO-90 (90 tasks): A broad suite of diverse everyday tabletop manipulation tasks.
- Robosuite (7 tasks): Covers distinct skills including spill wiping, assembly, stacking, and two-armed manipulation.
Key Insights and Ideas
- Worst-case timing is a free crystal ball: You don't need failures to spot fragile robot code. Simply checking how close a "perfect" program came to timing out on its hardest dev scene strongly predicts whether it will break on unseen layouts—concentrating nearly 3× to 8× the failure risk in low-margin programs.
- Efficiency repairs unlock reliability: Asking the LLM to shave off control steps doesn't just make the robot faster; it fixes underlying physical clumsiness. Recoveries on unseen scenes largely came from eliminating near-timeout loops and preventing the robot from ending an episode with an object still stuck in its gripper.
- Physics beats vision critics for catching regressions: When screening refactored code for hidden bugs, running actual paired simulation rollouts triggered by low-level trace alarms reliably caught regressions, whereas asking a Vision-Language Model (VLM) to judge keyframes offered much weaker protection.
Key Results
- Predicting unseen failures: On dev-perfect LIBERO-Pro programs, the near-miss margin predicted fresh-seed failures with 0.774 AUC (and 0.697 AUC on LIBERO-90). Low-margin programs ($m < 0.25$) made up just 21% of tasks on LIBERO-Pro but accounted for 44% of fresh-seed failures (2.97× higher risk).
- Faster, cleaner execution: Across two refinement rounds, MARGIN cut mean unseen-scene control steps by 10.7% and 15.0% on LIBERO-Pro, 18.0% on LIBERO-90, and 18.4–20.0% on Robosuite, while nudging held-out success rates up to 99.6% on both LIBERO-90 and Robosuite. High-step timeout failures on LIBERO-Pro dropped from 3.3% to 0.8%.
- Cheaper evaluation: Exact safe racing slashed candidate-evaluation episodes by 53.5% on LIBERO-Pro (57.2% on LIBERO-90; 57.1% on Robosuite) while selecting the exact same winning programs. Refining a task cost $4.40–$6.00 in LLM API spend.
Limitations and Future Work
While the paper does not feature a dedicated limitations section, a clear boundary is built into the metric itself: MARGIN’s risk signal relies purely on temporal headroom (steps remaining). A program that completes a task briskly—say, with 50% of its step budget left—while scraping perilously close to an obstacle or holding a mug by a fingertip looks completely safe to a step counter. Furthermore, all experiments take place in deterministic simulators where paired seeds can be cleanly replayed. To address the metric's blind spots, the authors point toward developing richer, interaction-aware margins—signals that capture physical and contact-level safety alongside execution time.
Summary updated