TL;DR
The paper introduces CaP-X, a comprehensive framework designed to systematically evaluate and enhance "Code-as-Policy" (CaP) agents for robotic manipulation. By analyzing how large language models perform when human-designed abstractions are removed, the authors develop CaP-Agent0—a training-free agent that achieves near human-level reliability by scaling up test-time computation through iterative debugging, ensembled reasoning, and automated skill synthesis.
What Problem Does This Paper Address?
While Vision-Language-Action (VLA) models excel at end-to-end learning for robotics, they often act as black boxes that lack interpretability and struggle to generalize to new environments without extensive retraining. An alternative paradigm, Code-as-Policy (CaP), uses language models to generate executable Python code to control robots.
However, prior CaP systems heavily relied on high-level, human-engineered primitives (e.g., stack_objs_in_order()). This "human scaffolding" makes it difficult to determine whether the success stems from the AI agent's reasoning or the cleverness of the human designer. This paper addresses this gap by systematically evaluating how coding agents perform as human scaffolding is stripped away, forcing them to operate on low-level, atomic control and perception primitives.
Methods
The authors propose a multi-component ecosystem to benchmark and improve coding agents:
- CaP-Gym: An interactive environment that wraps standard physics simulators into a Read-Eval-Print Loop (REPL) paradigm. Agents receive observations, generate a Python program, and execute it directly within the environment.
- CaP-Bench: A benchmark that evaluates 12 frontier models across three axes: Abstraction Level (high-level macros vs. low-level APIs), Temporal Interaction (single-turn vs. multi-turn debugging), and Perceptual Grounding (raw images vs. text descriptions).
- CaP-Agent0: A training-free agentic framework that introduces three key design choices to mitigate low-level execution failures:
- Visual Differencing Module (VDM): Converts visual observations into structured natural language descriptions of scene changes across turns.
- Auto-Synthesized Skill Libraries: Automatically distills successful low-level execution traces into a reusable, task-agnostic skill library that persists across trials.
- Parallel Reasoning: Concurrently samples multiple code candidates from single or multiple models and uses an ensemble agent to synthesize the final optimal program.
- CaP-RL: An on-policy reinforcement learning method using Group Relative Policy Optimization (GRPO) to fine-tune the language model directly based on environment rewards, using code as the action space.
Datasets
The framework introduces a massive suite of tasks:
- CaP-Gym includes 187 tasks unified under a shared primitive interface, drawing from Robosuite (7 tasks), LIBERO-PRO (130 tasks), and BEHAVIOR (50 tasks).
- CaP-Bench focuses on a controlled subset of 7 core manipulation tasks (such as Cube Lift, Cube Stack, Spill Wipe, Peg Insertion, and Two-Arm Handover) evaluated over 100 trials per model tier.
Key Insights and Ideas
- The Scaffolding Dependency: As human-crafted abstractions are removed (moving from high-level to low-level primitives), zero-shot performance across all 12 frontier models drops significantly. Current models still heavily rely on human-engineered APIs to sequence tasks successfully.
- The Cross-Modal Alignment Gap: Counter-intuitively, directly feeding raw RGB images to multimodal models during multi-turn debugging degrades code generation performance. Models struggle to jointly reason over software code and raw physical execution images. Translating these images into structured text via a Visual Differencing Module (VDM) yields much better results.
- Test-Time Compute Scaling: Robustness can be synthesized at runtime. By allowing the agent to iterate, inspect its own
stdout/stderrerror traces, and leverage parallel ensembled queries, agents operating on low-level primitives can match or exceed the performance of high-level single-turn baselines.
Key Results
- CaP-Agent0 Performance: By combining VDM, parallel reasoning, and an auto-synthesized skill library, CaP-Agent0 bridges the gap to human experts, achieving comparable or superior success rates on 4 out of 7 core CaP-Bench tasks.
- Outperforming VLAs: On the challenging LIBERO-PRO benchmark under position and instruction perturbations, the training-free CaP-Agent0 achieved an average success rate of 14-22%, comparable to or exceeding state-of-the-art, training-heavy VLA models like $\pi_{0.5}$.
- Sim-to-Real Success: Using CaP-RL to post-train a lightweight model (Qwen2.5-Coder-7B) boosted its simulation success rate on a cube-lifting task from 25% to 80%. Because code serves as the action space, these learned strategies transferred directly to a physical Franka Emika robot with zero simulation-to-real gap, retaining an 84% success rate.
Limitations and Future Work
While programmatic control excels at long-horizon, reasoning-heavy tasks, it remains brittle for contact-rich, high-frequency behaviors that require continuous feedback (e.g., precise peg insertion or fluid pouring).
The authors suggest that the most promising path forward is a hybrid CaP-VLA policy, where a coding agent manages high-level task logic and error recovery, while deferring low-level, continuous motor execution to a specialized VLA policy.
Summary updated