PyRUA-
Learning Programmatic Policies
for Dexterous Bimanual Manipulation with Coding Agents
SOTA on Bench2Dex
1Peking University2National University of Singapore3NVIDIA
4Tongji University5University of Chicago
*Equal contribution†Corresponding author
Coding agents explore a task in simulation, refine the resulting program stage by stage, and hand over a frozen programmatic policy that runs with no language model at test time.
A programmatic policy for every task, learned from the agents' own trials
Abstract
Learning for dexterous manipulation is limited by the scarcity of high-quality demonstrations: retargeting from human video is imprecise, teleoperation gives no force feedback to the operator, and exoskeleton-based collection is hard to scale up. We present PyRUA-Dex, a framework that enables coding agents to develop dexterous manipulation through programmatic policy, without the need of demonstrations. The programmatic policy is developed in two stages: during exploration, multiple agents explore in parallel for task skills and ways to compose them, and a distilling agent condenses the successful attempts into a task library and one program. During refinement, this program is improved through randomized layouts for enhanced robustness and execution efficiency. In simulated environments, PyRUA-Dex achieves SOTA on Bench2Dex with a score of 72.9 and reaches 81.0% success on DexJoCo under full randomization, ahead of every trained policy on both benchmarks. In real world experiments on a bimanual platform with two 22-DoF hands, PyRUA-Dex learns to play piano, write calligraphy, and other tasks efficiently: learning a new piece from sheet music takes as little as 30 minutes. These results suggest that PyRUA-Dex is an effective framework for developing dexterous manipulation policies with coding agents in the absence of high quality dexterous manipulation demonstrations.
Exploration, then refinement
PyRUA-Dex learns one programmatic policy per task in simulation and deploys it as a frozen program. Both stages are carried out by general coding agents, Codex CLI sessions of GPT-6 Astra, each with a shell, its own simulator instance and a library of perception and control primitives shared by all robots (the codebox). Exploration (Stage 1) searches for a program that completes the task at all; refinement (Stage 2) improves how reliably that program completes the task on unseen layouts.
Two stages, both in simulation
Exploration
find a program that completes the task at all
- Eight agents in parallel. Each receives the task library, a training layout of its own and one of the stages not yet solved.
- Exploration with state resets. An agent checkpoints the simulator's state during an episode and resets to a checkpoint, eight times per layout: it retries one stage many times without repeating the stages before it, and queries the stage count after each attempt.
- Shared memory. One memory per task in three parts: an event log written automatically, notes kept by a dedicated curating agent (for each stage: the method that reached it, what failed and what is still untried) and a code folder with each function that reached a stage. Every agent receives what is new in its next tool reply.
- Program evaluation. Each agent writes a program that reproduces what it achieved; it is evaluated without the agent on eight fresh training layouts.
- Distillation. A distilling agent writes the task library from the evaluation records and selects the task's program.
Refinement
make the program reliable on unseen layouts
- Stage-wise failure analysis. The program runs on 32 fresh training layouts and the result is broken down by stage, which shows the bottleneck before any change is made.
- Bottleneck refinement. The agent repairs the stage function with the help of state resets, then measures it with partial rollouts: the program runs only up to that stage on tens of fresh layouts, with twice the benchmark's step budget.
- Retries. With
AGAIN = True, a stage function that did not end ok is called again while steps remain. - Program selection. After every 160 training layouts the current version is evaluated without the agent on 32 fresh and 32 held-out layouts, at the benchmark's step budget; of at most 1,500 layouts, the version with the best held-out record is selected.
A task is a chain of stages
Learning a task is a search over programs π: maximize the success rate SR(π) on the benchmark's test layouts, subject to a budget of simulated layouts for development.
rk, the stage success rate: the fraction of layouts that reach stage k among those that reached the stage before
Five stages that each hold on 80% of the layouts complete only 33% of them, so a program that worked once fails on most layouts.
Because ∂ log SR / ∂rk = 1 / rk, the largest gain comes from the least reliable stage, the bottleneck: refinement finds it and raises it.
- Exploration makes every stage success rate positive, rk > 0: a search over grasps, hand orders and motions on a few layouts.
- Refinement needs stage success rates estimated over many layouts: once every rate is positive, the product dominates.
- Retries raise a stage's success rate directly. In 68% of the failed validation runs of the programs after exploration, on the 22 tasks they completed at least once, the program had returned with at least 30% of the step budget unused.
- The staged form lets every measurement be reported per stage, lets functions written by different agents be combined, and lets a single stage be executed in isolation.
The form of every program
STAGES = ["grasp", "place"] # the task's stages, in order
AGAIN = True # call stages that did not end ok again
def setup(codebox, context):
# measure once what the stages need
context["table"] = codebox.table()
context["box"] = codebox.locate("box")
def grasp(codebox, context):
tool = codebox.locate("screwdriver") # measure
codebox.move_to("right", grasp_point(tool)) # act
codebox.close("right")
if not codebox.holding("right"): # check
return Outcome(False, "not held")
return Outcome(True, "held")
def place(codebox, context):
if not codebox.holding("right"): # check on entry
return Outcome(False, "nothing held")
codebox.move_to("right", above(context["box"]))
codebox.release("right")
seen = codebox.relocate("screwdriver") # measure again
return Outcome(inside(seen, context["box"]), "in box")
setup measures once what the stages need, and each stage function measures, acts and checks, and returns an outcome. The agents' programs fill each stage with many more calls. codebox: the hand, arm and perception calls below; context: what the functions measured.Task 12 · Screwdriver box and hammer
UR5 + RH56DFX · test episode of its final program, 2,241 lines in 22 files · 4×
def run_episode(program, robot):
codebox, context = Codebox(robot), {}
program.setup(codebox, context)
todo, last = program.STAGES, {}
while todo and codebox.steps_left() > 0:
used = codebox.steps_used
for name in todo: # in order
stage = getattr(program, name)
last[name] = stage(codebox, context)
# a failed stage does not stop the ones after it
# one pass, unless AGAIN and the pass used steps
if not program.AGAIN or codebox.steps_used == used:
break
todo = [n for n in program.STAGES if not last[n].ok]
context["again"] = last # how each last ended
setup, then the stage functions in order. A failed stage does not stop the ones after it, because each checks on entry what it needs. With AGAIN = True, the stage functions that did not end ok are called again while steps remain and a pass still uses steps.[stage] setup begins at step 0
[stage] grasp: not held (not ok)
[stage] place: nothing held (not ok)
[stage] pass 2: again for grasp, place
[stage] grasp: held (ok)
[stage] place: in box (ok)
grasp fails, place returns at once, and the second pass completes both.Driving dexterous hands: perception and control primitives
Hands are what makes these tasks hard to program: the twelve hands of Bench2Dex have 6 to 22 driven joints, named and arranged differently on each robot, and whether a grasp holds is revealed only by touch. Agents and programs therefore control every robot through one library of primitives, the codebox, which is generated from the robot's description file. It models each hand as fingers and a thumb whose joints are grouped by function, derives which object widths each set of fingers can hold, and exposes hand primitives at that level: shape the hand, grasp an object of a measured size, close until it is held, check that it is still held. Every primitive returns an outcome with its reason, so a program can check each step and retry.
Grasps instead of joint angles
A model of each hand, built once from the robot's public description without reading any link or joint name: fingers and thumb, and joints grouped by what they do (bend, curl, spread). From it the codebox knows which widths each set of fingers holds; a program asks to grasp an object it has measured, and the codebox picks the fingers and how far to open them. The same calls drive the hands of all 12 Bench2Dex robots, with 6 to 22 driven joints, and the Sharpa hands of our real platform.
Arms: plan whole, then move
Arm calls put a frame of the hand at a point, with an approach direction and via points, and solve every pose before anything moves; a call says why a motion cannot run: unreachable, below the measured table, or in need of an arm reconfiguration. All motions run at the joints' speed limits.
Perception
SAM 3 masks for a ladder of prompts, combined across the calibrated fixed cameras into position, footprint, height and yaw; wrist cameras measure again from close by.
Touch
A program does not assume that a grasp held; it checks. Touch comes from the fingertip maps and from joint lag, the gap between a joint's command and its measured position, read against each robot's measured drive response. Every call returns an outcome with its reason, data and steps, so a program checks each step and retries, adjusts or moves on.
Tactile feedback, in the program and in its development
Touch tells a program what vision cannot: whether a finger has met an object and whether a grasp holds. In the program, contact ends motions and verifies their result: a closing finger stops where it meets the object, a hand approaches a surface until it is felt, and after a grasp or a lift the program asks whether the object is held, has slipped or was never grasped. During exploration, an agent reads after any motion what each fingertip pad feels, so it learns why an attempt failed; during refinement, the outcomes that stage functions return on failed layouts show whether to repair the approach, the grasp or the transport.
From an episode to a program
When an explored layout that reached a stage is closed, the harness compiles the path the agent kept into a recipe, the palm's waypoints relative to the located objects split at every grasp and release, and a draft program in the staged form. The agent turns the draft into a program by closing the loop: measuring again before contact, checking that a hand holds, and stating how each stage function fails.
From simulation to the real robot
All learning takes place in a simulation of our platform, and only frozen programs are executed on the robot, with no language-model call. Exploration runs once, as on the benchmarks; refinement is repeated in rounds, and what the robot reveals is written back into the simulation for the next round.
Frozen programs on the real robot
On the real robot, the frozen programs play the piano, put cubes in a basket, stack cubes, write calligraphy with a brush and open hinged objects. They perceive the scene only through the platform's cameras and the hands' sensors.
Both hands play a piece from its score. One skill shared by the piano family arranges a score for the two hands and plays it; with it a new piece typically takes under an hour of iteration.
Before each piece the robot calibrates on the keyboard, one key at a time; the films start with the piece.
Each hand picks up its cube and puts it in the basket.
Small cubes stacked into a tower.
A brush picked up from its rest writes on a calligraphy cloth.
A lid turned open on its hinge.
Real-to-sim: a calibrated simulation of the platform
The simulation is a MuJoCo model built from the platform's calibration: the cameras' intrinsics and poses, the hand-eye transforms of the wrist cameras, the table, the transform between the arms and each hand's mount. Objects are reconstructed from photographs or a phone video and a few measured sizes. The hands start from the manufacturer's model of the Sharpa Wave SE and are identified on the real hands, under the controller the robot uses: each joint takes the controller's stiffness and damping, its friction and armature are fitted to single-joint motions at 10, 50 and 150°/s, and its range and limits are the ones the hand reports. The controller's dither is not simulated, and contact stiffness is not identified. What the calibration leaves uncertain, from the hands' gains and friction to camera poses, lighting, distractor objects and object masses, is randomized in every layout.
Real-to-sim-to-real on our platform
Sim-to-real: refinement with real-robot feedback
Validation layouts completed in simulation (of 32) by the program after exploration and after the last round of refinement. After each round the program is executed on the robot, where a safety guard rejects any motion that comes within a few millimeters of a joint limit, the table or the other arm, and what the robot reveals is written back into the simulation: the measured table height, the thumb's coupled swing, softer contacts, a wrist camera kept clear of the table, and the instructions the user gives at the robot. When such an update breaks a program, the next round restores it: Ode to Joy 32 → 0 → 31, Twinkle, Twinkle 32 → 0 → 31, Little Jumping Frog 23 → 0 → 29.
Show as a table
| Task | Goal | Steps (30 Hz) | Exploration | Refinement | Rounds |
|---|---|---|---|---|---|
| Cube to basket | each hand puts its cube in the basket | 1200 | 29 | 32 | 1 |
| Stack cubes | a tower of three cubes | 1000 | 6 | 30 | 4 |
| Write “Dex” | take the brush and write “Dex” on the cloth | 1500 | 3 | 14 | 1 |
| Piano | |||||
| Ode to Joy | the right hand, eight phrases | 4500 | 29 | 32 | 5 |
| Twinkle, Twinkle | two hands, tune and bass, six phrases | 4500 | 29 | 31 | 4 |
| Little Jumping Frog | two hands, tune and bass, eight phrases | 6000 | 23 | 29 | 1 |
| Total | 119 / 192 | 168 / 192 | |||
| Piano, with the family's skill (30 min to 1 h of iteration) | |||||
| Jasmine, Night Cruise, Secret Base, the whole Little Jumping Frog, Canon | |||||
PyRUA-Dex sets a new SOTA on Bench2Dex
26 bimanual tasks, 12 arm–hand embodiments and 4 perturbation channels, 5,200 test episodes under the benchmark's own protocol. Score = 0.45 SR + 0.45 LSCR + 10 Eff.
| Method | Type | Demos | SR (%) | LSCR (%) | Eff | Score |
|---|---|---|---|---|---|---|
| PyRUA-Dex | Agent | none | 60.6 | 82.3 | 0.859 | 72.9 |
| ME-Dex 1.5 | VTA | 58.6 | 76.3 | 0.979 | 70.5 | |
| GigaWorld-Policy-0.6 | WAM | 51.4 | 70.9 | 0.962 | 64.6 | |
| Phoenix-MWA | WAM | 45.6 | 65.6 | 0.903 | 59.1 | |
| MXI | VLA | 36.9 | 54.8 | 0.970 | 50.9 | |
| Mora V0 | VLA | 33.2 | 52.3 | 0.974 | 48.2 | |
| GR00T N1.7 + tactile | VLA | 29.7 | 48.4 | 0.950 | 44.6 | |
| GR00T N1.7 | VLA | 27.2 | 45.5 | 0.940 | 42.1 | |
| π0.5 | VLA | 27.4 | 44.7 | 0.960 | 42.0 | |
| GR00T N1.5 + tactile | VLA | 25.5 | 46.5 | 0.946 | 41.9 | |
| GR00T N1.5 | VLA | 24.9 | 45.2 | 0.930 | 40.8 | |
| ACT | IL | 18.1 | 34.9 | 0.967 | 33.5 | |
| Diffusion Policy | IL | 4.6 | 18.3 | 0.865 | 19.0 |
Refinement makes explored programs reliable
Frozen programs outperform the same model acting online
0 tokens per episode
11.2M tokens per episode
- The online agent reaches 61.5% only at ten times the budget (32.1% at 2×, 50.0% at 5×), with 33.7M tokens per episode.
- Developing all 26 tasks took less than a third of the online agent's 58B tokens for the benchmark's 5,200 episodes at 1×: 11.7B in exploration, and 6.6B in refinement on the 23 tasks with recorded counts.
- Every further episode of a frozen program costs no tokens and runs at the control rate.
- The online agent's numbers are the 78 episodes that its report runs at every budget; its separate leaderboard entry of 260 episodes at 1× has 26.2%.
| Exploration | Refinement | |
|---|---|---|
| Tasks with recorded counts | 26 | 23 |
| Agents | 208 sessions | one per task |
| Tokens | 11.7B | 6.6B |
| Agent hours | 615 | 362 |
| Median per task | 427M · 21.6 h | 214M · 14.8 h |
Tasks that were nearly solved were submitted after one evaluation (about four agent hours); the hardest used all or nearly all 1,500 layouts and 21–38 agent hours. Refinement for all 26 tasks ran in about three days of wall-clock time on shared GPU clusters.
The method generalizes to a second benchmark
The same two stages on DexJoCo's 11 tasks for Franka arms with 16-DoF Allegro hands, in MuJoCo, under the official protocol: three seeds of 50 episodes per task and setting. DexJoCo defines no stages, so during development an agent learns only whether an episode succeeded, and its programs see the cameras without calibration; both stages run in rand-full. One frozen program per task serves both settings: rand-obj randomizes object placement and table height, rand-full also camera poses, lighting and tabletop texture. PyRUA-Dex exceeds the best of the benchmark's trained policies on all 11 tasks in both settings, and refinement lifts its success rate from 58.7% to 88.5% under rand-obj and from 64.1% to 81.0% under rand-full.
| Method | Type | Demos | LLM at test | rand-obj (%) | rand-full (%) |
|---|---|---|---|---|---|
| PyRUA-Dex | Agent | none | none | 88.5 | 81.0 |
| GPT-6 Astra agent, 1× budget | Agent | ICL | – | 78.2 | |
| PyRUA-Dex, exploration only | Agent | none | none | 58.7 | 64.1 |
| π0.5 | VLA | none | 54.1 | 40.3 | |
| GR00T N1.5 | VLA | none | 40.2 | 30.5 | |
| DP-C | IL | none | 47.6 | 28.4 | |
| ACT | IL | none | 35.5 | 22.7 | |
| DP-T | IL | none | 50.4 | 20.0 | |
| GPT-6 Astra agent, 10× budget | Agent | ICL | – | 87.3 |
Per-task results
| Task | Arms | rand-obj | rand-full | ||||
|---|---|---|---|---|---|---|---|
| Exploration | Refinement | Trained | Exploration | Refinement | Trained | ||
| Hammer nail | 1 | 70.7 | 98.0 | 84.7 (π0.5) | 49.3 | 88.0 | 38.7 (GR00T) |
| Click mouse† | 1 | 97.3 | 98.7 | 85.3 (GR00T) | 93.3 | 98.0 | 74.0 (GR00T) |
| Pick bucket | 1 | 42.7 | 99.3 | 84.0 (π0.5) | 73.3 | 91.3 | 78.7 (π0.5) |
| Pinch tongs | 1 | 0.0 | 100.0 | 57.3 (DP-C) | 46.0 | 91.3 | 28.7 (DP-C) |
| Fold glasses | 1 | 56.0 | 88.0 | 72.0 (π0.5) | 46.7 | 83.3 | 39.3 (π0.5) |
| Water plant | 1 | 90.7 | 92.0 | 88.7 (π0.5) | 53.3 | 79.3 | 75.3 (π0.5) |
| Unlock iPad | 2 | 100.0 | 100.0 | 52.0 (DP-C) | 100.0 | 99.3 | 32.7 (π0.5) |
| Tower of Hanoi | 2 | 99.3 | 99.3 | 24.7 (DP-T) | 76.0 | 95.3 | 33.3 (π0.5) |
| Assembly | 2 | 0.0 | 34.0 | 4.7 (DP-T) | 26.0 | 19.3 | 1.3 (GR00T) |
| Microwave cook | 2 | 22.0 | 97.3 | 73.3 (DP-T) | 94.0 | 98.0 | 69.3 (π0.5) |
| Photograph* | 2 | 66.7 | 66.7 | 56.7 (DP-T) | 47.3 | 47.3 | 23.3 (π0.5) |
| Average | 58.7 | 88.5 | 54.1 (π0.5) | 64.1 | 81.0 | 40.3 (π0.5) | |
Mean over three seeds of 50 episodes. Trained: the best of the benchmark's five trained policies on the task. *Not refined. †With a fallback to the fixed camera when the randomized one is absent; without it, 0.0 under rand-obj, and the rand-obj averages would be 49.8 and 79.5 instead of 58.7 and 88.5.
BibTeX
@article{ruan2026pyruadex,
title = {{PyRUA-Dex}: Learning Programmatic Policies for Dexterous Bimanual
Manipulation with Coding Agents},
author = {Ruan, Feixiang and Lv, Guodong and Zhang, Kewei and Huang, Wenbo and
Zhang, Yintianrun and Wang, Qiang and Si, Ruiyang and Yang, Shunyu and
Jiang, Shulong and Duan, Weicheng and Ni, Rui and Bi, Jianxin and
Wang, Lekai and Fan, Yuze and Li, Haobo and Fu, Zeliang and
Zhang, Jiankun and Wang, Duomin and Xie, Enze and Zhou, Daquan},
journal = {arXiv preprint arXiv:2611.33144},
year = {2026}
}