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 |
|---|---|---|
|
- |
JSON |
|
JSON |
JSON |
|
NPZ ( |
JSON |
--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 |
|---|---|---|
|
string |
the task’s registry name |
|
string |
|
|
list of strings |
robot config names, in order |
|
int |
parallel env slots; every batch below has this many rows |
|
int |
the protocol’s base seed |
|
int |
the cap the evaluator applies |
|
|
the action order, per robot, concatenated into one row |
|
lists of floats, length |
the action box (joint limits in action order, radians and metres) and the “hold” action |
|
|
the robots’ default pose |
|
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) |
|
object or null |
the tier ( |
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 |
|---|---|---|---|
|
float32 |
|
radians (metres for prismatic joints), the robot’s joint order ( |
|
float32 |
|
rad/s or m/s |
|
float32 |
|
|
|
float32 |
|
the same per body, when the backend provides it |
|
float32 |
|
the last commanded targets, when the backend provides them |
|
float32 |
as above |
|
|
uint8 |
|
RGB, 0..255 |
|
float32 |
|
metres; |
|
float32 |
|
camera pose in the world frame (quat wxyz), when the backend provides it |
|
float32 |
|
pinhole intrinsics, when provided |
|
- |
- |
|
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 |
the episodes in flight end as time-outs with |
takes longer than |
the same; the request is never replayed (the server may already have acted) |
fails |
the run aborts with the last error; no result file is written (the partial |
is unreachable at the handshake, speaks another protocol, or mismatches |
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
resetoractat a time.--obs-key robots --obs-key cameras/front/rgbkeeps 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 --checkpointhashes them into/metadata; a model fetched from a hub reportsmodelandmodel_revisionthrough the policy’smetadatadict. The leaderboard requires one or the other for a learned policy.