Seven things you can add, each with the smallest working example. Step-by-step versions for coding agents are in AGENT_HANDOFF.md.

#1. A base policy

python
import numpy as np
import x_harness as xh

def my_policy(obs, instruction):
    state = np.asarray(obs["state"])            # what the benchmark gives its policy
    return [0.0, 0.0, -0.01, 1.0]               # one action row, in the benchmark's convention

benchmark = xh.make_benchmark("mock", policy=my_policy)

Anything with predict(obs, instruction) works, and so does a server address. Runnable: examples/02_custom_policy_tool.py.

#2. A tool

python
@xh.register_tool(category="geometry")
def nearest_object(objects, xyz):
    "The object of a scene graph nearest to a point [x, y, z], or None for an empty list."
    if not objects:
        return None
    return min(objects, key=lambda o: sum((a - b) ** 2 for a, b in zip(o["xyz"], xyz)))

Policy code calls vision.nearest_object(...); the model sees the function's signature and first docstring paragraph in its prompt. Keep tools pure: inputs in, result out, no simulator state.

#3. A benchmark

bash
cp -r x_harness/benchmarks/_template x_harness/benchmarks/my_bench
FileEdit
tasks.pyyour tasks, TRAIN_SEEDS, TEST_SEEDS
contract.pyyour controls, bounds and caps in an ActionContract
env.pyobserve, execute, over, success, diagnostics around your simulator
__init__.pythe BenchmarkSpec (with an honest status) and make
python
xh.register_benchmark("my_bench", "x_harness.benchmarks.my_bench:make", "x_harness.benchmarks.my_bench:SPEC")

Three rules: check the action with the contract before the simulator sees it; raise InfrastructureError when the simulator itself fails; import the simulator only in env.py. A complete one-file benchmark: examples/05_new_benchmark_demo.py.

#4. A model

python
vlm = xh.make_vlm("local", model="my-served-model")       # any OpenAI-compatible server: vLLM, SGLang, Ollama
vlm = xh.CachedVLM(vlm, "replies.jsonl")                  # optional: repeated requests cost nothing

For another API, subclass VLMClient in x_harness/harness/vlm.py: build one request (request) and read one reply (parse); retries, image limits and timing come with the base class.

#5. A code form

The five structured forms are interpreters with the three contract methods. To add one: a GUIDE text for the model, an interpreter class built from the program's namespace, and an entry in INTERPRETERS (x_harness/program/forms.py). Run a program in a form with ProgramHost(source, form="rules") or xharness run --form rules.

#6. Rescue thresholds and triggers

python
from x_harness.harness.rescue import Rescue, Thresholds

mine = Thresholds(stagnation_steps=150, empty_jaw=0.004, noprog_grip=0.02)      # your robot's readings
rescue = Rescue(vlm, thresholds=mine, arms_of=my_state_adapter, mode="full_watchdog")

arms_of(obs) returns {arm: (x, y, z, gripper_reading)}. For a robot without Cartesian state, subclass Watchdog and judge stillness in your own space, as real_yam/runtime.py: JointWatchdog does with joint encoders.

#7. The selection gate

python
from x_harness.harness.evolution import EvolutionLoop, SelectionGate

loop = EvolutionLoop(benchmark, task, vlm, gate=SelectionGate(max_regressions=0))      # stricter
loop = EvolutionLoop(benchmark, task, vlm, gate=SelectionGate(ungated=True))           # the ablation

To evolve something other than the program, pass make_host: examples/03_evolve_and_toolbank.py evolves a tool bank around a frozen program this way.

#Before you send a change

bash
pytest -q
python scripts/render_tables.py --check

CONTRIBUTING.md has the checklist.