|
Download README.md from HuggingFaceSwarms/s3-maze: direct link, hf CLI and curl.
- Browser
- Download file 15.8 kB
-
https://huggingface.co/datasets/HuggingFaceSwarms/s3-maze/resolve/refs%2Fpr%2F1/README.md
- Command line
-
hf download hf://datasets/HuggingFaceSwarms/s3-maze@refs/pr/1/README.md
-
curl -L -o README.md https://huggingface.co/datasets/HuggingFaceSwarms/s3-maze/resolve/refs%2Fpr%2F1/README.md
15.8 kB
| pretty_name: s3-maze | |
| license: apache-2.0 | |
| language: | |
| - en | |
| tags: | |
| - harbor | |
| - agent-environment | |
| - multi-agent | |
| - message-board | |
| size_categories: | |
| - n<1K | |
| # s3-maze | |
| A [Harbor](https://harborframework.com) environment that measures whether a swarm of agents | |
| **communicates when it pays off**: any agent can find the exit alone, but the maze is too large | |
| for one agent's move budget, so sharing what each one has explored lets a team search it in | |
| time. It adapts the parallel-exploration task of | |
| [s³: Simple Scaling of Swarms via Cooperative Multi-agent RL](https://arxiv.org/abs/2611.08615). | |
| The companion [s3-aggregation](https://huggingface.co/datasets/HuggingFaceSwarms/s3-aggregation) | |
| requires communication to obtain the teammates' private numbers. | |
| ## The task | |
| Each agent explores its own copy of the same tree of rooms to find the exit. Everyone starts in | |
| the same room, with the same layout and the same door order; each agent's position is private, | |
| and moving never moves a teammate. The first agent to reach the exit wins for the team, and its | |
| arrival ends the run. The agent's shell has the `maze` command: | |
| ```sh | |
| maze look # the current room, without moving | |
| maze move R5524 # walk through a door of the current room into the named adjacent room | |
| ``` | |
| Each prints the paper's observation (Appendix H), with the moves left: | |
| ```json | |
| {"room": "R4821", "doors": ["R1937", "R7550", "R3104", "R6612"], "exit": false, "arrived_from": "R1937", "moves_left": 187} | |
| ``` | |
| A dead end adds `"notice": "Dead end: its only door leads back the way you came."`. A move into a | |
| room that isn't one of the current room's doors is refused with an `error` (exit code 1) and | |
| costs nothing; so is any move once the budget is spent or the exit reached. Looking is free. | |
| | | | | |
| | --- | --- | | |
| | Trees | 32 (the paper's held-out set size), from a fixed seed: one task each, `maze-t01` .. `maze-t32`; N is the number of agents in the run | | |
| | Shape | as in the paper: branching 3, corridors of 10 rooms, depth 3: 391 rooms, 27 dead ends at the far ends of the deepest corridors, one of them the exit (chosen uniformly) | | |
| | Distances | the shortest path is 30 moves; a full depth-first search 780 | | |
| | Labels | random 4-digit numbers (`R1000` .. `R9999`); each room's door order is shuffled once, at generation | | |
| | Move budget | **210 moves per agent** (below) | | |
| | Containers | a compose stack per agent: its container (`main`, `python:3.13-slim` with the `maze` command) and its own `maze` service, which alone holds the tree | | |
| | Agent / verifier timeout | 3600 s / 120 s | | |
| | Resources | 1 CPU, 1 GB memory per agent; the service 256 MB | | |
| ```text | |
| tasks/maze-tNN/ | |
| instruction.md the task, the commands and the budget; no room is named | |
| task.toml the service's collect hook and artifacts; the grader runs apart | |
| environment/docker-compose.yaml main (the agent) and maze, on an internal network only main reaches | |
| environment/agent/ main's image: its Dockerfile and the `maze` command, nothing else | |
| environment/maze/ the service's image: tree.json (private), engine.py, service.py, | |
| success.py (exit status), export.py (the collect hook) | |
| tests/ the grader's own image: test.sh, grade.py, expected.json | |
| solution/solve.sh an oracle that walks the shortest path with `maze move` | |
| template/ the files every task shares (generate.py copies them) | |
| generate.py writes tasks/ from its seed (115) | |
| budget.py the move-budget table below, from the service's own engine | |
| check.py the checks that need no model | |
| ``` | |
| **The tree stays in the maze service.** The agent's container is built from | |
| `environment/agent/` alone (its Dockerfile and the `maze` command), and reaches the service | |
| only through its two routes, `GET /look` and `POST /move`; every other path and method gets a | |
| bare 404. So an agent learns a room's doors only by standing in it, and that a room is the exit | |
| only by reaching it. Each agent's Trial is its own compose project: its own service, position | |
| and budget. | |
| **The service logs every move**, accepted or refused, with the agent (its Trial), the room it | |
| was in, the room it asked for and the time, before it answers; its state file mirrors the walk. | |
| ## Reward and stop on success | |
| The grader runs in **its own container** (`[verifier] environment_mode = "separate"`, built | |
| from `tests/`), after the agent's container has stopped. Harbor first runs the service's collect | |
| hook (`export.py`, in the maze service), which writes the service's own record of the walk to | |
| `/evidence` (`final.json` and `moves.jsonl`); Harbor carries those files over, and they are the | |
| grader's only input besides `tests/expected.json`. Reward **1** needs all of: | |
| - the export is the service's, for this task's tree (its sha256), start room and budget; | |
| - the service says the exit was reached, and the walk ends in the exit; | |
| - the move log's accepted moves form one unbroken walk from the start to the exit, within the | |
| budget, and as many as the service counted. | |
| Anything else scores **0**, a missing, unreadable or malformed file included. Nothing the | |
| agent's container holds reaches the grader: the evidence comes from the service, which the | |
| agent can only ask for moves, and `tests/` never enters the agent's container. The grader is | |
| hardened as s3-aggregation's anyway: each file counts only as a regular file of its own at | |
| exactly its path (no link anywhere on the path is followed, a FIFO can't block it, a hardlink | |
| doesn't count), it writes 0 before it checks anything, never writes through a link, and its | |
| Python runs isolated (`python3 -I -S`). It keeps copies of `moves.jsonl` and `final.json` in | |
| `/logs/verifier/` for the metrics. | |
| **Exit status.** Run `python3 -I -S /app/success.py` in the maze service to read the exit state. | |
| It prints JSON with a `success` boolean and, when available, evidence with `exit_reached`, | |
| `moves` and `reached_at`. A team runner can use this signal to end the search before grading | |
| the Trials. | |
| ## The move budget | |
| Simulated with the service's own engine (`template/environment/maze/engine.py`: every move | |
| goes through the same `Walk` the service holds), without containers: | |
| `python budget.py` over the 32 trees, for N agents and a per-agent budget: | |
| - **(a)** one agent, depth-first: the first door it hasn't been through, in the listed order, | |
| and back when it has none left; | |
| - **(b)** best-of-N: N agents search independently, depth-first, each taking the first listed | |
| unexplored door half the time and a random one otherwise (its own habit); the team succeeds | |
| if any one gets out (200 draws per tree); | |
| - **(c)** a perfect split: the 27 dead ends, in (a)'s order, are cut into N runs as equal as | |
| possible, and each agent searches only the branches leading to its own run (it knows the | |
| tree's shape, which no real agent does). | |
| Success rate over the 32 trees (a success: the exit reached within the budget by at least one | |
| agent): | |
| | budget | (a) N=1 | (b) N=2 | (b) N=4 | (b) N=8 | (c) N=2 | (c) N=4 | (c) N=8 | | |
| |---:|---:|---:|---:|---:|---:|---:|---:| | |
| | 30 | 6% | 8% | 14% | 22% | 22% | 25% | 41% | | |
| | 60 | 12% | 14% | 23% | 34% | 28% | 44% | 66% | | |
| | 90 | 12% | 20% | 31% | 45% | 31% | 50% | 94% | | |
| | 120 | 16% | 26% | 40% | 56% | 34% | 59% | 97% | | |
| | 150 | 22% | 37% | 54% | 73% | 41% | 72% | 100% | | |
| | 180 | 22% | 37% | 54% | 73% | 47% | 78% | 100% | | |
| | **210** | **25%** | **45%** | **63%** | **81%** | **59%** | **100%** | **100%** | | |
| | 240 | 31% | 49% | 66% | 84% | 66% | 100% | 100% | | |
| | 300 | 31% | 53% | 71% | 88% | 78% | 100% | 100% | | |
| | 360 | 34% | 61% | 78% | 93% | 91% | 100% | 100% | | |
| | 450 | 62% | 78% | 92% | 99% | 100% | 100% | 100% | | |
| | 600 | 78% | 91% | 98% | 100% | 100% | 100% | 100% | | |
| | 750 | 100% | 100% | 100% | 100% | 100% | 100% | 100% | | |
| Every tree has the same shape (only the labels, the door order and the exit differ), so (a) | |
| and (c) for an exit chosen uniformly are exact with the exit on each of the 27 dead ends in | |
| turn (`python budget.py --exact`): | |
| | budget | (a) N=1 | (c) N=2 | (c) N=4 | (c) N=8 | | |
| |---:|---:|---:|---:|---:| | |
| | 30 | 4% | 7% | 15% | 30% | | |
| | 60 | 7% | 11% | 26% | 56% | | |
| | 90 | 11% | 22% | 41% | 85% | | |
| | 120 | 15% | 30% | 56% | 96% | | |
| | 150 | 22% | 37% | 78% | 100% | | |
| | 180 | 22% | 41% | 81% | 100% | | |
| | **210** | **30%** | **56%** | **100%** | **100%** | | |
| | 240 | 33% | 59% | 100% | 100% | | |
| | 300 | 37% | 74% | 100% | 100% | | |
| | 360 | 44% | 89% | 100% | 100% | | |
| | 450 | 59% | 100% | 100% | 100% | | |
| | 600 | 78% | 100% | 100% | 100% | | |
| | 750 | 100% | 100% | 100% | 100% | | |
| **210 moves** is the smallest budget at which a perfect four-way split always finds the exit, | |
| while one agent's search finds it 30% of the time (25% on these 32 trees): one agent can search | |
| 8 of the 27 dead ends, a team of 4 can search them all, and a team of 8 has 60 moves to spare. | |
| Independent agents land in between, and closer to (a) the more they follow the shared door | |
| order: agents that always take the first listed door all walk (a)'s path, so best-of-N is (a) | |
| at every N (`--habit 1`); at N = 4 and 210 moves, best-of-N is 25%, 46%, 63% and 75% with | |
| habits of 1, 0.8, 0.5 and 0 (`--habit 0`: independent random orders), and at N = 8 25%, 58%, | |
| 81% and 94%. The gap between (b) and | |
| (c) is what sharing explored branches can buy. The budget is in every task's tree, grader, | |
| instruction and `task.toml` (`move_budget`). | |
| ## Run a Harbor task | |
| The maze uses two containers per Trial, so use Docker or Podman. Validate the search and | |
| grader with Harbor's oracle: | |
| ```sh | |
| uv run --with harbor==0.25.0 harbor run --path tasks/maze-t01 --agent oracle --env docker | |
| ``` | |
| For a cooperative run, give each participant its own Trial of the same task and supply a | |
| shared message board. The team succeeds if any participant earns 1. | |
| The maintained team recipe connects the exit status and a shared board. [Legion experiment](https://github.com/huggingface/legion/tree/main/experiments/s3-maze) | |
| The prior sweep and metrics are archived with the original run setup. [Dataset revision `3421ea2`](https://huggingface.co/datasets/HuggingFaceSwarms/s3-maze/tree/3421ea2d46e8963e59cf3690da6ea47739eefb2f) | |
| ## Checks | |
| The checks that need no model, in one command, on a machine with podman (or docker) for the | |
| Trials (`uv` installs Harbor 0.25.0): | |
| ```sh | |
| uv run check.py --env podman # include the Trials | |
| uv run check.py --env none # without the Trials | |
| ``` | |
| 1. **Generator:** `generate.py` reproduces `tasks/` byte for byte, and another seed gives other | |
| trees, which record that seed in their `task.toml` and regenerate from it. Each tree has 391 rooms with distinct 4-digit labels, is a tree (390 two-way doors, | |
| all reachable), has 27 dead ends all 30 moves from the start, one of them the exit; the | |
| shortest path is 30 moves and a full depth-first search through the engine 780; the way back | |
| is listed in every position a room can have it; the exits fall on many positions of the | |
| search order; every task's shared files are `template/`'s, its image tags its files' | |
| digests, and the budget is the same in its tree, grader, instruction and `task.toml`. | |
| 2. **The service**, run as in its container (`service.py` over HTTP): it starts in the start | |
| room with the whole budget; moves into the exit from the start, a room two doors away, the | |
| room itself, a number, an object, a list, a long string and malformed bodies are refused and | |
| cost nothing; a move past the budget is refused, a door included, and so is a move out of the | |
| exit. Every other route and method (`/`, `/tree`, `/state`, `/exit`, `/private/tree.json`, | |
| `/health`, `..` paths, a query on `/look`, ...) answers a bare 404; at every step, no answer | |
| names a room other than the current one, its doors or what was asked for, and only the exit | |
| says `"exit": true`. The move log has one record per move request, refused ones included, | |
| each with agent, from, to and time, and its accepted moves are the walk. `success.py` is | |
| false until the exit and true after, and false for a missing or linked state; `export.py` | |
| writes the record; a restarted service resumes the walk. The `maze` command prints the | |
| service's JSON and exits 0, 1 (refused) or 2 (usage). | |
| 3. **Graders**, as Harbor runs them (`tests/test.sh` on what `export.py` wrote): on every tree | |
| the oracle (`solution/solve.sh` through the `maze` command) scores 1 and a walk that never | |
| reaches the exit 0. On one tree, 27 more cases score 0: the budget spent without the exit, | |
| no move; a forged `final.json` (the exit claimed, no `exported_by`, another tree's hash, | |
| start or budget, the move count); a forged log (a jump, the exit past the budget); another | |
| tree's winning evidence; the evidence as symlinks or hardlinks to a winning copy, a symlinked | |
| `/evidence`, a directory, a FIFO, a missing file, no evidence, invalid JSON, `NaN`; a losing | |
| walk with Python made to rewrite the reward as the grader exits (a `json.py` in its working | |
| directory and on `PYTHONPATH`, a `sitecustomize` on `PYTHONPATH`, a `usercustomize` or a | |
| `.pth` file in the user site; each of these does win when the grader's Python isn't | |
| isolated, which the check confirms where the Python has a user site); and a `reward.txt` or | |
| `reward.json` of 1, or a linked `reward.txt`, left in the verifier's folder. | |
| 4. **No-cheat, in the files:** the agent's build context holds only its Dockerfile and the | |
| `maze` command and names no room, nor do the instruction, `task.toml` or the compose file; | |
| the exit is named only in the service's `tree.json`, `tests/expected.json` and | |
| `solution/solve.sh`; no folder beside `tasks/` holds a tree. | |
| 5. **Trials** (`--env podman` or `docker`, on `maze-t01`, with agents that need no model): | |
| - a walker runs the exit status check in the maze service (false), walks the shortest path | |
| with `maze move`, runs it again (true), and scores 1, with the move log and the export in | |
| its verifier's folder; | |
| - Harbor's oracle agent (`solution/solve.sh`) scores 1; | |
| - a probe searches the agent's container while it works: no file, process environment or | |
| command line names any room but the start and its doors, nor the tree's hash; there is no | |
| `tests/`, `solution/`, `/private` or `/evidence`; the service answers only its two routes. | |
| Then it plants a winning record (from a local walk of this tree) in `/evidence`, | |
| `/logs/artifacts` and `/logs/verifier`, a `reward.txt` of 1, a `json.py` and a | |
| `sitecustomize`, makes three moves short of the exit, and scores 0. | |
| ## Known limits | |
| - **HF Sandboxes can't run it:** each agent's Trial is two containers (the agent's and its maze | |
| service), and HF Sandboxes run one container per Trial. It needs multi-container support | |
| there, as AgentEscapeBench does. Until then it runs on docker or podman (the HF cluster). | |
| - **A new Trial starts a new maze.** It starts with a fresh position and move budget. | |
| - **The grader trusts the maze service.** The agent reaches it only through `maze look` and | |
| `maze move` (an internal network, two routes, bodies up to 4 KiB); an agent that could reach | |
| the service any other way could forge its record. The service runs without capabilities, with | |
| a pids and memory limit, so flooding it only hurts the agent's own maze. | |
| - **The move log's `agent`** identifies the Trial's compose project. | |
| - **Not the paper's setup:** a per-agent move budget instead of a token allowance (looking and | |
| refused moves are free), a message board instead of `message`/`read_messages` tools with | |
| notifications, the moves left in every | |
| observation, and N = 1 is a solo control. | |