Introduction
In the pursuit of general-purpose robotics, two paradigms have traditionally dominated: Classical Control, which requires engineers to manually write complex software for every subtask, and Vision-Language-Action (VLA) models, which learn directly from massive datasets.
A promising middle ground is Code-as-Policy (CaP), where a Large Language Model (LLM) generates the robot's control code on the fly. However, previous CaP systems have often relied heavily on high-level, human-designed macros (e.g., stack_objects()). This scaffolding makes it difficult to determine whether the AI is genuinely capable of complex reasoning or merely triggering pre-programmed routines.
To address this, researchers introduce CaP-X, an open-access framework designed to systematically study, benchmark, and improve Code-as-Policy agents. CaP-X investigates whether these agents can operate over low-level primitives, how much designer scaffolding truly matters, and how to make them robust enough for real-world deployment without expensive retraining.
The CaP-X Framework
The paper introduces a comprehensive, four-part ecosystem to evaluate and enhance coding agents:
- CaP-Gym: A standardized interactive environment built on Gymnasium. It allows coding agents to control robots in both simulation and reality through a Read-Eval-Print Loop (REPL), synthesizing and executing programs that compose perception and control primitives.
- CaP-Bench: A systematic benchmark evaluating 12 state-of-the-art models (including GPT-o1, Gemini 3 Pro, and Claude 4.5) across varying levels of abstraction (high-level vs. low-level) and interaction modes (single-turn vs. multi-turn).
- CaP-Agent0: A training-free "agentic harness" that pushes performance to near human-level using test-time scaling:
- Visual Differencing Module (VDM): Instead of relying on raw pixels, a Vision-Language Model (VLM) describes the scene and the changes between turns in natural language.
- Auto-Synthesized Skill Library: The system automatically distills successful code executions into a library of reusable, task-agnostic functions.
- Parallel Reasoning: The system ensembles multiple model queries to identify the most robust solution.
- CaP-RL: A reinforcement learning method for fine-tuning the coding agent itself. It uses Group Relative Policy Optimization (GRPO) based on verifiable environment rewards, treating executable code as the action space.
Experimental Setup and Datasets
To rigorously test these agents, the authors integrated three major robotics suites into CaP-Gym, totaling 187 tasks:
- Robosuite: Standard manipulation tasks (e.g., Cube Lift, Peg Insertion).
- LIBERO-PRO: 130 tasks focused on lifelong learning and generalization.
- BEHAVIOR: 50 long-horizon household tasks (e.g., "Pick up the radio").
- Real-World Testing: Evaluated on Franka Panda and AgiBot G1 embodiments for zero-shot tasks, such as "Mechanical Search" (finding a lime hidden under cups) and solving math equations using wooden blocks.
Key Findings and Results
The Scaffolding Trap and Cross-Modal Gaps
The benchmark revealed that model performance drops significantly when human-crafted high-level APIs are removed, exposing a heavy dependence on designer scaffolding. Furthermore, directly feeding images to a coding agent (multimodal feedback) often decreased performance, as models struggled to map raw pixels directly to code logic.
Text as the Universal Interface
Converting visual feedback into structured text via the Visual Differencing Module proved highly effective. It allowed the coding agent to reason about failures (e.g., "the grasp was too high") and self-correct, bridging the cross-modal alignment gap.
Test-Time Scaling and Human-Level Performance
By scaling test-time computation—giving the agent more turns to debug its own code and ensembling different reasoning paths—the system compensated for the lack of low-level primitive capabilities. CaP-Agent0 achieved success rates comparable to, and sometimes exceeding, human expert-written code on 4 out of 7 core benchmark tasks.
Reinforcement Learning and Sim-to-Real Transfer
Using CaP-RL, a base Qwen 2.5 Coder model improved its success rate on a "Cube Lift" task from 25% to 80%. Because the action space consists of high-level code rather than low-level motor torques, strategies learned in simulation transferred seamlessly to real robots, enabling the successful execution of complex, zero-shot real-world problems.
Limitations and Future Work
While CaP-X demonstrates significant progress, challenges remain:
- Latency: Generating code takes seconds (6.8s to 23.8s per iteration), making these agents too slow for highly reactive, high-frequency tasks.
- Contact-Rich Physics: The system struggles with tasks requiring tight visual servoing, such as pouring liquids or precise insertions, where continuous, real-time feedback is necessary.
To overcome these limitations, the authors suggest exploring Hybrid CaP-VLA policies, where a coding agent handles high-level logic, reasoning, and error recovery, while a VLA model manages low-level, high-frequency execution.
Summary updated