Skip to content
Robotics.world

Research

CaPtain: A Pipeline for Post-Training Code-as-Policy Robot Agents

Language-model agents in coding, web navigation, and tool use are routinely trained with the same recipe: supervised fine-tuning to learn the interface, then multi-turn reinforcement learning to…

The paper’s first page · arXiv:2610.40799
arXiv
2610.40799 · Preprint · not peer-reviewed
Published
2026-10-29
Authors
Yijia Fan, Xilin He, Yilei Jiang, Dongming Wu, Jiaxu Wang, Xiangyu Yue

In plain words

Language-model agents in coding, web navigation, and tool use are routinely trained with the same recipe: supervised fine-tuning to learn the interface, then multi-turn reinforcement learning to master it.

AI summary

CaPtain: A Pipeline for Post-Training Code-as-Policy Robot Agents

Overview

Research area: Robot learning / embodied AI — specifically code-as-policy (CaP) agents, where a vision-language model controls a robot by writing Python against perception and motion APIs.

Technical level: Advanced. The paper assumes familiarity with supervised fine-tuning, multi-turn reinforcement learning, advantage estimation, and manipulation benchmarks.

Scope (one sentence): The paper introduces an open, end-to-end SFT-then-RL post-training pipeline that turns a small 4B open vision-language model into a standalone code-as-policy manipulation agent operating over 22 low-level primitives, with no vision-language-action model, frontier API, or privileged state at test time.

What This Paper Is About

Language-model agents in coding, web navigation, and tool use are routinely trained with the same recipe: supervised fine-tuning to learn the interface, then multi-turn reinforcement learning to master it. Code-as-policy robotics has the same shape — the policy writes code against robot APIs and reads back results — but existing systems skip training entirely, either prompting closed frontier models or delegating the actual manipulation to frozen vision-language-action models and high-level skills. Meanwhile small open vision-language models fail outright (Qwen3.5-4B solves 0% of LIBERO episodes in the authors' harness). CaPtain closes that gap by making the recipe work at the level of low-level primitives, where every grasp decision belongs to the policy itself.

Key Contributions

  1. CaPtain, an open end-to-end SFT-and-RL pipeline that turns a small open VLM into a standalone CaP agent. The authors release the SFT data, training code, and CaPtain-4B weights.

  2. CaPtain-Harness, a portable execution harness with low-level primitives only — 22 perception, geometric-measurement, and guarded-motion capabilities plus finish(), with no grasp, place, or open-drawer skills and no VLA. Every robot call returns a grounded structured text receipt, and the policy-facing API is identical across LIBERO, RoboTwin 2.0, RoboDojo, SimplerEnv, CaP-Bench, and a physical robot.

  3. A simulator critic for multi-turn VLM agents that converts privileged physical state transitions into dense per-request credit, pairing the streaming RL formulation of SAO with asymmetric actor-critic training. The critic sees 36 physical features the policy never sees and is removed at test time.

  4. A comprehensive evaluation showing RL gains persist across three perturbation suites, that a 4B policy surpasses several frontier-model agents at a small fraction of their cost, and that it transfers zero-shot across benchmarks and embodiments and to a physical robot without real-world data.

Main Findings

  • SFT then RL transforms a failing base model. Qwen3.5-4B starts at 0% zero-shot on held-out LIBERO (at most 0.3% on any suite, exhausting its request budget misusing the interface). CaPtain-4B-SFT reaches 55.4% host success, and RL lifts it to 73.8%. Strict success rises from 52.1% to 67.5%.

  • RL improves behavior quality, not just success. False finishes drop from 7.1% to 2.1% of episodes, and the mean number of requests per episode falls from 39.1 to 32.6.

  • Gains survive perturbation. RL adds +19.0 host points on LIBERO-PRO across the 3 short-horizon suites, +19.4 across all 4 suites, +17.6 on LIBERO-Plus, and +21.2 (Dynamic) / +18.8 (Base) on LIBERO-MAX. On LIBERO-Plus all seven perturbation dimensions improve at p < 0.05 and six of seven survive a Bonferroni correction; largest gains are lighting (+23), camera, object layout and robot initial state (+18 each), and smallest sensor noise (+13).

  • A 4B model beats several frontier-API agents on LIBERO-PRO. CaPtain-4B reaches 78.5% on the 3-suite average, above K1 (77.2%, Gemini 3.7 Flash), WAA (75.6%), and ASPIRE (71.7%, Claude Opus 4.6). It also beats open-weight agents without VLA delegation: SPARK (66.8%, a 27B model) and Guava (≈41.0%).

  • Low-level RL beats skill-level RL in raw point gain. Multi-turn RL over low-level primitives adds +19.4 points on the 4-suite average (49.2% → 68.6%), versus +5.9 points for AgenticRoboRL's RL over a frozen LIBERO VLA (65.1% → 71.0%) — though the authors note the two start from different baselines.

  • Zero-shot SimplerEnv WidowX: 83.3%. Per-task: spoon on towel 75.0, carrot on plate 79.2, block stacking 91.7, eggplant in basket 87.5. This is close to ManiAgent with GPT-5 (86.8) and above PhysBrain 1.0 (80.2) and π0.5 (57.1).

  • Zero-shot CaP-Bench: 75.0. This beats Gemini-3-Pro (73.5), GPT-5.2 (55.5), Claude Opus 4.5 (54.0), and the 7B coder trained with CaP-RL directly on CaP-Bench (62.0). SFT alone scores 55.0 and the untrained base model 5.0. Run to the full episode horizon, CaPtain-4B completes 20/20 Cube Lift and 19/20 Cube Stack trials (97.5% mean), showing the gap to 75.0 reflects execution speed against CaP-Gym's step cutoff rather than task failure. Results on the remaining three tasks of the five-task suite are cut off in the provided content and not reported here.

  • Transfer is limited on dual-arm benchmarks. RoboTwin 2.0: 22.6% on all 50 tasks, 30.0% on the 33-task single-arm subset, versus 46.0% for π0.5 and 48.7% for OpenWAM-α trained in-domain. RoboDojo: Score 1.7 and 0.8% success (2.0 / 1.0% on the 32 single-arm tasks), against GPT-6 Astra's 29.0 / 22.5%. The stated bottleneck on the ARX X5 is kinematic reach: the 6-DoF arm's top-down workspace extends only ≈0.5 m from its base.

  • Cost is low. A LIBERO episode uses 32.6 requests on average (median 26), 16.6 physical actions, and 7.3k output tokens, taking 417 s of wall time on a GPU shared by eight episodes — about 52 GPU-seconds of policy compute, or an estimated $0.03–0.06 per episode at $2–4 per GPU-hour excluding perception services. Published code agents report $0.18–0.24 (SPARK, WAA, RACaP) to $8–22 (OpenRUA) per episode.

  • Real-robot operation after simulation-only adaptation. The paper reports that CaPtain-4B runs on a physical robot after adaptation in a coarse simulated twin alone; specific real-robot success rates are not reported in the provided content.

Methodology in Plain English

Build a harness with nothing high-level in it. The policy interacts through a sandboxed Python session with a pre-imported robot module. The module offers 22 capabilities — observe (head and wrist RGB-D), segment (SAM 3 masks), point (Molmo2), mark_point (back-project a pixel the model chose itself), track_target, geometry measurement, move_to (absolute end-effector pose or a jaw command), hold, recover, release, and read-only reachability/state checks. The agent must decide where to grasp, from which direction to approach, and when to close the jaw. Motions are straight Cartesian moves with inverse kinematics, self-collision checking, and force monitoring at every control substep. Each call returns a text "receipt" reporting what physically happened — stop reason, executed distance, peak force, jaw opening — so the model gets grounded text feedback alongside images.

Keep the context manageable. An episode is up to 60 requests, each one model call that reasons and then emits code. Tool outputs are truncated to a token budget, at most 20 receipt lines print per cell, only the 12 most recent images are kept, and the harness compacts old turns into a short notice listing the commands they ran. Because variables live in the Python session rather than the prompt, detections and poses survive compaction.

Stage 1 — supervised fine-tuning. Trajectories are generated with GPT-6 Astra inside the harness and rendered in exactly the chat template, system prompt, TASK.md, tool schema, and receipt format the policy sees at deployment. Only agent-produced tokens are supervised; turns with repeated execution failures or recovery loops are masked out, and visual question-answering examples are added at weight 0.5. With probability 0.2, earlier coordinates in the history are replaced with a mask token so the model cannot copy pixel coordinates from previous mark_point calls. All language-model weights are fine-tuned; the vision tower stays frozen.

Stage 2 — multi-turn RL with a simulator critic. The hard part is credit assignment: an episode contains tens of requests, most of which only perceive or verify, and the single outcome arrives at the end. Since training is in simulation, the harness records a hidden snapshot before each request and reduces it to 36 features in five groups (end-effector and jaw state; goal bookkeeping; distances between end-effector, target, and destination; target lift and displacement; articulated-joint positions plus held/ever-held flags). Behavioral counters such as the number of perception or failed calls are deliberately excluded because they act as proxies for elapsed time and absorb credit from grasping. An ensemble of five small MLPs predicts the probability of success from these features plus request index and task embedding. Each request's credit is the change in predicted success it causes, computed at a fixed time index, so time passing alone earns nothing and perceiving-only requests get near zero. These credits feed GAE with λ = 0.9, combined with a group-relative outcome term over G = 4 rollouts per start state. The critic is warm-started and then co-trained online; its advantages always come from the critic before the round's update.

Rewards and safeguards. Success with finish() earns 1; success without it 0.25; other failure 0; budget exhausted −0.1; a false finish −0.3. Costs penalize failed or rejected physical actions, action counts far beyond the task norm, and any action after the scene is solved. A host-side gate can reject finish() twice. Episodes where all goals hold for 15 consecutive requests without finish() are stopped and scored as a missed finish.

Policy update. The streaming single-pass SAO update with double-sided token masking: tokens whose probability ratio falls outside (0.2, 4) are dropped rather than clipped, and a KL term keeps the policy near the SFT model. Gradients accumulate over 1,024 episodes per optimizer step because the estimator's gradient-noise scale is in the thousands of episodes — without accumulation, consecutive updates were nearly orthogonal. Each round samples 64 start states, and an optimizer step plus weight sync happens every 4 rounds. Up to 8 requests per trajectory are used for the policy gradient, uniformly sampled and reweighted; the critic uses every request. Rollouts run asynchronously, so a request may come from a policy up to two versions old.

Training and evaluation setup. RL samples fresh start states across all 40 LIBERO tasks with randomized lighting, camera pose, and materials; the 240 official evaluation states are excluded. Evaluation uses temperature 1, thinking enabled, at most 60 requests, 150 physical actions, and 1,080 s per episode, with the critic removed and all object coordinates estimated online from RGB-D. Reported checkpoints: CaPtain-4B-SFT (also the KL reference) and round 300 (75 optimizer updates).

Why This Matters

The paper argues that robot manipulation over a low-level execution harness can be post-trained like any other language agent — that the SFT-then-RL recipe generalizes beyond coding and web tasks once the interface is low-level enough. It also demonstrates a clean use of simulation's information asymmetry: the critic reads physics the deployed policy cannot see, and is discarded at test time. The economics matter too: a 4B open model at roughly $0.03–0.06 per episode is a different deployment proposition from $8–22 per episode for frontier-API code agents.

Real-world applications:

  • Onboard robot control. Because the policy runs on a small open model with no frontier API and no privileged state, it can run on robot-mounted compute where network calls to closed models are impractical.
  • Warehouse and lab automation. Tabletop pick-and-place, stacking, and articulated-object tasks (drawers) where the harness's guarded motions and force monitoring provide safety envelopes.
  • Cheap generalist baselines for new embodiments. The portable adapter design means a new robot backend can inherit an existing policy, as the physical-robot result after simulation-only adaptation suggests.
  • Verifiable completion for deployed fleets. The finish() gate and strict-success metric give a deployment-relevant signal: a robot that cannot declare completion cannot be deployed.

Industry relevance: The work targets the cost and lock-in problems of frontier-API robotics agents and the data-dependency problem of VLA-based systems. Releasing weights, data, and code at 4B scale makes the approach reproducible on modest hardware. The reported failures are equally informative for industry planning: dual-arm coordination and unfamiliar kinematics (22.6% on RoboTwin 2.0, 0.8% on RoboDojo) and a ≈0.5 m reach constraint mark where the approach is not yet ready.

Future Directions

  • Dual-arm coordination and cross-embodiment transfer. The paper's weakest results are exactly here. CaPtain-4B acts with one arm at a time and routes calls by nearest base; extending the harness and training distribution to simultaneous two-arm action, handover, and navigation is the obvious next step.
  • Overcoming kinematic reach limits. The ≈0.5 m top-down workspace of the 6-DoF ARX X5 is named as the primary RoboDojo bottleneck, raising the question of whether base motion, mobile manipulation, or different arm mounting should enter the primitive set.
  • Generalizing the simulator critic beyond simulation. The credit mechanism depends on privileged physical state that only a simulator provides. Whether the same per-request credit can be learned from real-world proprioception, contact sensing, or learned state estimators is unresolved — the paper's real-robot result relies on adaptation in a coarse simulated twin.
  • Extending the recipe to skill-level and longer horizons. Since CaPtain deliberately excludes grasp/place skills, an open question is how far the low-level-only design scales before skill abstractions, or a hybrid, become necessary — particularly given that the long-horizon LIBERO-PRO suite shows the smallest gain (+13.3).

Target Audience

Robotics and embodied-AI researchers working on code-as-policy agents, language-model post-training, and credit assignment in long-horizon multi-turn RL. It is also relevant to engineers building deployable manipulation stacks who need to weigh frontier-API agents and VLA-based systems against a small self-hosted policy, and to readers interested in asymmetric actor-critic methods and privileged-information training. Beginners will find the system-level framing (harness, receipts, SFT-then-RL) accessible, but the RL section assumes comfort with advantage estimation, KL-regularized policy gradients, and off-policy staleness handling.

Authors’ abstract

Across coding, web, and tool-use tasks, language-model agents are now routinely trained with the same recipe: supervised fine-tuning (SFT) to learn the interface, then multi-turn reinforcement learning (RL) to master it. Code-as-policy (CaP) casts robot manipulation in the same form, as the policy writes code against robot APIs and reads back the results, so the same recipe should apply. Yet existing CaP agents sidestep training: they either prompt closed frontier models or…

The full abstract on arXiv
Read the original paper

Related papers