Research
RAPID: Robot Agentic Programming from Demonstrations
Coding agents are good at iteratively writing, testing and fixing programs, but applying that loop to robots normally requires ingredients that are usually handed to the agent in advance: a testable…

- arXiv
- 2609.30249 · Preprint · not peer-reviewed
- Published
- 2026-09-24
- Authors
- Yuyao Liu, Jiayuan Mao, David Hsu, Leslie Pack Kaelbling, Tomás Lozano-Pérez
In plain words
Coding agents are good at iteratively writing, testing and fixing programs, but applying that loop to robots normally requires ingredients that are usually handed to the agent in advance: a testable definition of task success, a library of manipulation primitives, and a resettable simulated environment for checking programs.
AI summary
Overview
Research area: Robotics — robot manipulation, learning from demonstration, and LLM-based coding agents for robot programming.
Technical level: Advanced. The paper combines agentic code generation, object-centric program representations, contact-rich trajectory optimization, and real-to-sim scene reconstruction; readers benefit from familiarity with manipulation primitives and trajectory optimization.
Scope: RAPID turns a single visual human demonstration plus a language instruction into a reusable, verified robot manipulation program by closing an agentic generate–execute–verify–revise loop entirely from that demonstration.
What This Paper Is About
Coding agents are good at iteratively writing, testing and fixing programs, but applying that loop to robots normally requires ingredients that are usually handed to the agent in advance: a testable definition of task success, a library of manipulation primitives, and a resettable simulated environment for checking programs. This paper asks whether those ingredients can instead be derived from one visual human demonstration. RAPID segments the demonstration, reconstructs an interactive simulation from it, infers per-phase goals and success predicates, has a coding agent write and refine trajectory-optimization primitives, and then composes those primitives into a task-level strategy that transfers to new scenes.
Key Contributions
-
A framework that closes the agentic coding loop from demonstration alone. RAPID infers the task specification, constructs the manipulation primitives, and reconstructs the verification environment from a single visual human demonstration plus a language description, rather than assuming any of them are provided a priori.
-
An object-centric relational program representation. Primitives are written as local trajectory-optimization programs that achieve object-level effects (e.g., push by a displacement, flip by an angle), parameterized by semantic roles, relations, and an effect parameter; strategies compose primitives through connecting constraints that compute each phase's effect argument from the state reached by the previous phase.
-
Demonstration-derived verification with synthesized scene variants. RAPID reconstructs a MuJoCo environment from the demonstration's first RGB-D frame using a VLM for labeling and physical properties, SAM 3 for masks, SAM 3D for meshes, and FoundationPose for registration; the coding agent then writes filters that keep only physically feasible, task-consistent variants for verifying primitives and strategies.
-
Empirical validation on contact-rich nonprehensile manipulation and on LIBERO-Pro, plus real-robot deployment. Eight contact-rich multi-step tasks in simulation with 50 novel test scenes each, LIBERO-Pro prehensile tasks, and deployment on a real Franka arm across all eight nonprehensile tasks.
Main Findings
-
RAPID substantially outperforms code-as-policy baselines in simulation. Averaged over the eight nonprehensile tasks, RAPID reaches 0.759 ± 0.024 success, versus 0.532 ± 0.071 for RAPID without scene variants, 0.146 ± 0.025 for CaP-Agent0, 0.126 ± 0.043 for CaP-Agent0 + SV, 0.013 ± 0.003 for CaP, and 0.011 ± 0.002 for CaP + OReP.
-
Per-task spread is large and task-dependent. RAPID scores 0.933 ± 0.057 (Task 1), 0.847 ± 0.025 (Task 2), 0.700 ± 0.033 (Task 3), 0.787 ± 0.082 (Task 4), 0.793 ± 0.009 (Task 5), 0.587 ± 0.050 (Task 6), 0.807 ± 0.203 (Task 7), and 0.620 ± 0.028 (Task 8).
-
The representation alone is not enough; the closed loop is essential. Adding the object-centric relational representation to open-loop CaP (CaP + OReP) does not improve over CaP (0.011 versus 0.013 average), which the authors attribute to the absence of simulation-based verification.
-
The agentic baselines were given more help than RAPID and still underperformed. CaP-Agent0 received ground-truth success signals, environment states and visual observations during construction, and could run and revise rollouts in each test scene at evaluation time, yet averaged 0.146 ± 0.025. The authors attribute the gap to those policies relying on fixed world-frame offsets and predetermined timing, whereas RAPID computes geometry-dependent subgoals from the post-phase state.
-
Scene-variant generation matters for contact-rich tasks. Removing it (RAPID w/o SV) drops the average to 0.532 ± 0.071 and increases variance; the paper notes the drop is substantial except for Tasks 1 and 2. Adding scene variants to CaP-Agent0 did not help it (0.126 versus 0.146), which the authors read as evidence that variant-based verification needs the relational representation to pay off.
-
Strong results on prehensile tasks in LIBERO-Pro. RAPID scores libero-object Pos. 1 / Task. 0.95, libero-goal Pos. 0.67 / Task. 0.53, and libero-spatial Pos. 0.83 / Task. 0.81, versus ASPIRE at 0.98 / 0.95, 0.81 / 0.45, and 0.51 / 0.60, and CaP-Agent0 at 0.22 / 0.18, 0.26 / 0.17, and 0.12 / 0.14; OpenVLA and π₀ are reported at 0 throughout, and π₀.₅ at 0.17 / 0.01, 0.38 / 0, and 0.20 / 0.01. RAPID is best on five of the six task settings and second behind ASPIRE on LIBERO-Goal (Pos.).
-
The LIBERO-Pro comparison was deliberately unfavorable to RAPID. RAPID received no demonstrations there, only the task description and a single debug scene, while ASPIRE uses 15 debug scenes per task and the CaP baselines are given predefined grasping, placing and transporting primitives that RAPID had to discover itself. The one loss, on LIBERO-Goal (Pos.), is attributed to articulated-object primitives such as drawer opening being less robust to spatial variation when learned from only one debug scene.
-
Real-robot deployment succeeded. The paper reports deploying RAPID on a real Franka arm and evaluating on all eight nonprehensile tasks; numeric real-world success rates are not reported in the available text.
-
Cost profile. Program construction takes on the order of tens of minutes per task, incurred once; at deployment, semantic role binding takes only a few seconds per scene while the strategy and primitives stay frozen.
Methodology in Plain English
The input is one human video demonstration plus a sentence describing the task. The system first splits the demonstration into ordered phases and writes a short description of each. For each phase it reconstructs a small simulation of the scene from the demonstration's first RGB-D frame: a vision-language model names the objects and guesses physical properties, segmentation and 3D reconstruction produce meshes, and pose registration places them into MuJoCo alongside a robot model.
For each phase, a coding agent (Codex powered by GPT-5.6 Sol with high reasoning effort) infers what the phase is supposed to achieve and an executable success test, then writes a primitive. Crucially, a primitive is not a recorded trajectory or a learned policy — it is a small optimization program with a declared set of semantic roles, relations those roles must satisfy, an effect parameter (like a flip angle), code that resolves scene-specific geometry at run time (where the support plane is, where the fixture's vertical face is, what the object's dimensions are), and a cost that rewards reaching the intended effect while following contact-rich heuristics. The motion itself is found by cross-entropy method optimization in simulation, which avoids differentiating through contact.
To avoid overfitting to the one demonstrated scene, the system randomizes object appearance, size, pose, mass, friction and elasticity to make variants, and has the agent write a filter that throws out variants that are physically infeasible or inconsistent with the task. The agent repeatedly executes the primitive across the demonstration scene and the surviving variants, diagnoses failures, and rewrites the code until every case passes, then freezes the primitive.
The same generate–execute–verify–revise loop then runs at the task level: the agent writes a strategy that names the phase sequence, maps strategy roles onto each primitive's roles, and writes connecting constraints that compute each phase's effect argument from the state left by the previous phase. Failures here cause the composition to be revised while the primitives stay fixed. At deployment on a new scene, only a lightweight semantic binding is generated to assign real objects to the strategy's roles; the program text is unchanged and generalization comes from the relational representation plus re-solving trajectory optimization for the new geometry.
Why This Matters
Impact on research. The paper reframes demonstration as a programming interface rather than a policy-training signal: a single demonstration can supply the specification, the primitives, and the verification environment that agentic coding otherwise needs to be handed. It also argues that nonprehensile manipulation — pushing, pivoting, toppling, flipping, sliding — is a good stress test for coding agents precisely because no compact fixed primitive library covers it, and it shows that a relational program representation, not the agent loop alone, is what buys generalization.
Real-world applications:
-
Warehouse and logistics picking, where objects arrive in poses and geometries that a parallel gripper cannot grasp directly and must first be pushed, flipped or pivoted into a graspable configuration.
-
Household and service robots that need to retrieve items from cluttered shelves, corridors and fixtures using contact with the environment rather than a clean top-down grasp.
-
Manufacturing and assembly cells where a single expert demonstration could be turned into a reusable, re-verified motion program for a new part variant.
-
Flexible automation for small-batch production, where re-programming cost rather than hardware cost is the barrier.
Industry relevance. The approach targets the expensive part of robot deployment: engineering primitives, success detectors, and resettable test environments. The paper's cost profile is directly relevant to practitioners — tens of minutes of one-time construction per task, then seconds per new scene — and its explicit comparison against systems that are handed ground-truth rewards, human-engineered primitives and resettable environments shows what is achievable when those crutches are removed.
Future Directions
-
Primitives learned from too little evidence. The single loss on LIBERO-Goal (Pos.) is attributed to primitives like drawer opening, learned from one debug scene, being fragile under spatial variation. Discovering articulated-object primitives from richer or iteratively collected evidence is the obvious next step.
-
Robustness of the reconstruction and inference pipeline. Success depends on a VLM labeling objects and guessing physical properties, SAM 3 / SAM 3D meshes, and FoundationPose registration; how errors in any of these propagate into primitive verification is an open question.
-
Where the verification set comes from and how good the filters are. Feasible scene variants and agent-written filters are the main driver of the ablation gap; understanding how well sampled variants cover real deployment distributions, and whether filters can be too permissive or too strict, remains open.
-
Reducing the one-time construction cost and broadening the task class. Construction takes on the order of tens of minutes per task; shortening that, and extending the framework beyond quasi-static rigid-body manipulation (the scope the paper states) to deformable objects or dynamics-dominated tasks, are natural extensions.
Target Audience
Robotics researchers working on manipulation, learning from demonstration, and LLM-based coding agents for robot control; engineers building robot programming pipelines who want to eliminate hand-engineered primitives and reward functions; and graduate students interested in how agentic code generation, trajectory optimization, and object-centric representations can be combined into a single system. Readers without background in manipulation or trajectory optimization will find the system-level ideas accessible but the technical details dense.
Authors’ abstract
Coding agents have demonstrated enormous success in solving complex programming problems. To leverage their potential for robot systems, this work introduces Robot Agentic Programming from Demonstrations (RAPID), which automatically generates, verifies, and refines robot programs, given a single visual human demonstration. The iterative agentic loop of code refinement requires several key ingredients: (i) a testable task specification, (ii) action primitives for robot…
The full abstract on arXivRelated papers
- Energy-Based Policy Orchestration 2026-11-02 · cs.RO · Also by Leslie Pack Kaelbling, Tomás Lozano-Pérez
- FEIJOA: Task-Driven Grounding and Execution for Mobile Manipulation 2026-11-02 · cs.RO · Also by Leslie Pack Kaelbling, Tomás Lozano-Pérez
- Generalized Inverse Kinematics via Conditional Flow 2026-11-11 · cs.RO · Also by Leslie Pack Kaelbling, Tomás Lozano-Pérez
- Visibility-Aware Task and Motion Planning with Task-Centric Perception 2026-11-12 · cs.RO · Also by Leslie Pack Kaelbling, Tomás Lozano-Pérez
- Where Should I Join? Robot Group Joining via Language-Guided Goal Prediction 2026-09-23 · cs.RO · Also by David Hsu