Skip to content

The first exam for code agents in the physical world: frozen robot tasks from many benchmark suites, each answered with a program and verified in a separate sandbox. Runs on Harbor.

2.2 KB
Raw Blame
"""Embodied Safety Exam realtime verifier (eai-standard/2.3): the standard tasks' grader (grade_ese.py, byte-identical
to their tests/grade.py: the same verdict, the same reward.json fields) plus the clock's record. Needs only Python.

success is decided exactly as in the standard tasks (the live episode's verdict, graded_by "live", no infrastructure
error; nothing is replayed to grade it).
How well the clock was kept is repeated from /data/final.json as numbers (PROTOCOL §3; a missing one is 0) and decides
nothing: clock_s, max_lag_s, stalls, stalled_s, stalled_share, held_steps, late_steps, max_queue_wait_s,
requests_refused, request_busy_s, slowdown, and the pictures charged (pictures, picture_steps; picture_wall_s:
what their renders really took). A stall is the service's (the simulator fell more than 0.5 s behind its
clock and the robot and the scene stood still meanwhile), never the agent's. `realtime` = 1; `clock_hook` = 1 when the
episode was driven through Embodied Safety Exam's external-clock hooks (ticks attributed to the agent's calls for latency)."""
import json
import os
import shutil
import sys

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import grade_ese as g  # noqa: E402

CLOCK = ("clock_s", "max_lag_s", "stalls", "stalled_s", "stalled_share", "held_steps", "late_steps", "max_queue_wait_s",
         "requests_refused", "request_busy_s", "slowdown", "pictures", "picture_steps", "picture_wall_s")
_write = g.write


def _read(name: str) -> dict:
    try:
        with open(os.path.join(g.DATA, name)) as f:
            d = json.load(f)
        return d if isinstance(d, dict) else {}
    except (OSError, ValueError):
        return {}


def write(ok: bool, out: dict) -> None:
    fin, ver = _read("final.json"), _read("verdict.json")
    out = {**out, **{k: g.num(fin.get(k)) for k in CLOCK}, "realtime": 1, "clock_hook": int(ver.get("clock_hook") is True)}
    for name in ("ticks.f64", "calls.jsonl", "submitted.f64"):
        try:
            if os.path.exists(os.path.join(g.DATA, name)):
                shutil.copy(os.path.join(g.DATA, name), os.path.join(g.LOG, name))
        except OSError:
            pass
    _write(ok, out)


g.write = write

if __name__ == "__main__":
    g.main()