Recent advances in frontier models have pushed the boundaries of agentic robot control, enabling agents to perform complex robotic tasks through reasoning and interaction. However, repeated calls to these models during execution can substantially increase task completion time. Code as Policies (CaP) offers a route for coding agents to acquire physical skills through experience and retain them in executable programs, allowing the reasoning invested in development to be reused across runs. Developing reliable code policies while limiting the cost of physical experimentation remains a central challenge. We investigate human guidance as a source of priors for feasible actions and simulation as an auxiliary environment for exploring and testing candidate policies. Our findings favor robot demonstrations available on request and simulation used selectively during real-world policy refinement. These findings inform ACE-CaP-0, an agentic recipe that couples policy revision with experience acquisition through Demonstrations on Request and Simulation on Demand. Across eight real-world manipulation tasks spanning alignment, multi-object handling, and bimanual coordination, the resulting frozen programs achieve 92.1% success (221/240 trials). Mean execution times across tasks range from 0.97 to 2.27 minutes. The programs execute with runtime perception and control, without a human or coding agent in the loop. These results highlight CaP's potential to turn experience into reliable, reusable physical skills.
Figures & tables
Figure 1: ACE-CaP-0: from targeted experience to standalone robot execution. Left: a coding agent refines policies on the robot, requesting robot demonstrations and using simulation as needed. Right: eight manipulation tasks, with each panel reporting the success rate and mean physical execution time in minutes. Each frozen policy is evaluated in 30 trials and executes with runtime perception and control, without a human or coding agent in the loop.
Figure 2: Guidance form for charger insertion. Top: textual guidance, robot-egocentric human video, and robot demonstrations, all available on request during real-only development. Both demonstration conditions also include textual guidance. Bottom: final success rate over 30 real-world trials of each frozen program, development time, and output token usage. Robot Demonstrations is the shared reference in Figures 3 and 4 .
Figure 3: Guidance timing for charger insertion. Textual guidance and robot demonstrations are provided upfront or requested during real-only development. The lower panels report final success rate over 30 real-world trials of each frozen program, development time, and output token usage. On-Request Guidance shares the Robot Demonstrations condition and results from Figure 2 .
Figure 4: Simulation protocols and charger-insertion results. Top: (a) Real-Only uses physical feedback; (b) Sequential Real-Sim-Real uses ten simulation rounds before transfer, each ending with a joint reset of four parallel environments; (c) Simulation on Demand makes simulated experiments available within real-world development. Bottom: final success rate over 30 real-world trials of each frozen program, development time, and output token usage. Real-Only is the shared reference from Figures 2 and 3 .
Figure 5: ACE-CaP-0: from policy development to standalone execution. (a) The coding agent writes and revises an executable policy using real-world feedback, with a shared robot toolbox that supports both policy execution and direct exploration by the agent. Throughout development, the agent can request kinesthetic demonstrations that provide video, arm trajectories, and key joint poses, or test candidate code in simulation for a chosen task segment and initial state. (b) The resulting code policy is frozen and executes through the robot’s interfaces without a human or coding agent in the loop. Section 4 evaluates these frozen policies without further updates.
Figure 6: Real-world evaluation platform and tasks. Left: the dual-arm platform with one top-down camera and two wrist-mounted cameras. Right: representative scenes for the eight tasks, covering alignment, object reorientation, multi-object handling, and bimanual coordination.
Figure 7: Real-world manipulation with the code policies developed by ACE-CaP-0. Each panel shows a task image and the success rate over 30 evaluation trials, with the successful trial count alongside it. Selected panels include end-state insets.
Task
Task objective
Success rate
Mean time (min)
Output token usage (M)
Charger Insertion
Insert a charger plug into a socket.
100.0% (30/30)
1.65
1.09
Bread Packing
Pack bread bags into a cardboard box.
83.3% (25/30)
1.93
2.14
Bottle Uncapping
Stabilize a bottle and remove its cap.
90.0% (27/30)
2.23
1.17
Cup Nesting
Insert multiple cups into one another.
93.3% (28/30)
1.58
0.95
Flower Insertion
Insert flower stems into a vase.
90.0% (27/30)
1.37
0.92
Chicken Plating
Plate the scattered chicken pieces.
96.7% (29/30)
1.12
0.75
Table 1: Task objectives, execution performance, and output token usage. Each frozen program is evaluated in 30 trials; parentheses give successful and total trial counts. Time denotes mean physical execution time in minutes. Output token usage is the cumulative output across all model calls during development, in millions (M).
"Code-as-Policy" considers how executable code can complement data-intensive Vision-Language-Action (VLA) methods, yet their effectiveness as autonomous controllers for embodied manipulation remains underexplored. We present CaP-X, an open-access framework for systematically studying Code-as-Policy agents in robot manipulation. At its core is CaP-Gym, an interactive environment in which agents control robots by synthesizing and executing programs that compose perception and control primitives. Building on this foundation, CaP-Bench evaluates frontier language and vision-language models across varying levels of abstraction, interaction, and perceptual grounding. Across 12 models, CaP-Bench reveals a consistent trend: performance improves with human-crafted abstractions but degrades as these priors are removed, exposing a dependence on designer scaffolding. At the same time, we observe that this gap can be mitigated through scaling agentic test-time computation--through multi-turn interaction, structured execution feedback, visual differencing, automatic skill synthesis, and ensembled reasoning--substantially improves robustness even when agents operate over low-level primitives. These findings allow us to derive CaP-Agent0, a training-free framework that recovers human-level reliability on several manipulation tasks in simulation and on real embodiments. We further introduce CaP-RL, showing reinforcement learning with verifiable rewards improves success rates and transfers from sim2real with minimal gap. Together, CaP-X provides a principled, open-access platform for advancing embodied coding agents.
General-purpose robot agents must learn from experience, transfer to new tasks, and act efficiently. Code as Policies (CaP) methods generate and repair programs at runtime, incurring latency and entangling reusable mechanisms with task-specific decisions. We introduce RACaP, an agentic framework that moves coding to evolution and uses a Reasoning-and-Acting (ReAct) loop to call frozen, typed Policy APIs at deployment. A two-phase strategy combines capability curriculum learning with autonomous self-evolution to improve the APIs, the ReAct harness, and experience memory. The APIs encode reusable physical mechanisms while exposing arguments for runtime adaptation. ReAct combines task-specific working memory, long-term experience memory, and visual feedback to select actions, verify outcomes, and recover from failures without modifying source code. RACaP achieves 54.4% success on LIBERO-90, 45.0% on zero-shot LIBERO-PRO, and 46.0% on LIBERO-Long, compared with at most 4.0% for CaP baselines on long-horizon tasks. On LIBERO-PRO, it achieves 2.5 times the success rate of CaP baselines and a 1.9-fold speedup in median policy time. For efficient on-robot deployment, rejection-sampled fine-tuning distills GPT-5.6 ReAct decisions into Qwen3-VL-8B-Instruct, yielding a 13.2-fold per-decision inference speedup and reducing repeated physical calls from 16 to 4. These results show that separating reusable code from runtime decisions supports continued evolution, effective transfer, and efficient long-horizon control.
Zexi Li, Yehang Zhang, Haojian Huang +10
The Chinese University of Hong Kong · Knowin AI · The Hong Kong University of Science and Technology (Guangzhou)
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 execution, and (iii) an interactive environment for program execution and verification. RAPID infers all three from the demonstration automatically. To make the resulting program reusable beyond the demonstration setting, RAPID uses an object-centric relational program representation that focuses on the underlying structure of the demonstrated strategy rather than the specific motion per se: it expresses the action primitives as trajectory-optimization programs that realize object-level motion effects, while composing them through relational constraints that capture scene-specific geometry at run time. We evaluated RAPID in simulation on eight challenging contact-rich nonprehensile manipulation tasks as well as general prehensile manipulation tasks in the LIBERO-Pro benchmark. We also successfully deployed it on a real Franka arm and evaluated on all eight nonprehensile tasks. In all experiments, RAPID demonstrated strong performance, with generalization over object pose, shape, material, and environment. Website: https://yuyaoliu.me/projects/rapid.
Yuyao Liu, Jiayuan Mao, David Hsu +2
Massachusetts Institute of Technology · National University of Singapore · University of Pennsylvania +1