CaP-X: A Framework for Benchmarking and Improving Coding Agents for Robot Manipulation

Letian Fu, Justin Yu, Karim El-Refai, Ethan Kou, Haoru Xue, Huang Huang, Wenli Xiao, Guanzhi Wang, Dantong Niu, Fei-Fei Li, Guanya Shi, Jiajun Wu, Shankar Sastry, Yuke Zhu, Ken Goldberg, Linxi "Jim" Fan

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:

  1. 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.
  2. 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).
  3. CaP-Agent0: A training-free agentic framework that introduces three key design choices to mitigate low-level execution failures:
  4. Visual Differencing Module (VDM): Converts visual observations into structured natural language descriptions of scene changes across turns.
  5. Auto-Synthesized Skill Libraries: Automatically distills successful low-level execution traces into a reusable, task-agnostic skill library that persists across trials.
  6. Parallel Reasoning: Concurrently samples multiple code candidates from single or multiple models and uses an ensemble agent to synthesize the final optimal program.
  7. 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.
High-Level vs. Low-Level code generation examples in CaP-Bench

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/stderr error traces, and leverage parallel ensembled queries, agents operating on low-level primitives can match or exceed the performance of high-level single-turn baselines.
Figure 1. (Top) CaP-Bench Task Success Rate over Model Release Date: across 7 tasks and 12 models, we compare the success rates of model-generated robot-control programs against those of human expert-written programs. We find that while (vision-) language models have achieved capabilities comparable to humans in other domains (Jimenez et al., 2024; Rein et al., 2024; Hendrycks et al., 2020), they still trail behind human performance in writing code that controls robots for manipulation tasks. (Bottom): CaP-Gym integrates Robosuite (Zhu et al., 2020), LIBERO-PRO (Zhou et al., 2025), and BEHAVIOR (Li et al., 2024). We further present CaP-Agent0 (Section 4), a training-free agentic framework that recovers near human-level performance on several manipulation tasks and achieves success rates comparable to—and in some cases exceeding—those of post-trained VLAs, without any task-specific training data.

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

BibTeX
@inproceedings{fu2026cap,
  author = {Letian Fu and Justin Yu and Karim El-Refai and Ethan Kou and Haoru Xue and Huang Huang and Wenli Xiao and Guanzhi Wang and Dantong Niu and Fei-Fei Li and Guanya Shi and Jiajun Wu and Shankar Sastry and Yuke Zhu and Ken Goldberg and Linxi "Jim" Fan},
  title = {{CaP-X: A Framework for Benchmarking and Improving Coding Agents for Robot Manipulation}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=4JRO9plGAI},
}
Figure