Policy server protocol#

A policy that lives in another process, environment or machine is scored over HTTP: python -m metasim bench serve wraps it, bench run --policy-url drives it. The wire protocol is roboverse.bench.remote/1 (plain HTTP, JSON and NumPy NPZ, no pickle), so a server can be written in any language. This page is the contract: what a policy receives, what it returns, and what happens when it fails. python -m metasim bench conformance --policy-url <url> --robot franka exercises every part of it without a simulator.

Routes#

route

request

reply

GET /metadata

-

JSON {"protocol": "roboverse.bench.remote/1", "name": ..., "features": [...], ...}; every other field (checkpoint, checkpoint_sha256, model, model_revision, family) is copied into the result’s policy record. features lists the optional parts the server implements ("usage", "auth"); a client needs none of them.

POST /reset

JSON {"context": {...}, "env_ids": [...], "instances": [...]}

JSON {"ok": true}

POST /act

NPZ (application/octet-stream), see below

JSON {"actions": ..., "usage": {...}}

--require-metadata key=value on the client makes a mismatch in /metadata fail before the first episode. With a token (bench serve --token, RemotePolicy(token=...), or ROBOVERSE_BENCH_TOKEN on either side) every request carries Authorization: Bearer <token> and a request without it is answered 401.

The context (/reset)#

context is the PolicyContext the evaluator built, without extras (the simulator’s scenario does not cross the wire; a policy that needs the robot config looks it up by name, metasim.utils.setup_util.get_robot):

field

type

meaning

task

string

the task’s registry name

simulator

string

mujoco, isaacsim, …

robots

list of strings

robot config names, in order

num_envs

int

parallel env slots; every batch below has this many rows

seed

int

the protocol’s base seed

max_episode_steps

int

the cap the evaluator applies

action_joint_names

{robot: [joint, ...]}

the action order, per robot, concatenated into one row

action_low, action_high, default_action

lists of floats, length action_dim

the action box (joint limits in action order, radians and metres) and the “hold” action

default_joint_positions

{robot: {joint: float}}

the robots’ default pose

instruction

string or null

the task’s canonical instruction (null under a train or held-out prompt split: the instruction is then per episode, in the instance)

access

object or null

the tier (metasim.bench.AccessProfile.to_dict()); null means privileged

instances has one object per starting env: index, seed, instance_id, prompt, prompt_variant. Below the privileged tier the index is an opaque per-run handle and seed and hash are blank: the pool is the task’s public demo file, so a real index would be a lookup key for the hidden initial state. The result still records the real instance.

The observation (/act)#

Every array leaf of the observation is one NPZ entry under obs/<path>, plus prompt (one string per env, "" for none), request (a counter) and task. Paths follow metasim.types.TensorState; the client sends only what the tier allows and what --obs-key keeps. Shapes are per batch (N = num_envs):

path

dtype

shape

unit / frame

obs/robots/<robot>/joint_pos

float32

(N, J)

radians (metres for prismatic joints), the robot’s joint order (action_joint_names when the robot’s action is its joints)

obs/robots/<robot>/joint_vel

float32

(N, J)

rad/s or m/s

obs/robots/<robot>/root_state

float32

(N, 13)

[pos xyz (m), quat wxyz, lin_vel xyz (m/s), ang_vel xyz (rad/s)] in the world frame

obs/robots/<robot>/body_state

float32

(N, B, 13)

the same per body, when the backend provides it

obs/robots/<robot>/joint_pos_target, joint_vel_target, joint_effort_target

float32

(N, J)

the last commanded targets, when the backend provides them

obs/objects/<object>/root_state, body_state, joint_pos, joint_vel

float32

as above

privileged only: never sent below it

obs/cameras/<camera>/rgb

uint8

(N, H, W, 3)

RGB, 0..255

obs/cameras/<camera>/depth

float32

(N, H, W)

metres; visual-depth and privileged only

obs/cameras/<camera>/pos, quat_world

float32

(N, 3), (N, 4)

camera pose in the world frame (quat wxyz), when the backend provides it

obs/cameras/<camera>/intrinsics

float32

(N, 3, 3)

pinhole intrinsics, when provided

obs/extras/...

-

-

privileged only

Segmentation masks (instance_seg, instance_id_seg) are sent under privileged only. Half-precision tensors arrive as float32. Lists of names (body_names) are not arrays and are not sent. On the server a PolicyServer rebuilds the tree as nested mappings with attribute access (obs.robots["franka"].joint_pos), so a policy written against TensorState runs unchanged as long as it reads tensors only.

The action (/act reply)#

actions is a nested list of finite numbers of shape (N, action_dim), or (N, horizon, action_dim) for an action chunk, in the order of action_joint_names (joint position targets, radians and metres) when the task’s actions are its joints, or the task’s own normalised box otherwise (the context’s action_low / action_high say which). The simulator clips to the box. The client executes each env’s chunk step by step and asks for a new batch only for the envs whose chunk ran out, so a chunked policy behaves per env exactly as with num_envs=1. A policy that keeps per-env state keys it by env id; /reset names the envs that start.

usage is optional: {"llm_calls": n, "llm_tokens": n, "tool_calls": n} with the counts since the previous reply (the client sums them; the result records them as usage_source: "self-reported"). The agent tiers’ budgets are judged on these.

Failures#

what the server does

what the evaluator does

answers 5xx, or a 200 whose body is not {"actions": ...} of the right shape, or non-finite numbers

the episodes in flight end as time-outs with policy_error set ("PolicyError: policy server POST .../act answered 500: ..."), scored by the success rule over the steps taken; the run goes on

takes longer than --policy-timeout (default 180 s), or the connection drops mid-request

the same; the request is never replayed (the server may already have acted)

fails --max-policy-errors times in a row (default 3)

the run aborts with the last error; no result file is written (the partial <out>.episodes.jsonl remains)

is unreachable at the handshake, speaks another protocol, or mismatches --require-metadata

the run does not start

A failed episode is the policy’s loss, not the harness’s: an unstable model loses the episodes it crashed on instead of leaving the run without a number. notes.policy_errors counts them.

Limits and good practice#

  • The server reads at most 1 GiB per request and drops a client that stalls for 30 s; it serves connections on threads but calls the policy under one lock, one reset or act at a time.

  • --obs-key robots --obs-key cameras/front/rgb keeps the payload to what the policy reads (a 480p RGB batch is about 0.9 MB per env per request uncompressed).

  • Bind to 127.0.0.1 (the default) unless the evaluator is on another machine; then set a token.

  • Report the weights: bench serve --checkpoint hashes them into /metadata; a model fetched from a hub reports model and model_revision through the policy’s metadata dict. The leaderboard requires one or the other for a learned policy.