CaAP: Code as Adaptive Policies

for Cold-Start Robot Manipulation

Pianran Huang1, Ziyi Liu2,†, Zhaoxin Luo1, Qichen Tan2, Jiajie Xu2, He Huang2, Min Zhang1, Zhijun Li1,†
1Harbin Institute of Technology 2Soochow University
†Corresponding authors: liuziyi@suda.edu.cn (Z. Liu), lizhijun_os@hit.edu.cn (Z. Li)
Paper (coming soon) arXiv (coming soon) Code BibTeX
Prior code-as-policy versus CaAP
Prior code-as-policy versus CaAP. Top: a prior agent runs each turn's code to the end, tips the object over, and later turns cannot grasp the fallen object. Bottom: CaAP captures the uncertain motion, hands off before the next step, and the LLM writes turn t+1 from both; LoreCraft carries the lessons to later trials. Bottom left: success rate versus rollouts (LIBERO-PRO, 60 tasks).
ABSTRACT

Code-as-policy methods enable robot manipulation without task-specific training, but they often achieve low zero-shot success and require extensive interaction to adapt to new tasks. We present CaAP, a framework that improves both zero-shot performance and few-trial adaptation efficiency. Within a trial, Self-Adaptive Process Monitoring lets the agent specify when and how to observe execution, while Heritable Handoff deliberately suspends the program when its assumptions no longer hold, preserving the scene and program state for subsequent recovery. Across trials, LoreCraft consolidates successes and failures into declarative lessons and reusable executable tools, enabling subsequent attempts to build on prior experience. On LIBERO-PRO, CaAP achieves 53.9% average zero-shot success, about three times that of the strongest code-based baseline, CaP-Agent0 (18.0%), and 10.3 percentage points above the strongest evaluated vision-language-action baseline. After 15 online adaptation trials per task, validation-based program selection raises the average success rate to 73.1%. This exceeds the 61.7% reported by ASPIRE with Opus 4.6 while using about one-sixth of its rollouts and one-tenth of its cost. Experiments on a real bimanual mobile manipulator further demonstrate the applicability of CaAP to physical robot manipulation.

1Method

A code-as-policy agent writes a program, runs it, and only regains control when the program finishes or fails. By then a wrong assumption may already have knocked an object over. CaAP changes what happens inside a trial and what carries over between trials.

Within a trial · detect

Self-Adaptive Process Monitoring

The generated code opens capture windows around the motions it is unsure about and chooses how to sample them. A vision model reports what happened in those frames, so the next turn sees how the motion unfolded, not only where it ended.

Within a trial · recover

Heritable Handoff

When a check in the code fails, the program suspends itself instead of continuing on a false premise. The scene and the program namespace are kept intact, and the next turn resumes from the measured state.

Across trials · learn

LoreCraft

After each trial, successes and failures are consolidated into Lore, declarative lessons, and Craft, executable tools that later programs can call. Later attempts start from what earlier ones learned.

CaAP overview
CaAP overview. Within a trial, generated code selects action intervals for visual monitoring and can deliberately hand off control when further decisions are needed. Witness evidence and handoff diagnostics are available to the next agent turn. Across trials, LoreCraft updates declarative lessons and executable tools.
Capture-window sampling modes
Capture-window sampling. Endpoint compares the beginning and end of an action, uniform follows its motion, and keyframe selects frames with large visual changes. In the keyframe example, the gripper closes on empty space; the next turn adjusts the grasp after handoff.

2Results on LIBERO-PRO

53.9%average zero-shot success over 60 tasks
3×the strongest code-based baseline (18.0%)
73.1%after 15 online adaptation trials per task
1/6 · 1/10of the rollouts and cost of ASPIRE with Opus 4.6

Zero-shot success (%) on six LIBERO-PRO splits

MethodObject-PObject-TGoal-PGoal-TSpatial-PSpatial-TAvg.
VLA models, trained on LIBERO demonstrations (selected)
π0.517.40.837.82.020.40.813.2
ABot-M09.09.85.610.613.454.817.2
PRTS36.08.819.033.826.862.231.1
Cont. Reasoning54.527.036.033.051.060.043.6
Code-based methods, no target-task rollouts before evaluation
Opus 4.623.617.026.65.08.68.514.9
CaP-Agent021.818.225.616.811.814.018.0
CaAP (final)59.253.254.017.251.662.249.6
CaAP (ever)60.055.262.026.854.065.453.9

P and T denote position and task perturbations. CaAP uses DeepSeek-V4.1-Flash-1017; Opus 4.6 and CaP-Agent0 use Claude Opus 4.6 and an ensemble of Gemini-3-Pro, GPT-5.2 and Claude Opus 4.5. The full table with all VLA baselines is in the paper.

Zero-shot success by task
Zero-shot success by task. Final success over 50 seeds per task; P and T denote position and task perturbations.

Online adaptation

Success versus rollouts per task
Success versus target-task rollouts. Average over LIBERO-PRO; dashed lines mark CaAP before and after adaptation.
LIBERO-PRO success before and after online adaptation
Before and after adaptation. ASPIRE uses the same model and the same budget of 34 rollouts per task.

Same-model comparisons

CaP-Bench Robosuite tasks
CaP-Bench (Robosuite). One query per turn for CaAP, nine for CaP-Agent0; seeds 1–25.
Component ablations
Ablation. 30 tasks, seeds 1–10, one-shot versus multi-turn.

All methods in the bar charts use DeepSeek-V4.1-Flash-1017.

3Example rollouts

Zero-shot trials with empty memory: the program is written by the language model at test time, with no task-specific training or demonstrations.

LIBERO-PRO, Object-P task 9. Pick up the orange juice and place it in the basket.
LIBERO-PRO, Goal-P task 7. Turn on the stove.
CaP-Bench (Robosuite), Two-Arm Handover. One arm picks up the hammer and hands it over; the other arm grasps it by the handle.
CaP-Bench (Robosuite), Cube Restack. Place the red cube on top of the green cube.

4A trial, turn by turn

Goal-P task 8, put the bowl on the plate, zero-shot with empty memory. Every grasp attempt is wrapped in a capture window and followed by a check on the gripper width. When a check fails, the block hands off before lifting, the bowl is not disturbed, and the next turn changes only the grasp. The trial succeeds after 9 agent turns.

Main camera.
Wrist camera.
Case study key turns
Key turns of the trial. Failed grasps are stopped by the code's own checks and handed off; the successful grasp is followed by transport and placement.

5Real robot

On a bimanual mobile manipulator, the task instruction is obtained from a human demonstration video: pour oil before adding seasoning. Online execution forms a program; after freezing, the same program completes the ordered task without further model calls, despite rearranged objects and additional distractors.

Real-robot multi-stage pouring
Real-robot multi-stage pouring. Human demonstration (top), online execution (second row), and the frozen program under rearranged objects and distractors (bottom rows).
Human demonstration. The task instruction is obtained from this video.
Online execution. The agent writes and revises the program with model calls while performing the task.
Frozen program. The same program runs without model calls, with rearranged objects and additional distractors.

6BibTeX

@article{caap2026,
  title   = {CaAP: Code as Adaptive Policies for Cold-Start Robot Manipulation},
  author  = {Huang, Pianran and Liu, Ziyi and Luo, Zhaoxin and Tan, Qichen and
             Xu, Jiajie and Huang, He and Zhang, Min and Li, Zhijun},
  journal = {arXiv preprint},
  year    = {2026}
}