15 minutes · Laptop only · Zero GPU · Zero API keys

By the end of this walkthrough you will have run frozen policy code, read the program contract, watched a triggered Semi-online rescue, evolved a program under the 4-part selection gate, and chosen the right harness recipe for your own robot.

Overview of the Policy-Harness Study
Overview of the Policy-Harness Study

#Step 1. Install and inspect your environment (2 min)

bash
pip install -e .
xharness wizard
xharness list
xharness doctor

xharness wizard walks through benchmark preflight checks, maps your robot setup to a concrete harness recipe (policy use, code form, run-time tier), and prints ready-to-run commands (pass --write-starter my_program.py to scaffold a clean starter file, or --non-interactive in scripts). xharness list prints all 10 registered benchmarks and their status. Only mock is Verified (CPU): it is a pure-NumPy tabletop sandbox (a point gripper over a table, one calibrated RGB-D camera, and a scripted reaching policy standing in for a VLA). Everything in this guide runs on mock; xharness doctor tells you what optional packages or external simulators are needed for the other suites.


#Step 2. Base policy alone vs. frozen policy code (3 min)

bash
xharness run --program programs/mock/button_unmask_swap/policy_alone.py
xharness run --program programs/mock/button_unmask_swap/reference.py \
  --replay replay.html

What is happening: in button_unmask_swap, a cube is visible on frame 0, then two identical covers hide both slots and swap positions. Success requires closing the gripper over the cover hiding the cube.

  • policy_alone.py delegates blindly to the reactive base policy, which cannot remember frame 0 and solves 0 / 10.
  • reference.py adds ~30 lines of stateful policy code that remember the initial detection and track the swap—solving 10 / 10 with 0 test-time model calls.
  • --replay replay.html exports a self-contained single-file HTML viewer (camera frames, TCP state, actions, outcomes, and Semi-online rescue markers) using only Python's standard library + NumPy. Open replay.html in your browser to scrub step-by-step.

Open programs/mock/button_unmask_swap/reference.py : that single file captures the core idea of a policy harness.

NOTE

Train vs. test split protection: the commands above run training seeds. Running held-out test seeds requires an explicit flag and automatically appends to an audit log (test_access.jsonl):

bash
xharness run --program programs/mock/button_unmask_swap/reference.py \
  --split test --allow-test

#Step 3. Understand the 3-method contract (2 min)

X-Harness architecture schematic
X-Harness architecture schematic

Every policy program—whether hand-written or generated by a VLM—implements the exact same class (x_harness/program/contract.py ):

python
class Program:
    def set_task(self, instruction, obs, vision):   # called once at episode start
        ...
    def get_action(self):                           # returns {"control": ..., ...}
        ...
    def update_step(self, outcome, obs, vision):    # called after every action
        ...
  • obs: obs["cameras"]["front"] carries rgb, depth (int16 millimetres, 0 = unknown), K, and T_w2c; obs["tcp"] gives gripper pose and opening.
  • vision: vision.get_scene_graph(rgb, depth, K, T_w2c, ["red cube"]) returns 3D object coordinates (xyz) in the action frame; vision.detect(image, text) returns [row0, col0, row1, col1] boxes; vision.track, vision.analyze_demo_video, and vision.depth expose point tracking, demo-video analysis, and monocular depth when backed by the perception server.
  • Controls on mock: move, gripper (+1 open, -1 closed), policy (runs the base policy for steps under your instruction), hold, and done.
TIP

Try breaking it on purpose: add import os to a copy of a program and run it—ProgramHost rejects it during static auditing before a single line executes. Return {"control": "fly"}—the action contract catches it cleanly and reports program_error.


#Step 4. Watch a Semi-online rescue (2 min)

bash
python examples/01_quickstart.py

Part 2 intentionally runs a buggy program on pick_cube that grasps too high:

  • Offline tier: fails 0 / 5.
  • Semi-online tier: the watchdog detects that the gripper lifted empty (empty_jaw) and hands control to a VLM for a few observation-grounded turns—recovering to 5 / 5.

The example uses ScriptedVLM so no API key is required; pass xh.make_vlm(...) to plug in a live cloud or local model.


#Step 5. Evolve a program under the selection gate (3 min)

bash
python examples/03_evolve_and_toolbank.py

Watch the 4-part selection gate in action across four candidate revisions:

  1. A candidate that solves more episodes overall—but breaks 4 previously solved training episodes—is rejected (the bound is at most 2 regressions).
  2. Its diff and regression report are fed back into the next round.
  3. A candidate that raises training successes with ≤ 2 regressions is accepted.

To run real evolution with any cloud or local OpenAI-compatible VLM:

bash
# Or OPENAI_API_KEY, GEMINI_API_KEY, or OPENAI_BASE_URL for local vLLM
export ANTHROPIC_API_KEY=...
xharness evolve --benchmark mock --task pick_cube \
  --vlm-model <model-id> --vlm-effort high --cache replies.jsonl \
  --out programs/mock/pick_cube/<model>.py

--cache replies.jsonl hashes every prompt and caches replies locally, making interrupted runs free to resume.


#Step 6. Which harness recipe fits your robot?

Decision Guide Matches xh.recommend_tier(...) and xharness wizard
1. Base VLA

Strong VLA & in-distribution?

Yes: Run the minimal policy_alone wrapper to preserve peak trained accuracy (97.2% on LIBERO Std).

Shift / memory: Write stateful policy code delegating 2D-marked sub-goals to the VLA.

No VLA: Use RGB-D perception tools + 3D motion primitives.

2. Code Form

Match structure to your VLM

Frontier VLM (Opus / Sonnet): Keep --form freeform Python.

Lighter / local VLM (Flash / edge): Switch to a structured template (bt, coro, or rules) for +7.6 pp lift.

3. Pre-Test Evolution

4–8 gated rounds on train seeds

Run EvolutionLoop under SelectionGate(max_regressions=2) on training seeds only, then freeze with SHA pinning for 0 test-time VLM calls.

4. Run-Time Tier

Residual failures left?

No: Deploy Offline frozen code at native 16.7–25 Hz.

Yes: Enable Semi-online bounded rescue (Rescue watchdog, ≤24 turns only on physical faults).

Your situationRecommended starting point
Strong VLA on in-distribution tasksStart with the policy-alone wrapper (EvolutionLoop also tests it automatically as a baseline).
VLA struggles on memory, multi-step logic, or shifted layoutsAdd closed-loop policy code that keeps state and sends sub-goals via policy actions.
No VLA available for your robotUse perception tools (vision.get_scene_graph) + 3D motion primitives (move, pick, place) with accurate depth.
Training episodes available (10–40 / task)Run 4–8 gated evolution rounds (SelectionGate), then freeze for 0-overhead Offline execution.
Residual failures remain after evolutionTurn on the Semi-online tier (Rescue) so a VLM steps in only when a watchdog/rule trigger fires.
Smaller or weaker code-writing VLMSwitch --form from freeform to a structured template (rules, bt, coro, pddl, or rekep).

You can call xh.recommend_tier(...) for the exact same decision logic in Python.


#Step 7. Connect your own simulator or robot


#Step 8. Three rules to keep in mind

WARNING
  1. Never conflate infrastructure faults with policy failures. Setup, server, or simulator crashes raise InfrastructureError and stop the run—never swallow them into a 0% policy score.
  2. Keep training and test splits strictly separate. Evolve and tune only on training seeds; inspect test_access.jsonl before reporting test metrics.
  3. Treat ProgramHost as a guardrail, not an OS sandbox. Always isolate untrusted code in a container.