--- pretty_name: s3-aggregation license: apache-2.0 language: - en tags: - harbor - agent-environment - multi-agent - message-board size_categories: - n<1K --- # s3-aggregation A [Harbor](https://harborframework.com) environment that measures whether a swarm of agents **communicates**: each agent holds one private number, and no agent can solve the task alone. It adapts the information-aggregation task of [s³: Simple Scaling of Swarms via Cooperative Multi-agent RL](https://arxiv.org/abs/2611.08615) ([scalingswarms.com](https://scalingswarms.com)) to [Legion](https://github.com/huggingface/legion) swarms, whose agents talk over a shared message board. It isn't a replication of the paper: the agents are Pi with Legion's board, and the board is what we measure. **This dataset is private for now.** ## The task Each of the N agents holds one private integer from 1 to 99, written in English words ("seventy-three"). The team must list all N numbers in ascending order, keeping equal numbers from different agents as separate entries. Each agent finds its number in its instruction, shares it on the board, reads the others', keeps one number per participant, writes `/app/answer.json` (a JSON array of N integers in ascending order) and stops. The team succeeds if any agent's answer is right. The instruction adapts the paper's (Appendix G) to the board and prescribes no protocol beyond that. | | | | --- | --- | | Problems | 32 (the paper's held-out set size), each 16 integers drawn uniformly from 1 to 99, repeats allowed, from a fixed seed | | Teams | 160: one per problem and team size N ∈ {1, 2, 4, 8, 16}, holding the problem's first N numbers, e.g. `agg-p07-n08` | | Tasks | 992: one per slot of each team, `agg-p07-n08-s01` .. `-s08`, whose instruction states that slot's number | | Image | `python:3.12-slim`, prebuilt and public (no Dockerfile): HF Sandboxes, docker and podman | | Agent / verifier timeout | 1800 s / 60 s | | Resources | 1 CPU, 1 GB memory per agent | ```text tasks/agg-pPP-nNN-sKK/ slot K of team agg-pPP-nNN (zero-padded: name order is slot order) instruction.md "Your private number is ...": slot K's, and no other task.toml tests/test.sh the grader, the same for every slot of the team tests/expected.json the team's answer: copied in only after the agent is done solution/solve.sh an oracle with its own copy of the answer legion/ spec.template.yaml what every team's Legion run shares: model, board rules, loop, limits team.py writes one team's spec (docker, HF Sandboxes or the HF cluster) sweep/ the scaling sweep on the HF cluster (legion/sweep/README.md) eval/metrics.py one row per team from Legion run directories problems.json the 32 problems generate.py writes problems.json and tasks/ from its seed (115) check.py the checks that need no model ``` **Private numbers** reach each agent only through its own task. Legion runs a team with the selector `agg-pPP-nNN-s*`, `agents.count: N` and `naming: consecutive-id`: the selector matches the team's N slots, sorted by name, and `agent-00K` runs slot K's task, so its instruction holds its own number and no one else's. A task folder puts nothing in the container while the agent works (no `environment/`; `tests/` arrives after the agent is done), so no agent can read another agent's number until that agent posts it. ## Reward `tests/test.sh` writes reward **1** to `/logs/verifier/reward.txt` when `/app/answer.json` is exactly `tests/expected.json`: a JSON array of the team's integers in ascending order, one per agent. Anything else scores **0**: a missing or unreadable file, invalid JSON, `NaN`, a non-array, strings, words, floats or booleans, a missing, extra or dropped duplicate number, and a wrong order. The answer counts only as a regular file of its own at exactly `/app/answer.json`: a symlink (e.g. to `/tests/expected.json`, which arrives only after the agent is done), a link anywhere on the path (a symlinked `/app`), a hardlink, a directory or a FIFO scores 0, and `expected.json` is read the same way. The grader follows no link an agent may have left, writes 0 before it checks anything (a crash also scores 0), and keeps a copy of the answer with the trial's results. Its Python runs isolated (`python3 -I -S`), so no module in the working directory or on `PYTHONPATH`, and no `sitecustomize`, `usercustomize` or `.pth` hook, can change what it imports; besides `bash`, `python3` is the only command it runs. Each agent is scored on its own answer; the team succeeds if any agent scores 1. ## Run it with Legion Legion's [`experiments/s3-aggregation/spec.yaml`](https://github.com/huggingface/legion/tree/main/experiments/s3-aggregation) runs one team on HF Sandboxes (`TEAM`, default `agg-p01-n04`, with `N` its size) at the revision it pins: `uv run legion launch experiments/s3-aggregation/spec.yaml`. Its board is a public Space for the run: delete it afterwards. For any other team or place, `legion/team.py` writes the spec from `legion/spec.template.yaml`, run from Legion's checkout. **Needs** `HF_TOKEN`, which reads the private dataset (and starts the sandboxes and deploys the board's Space), and `HF_INFERENCE_TOKEN`, a fine-grained token with only "Make calls to Inference Providers", which goes into the agents' containers. Never the same token. Each agent of a team is `agent-001` ... (`naming: consecutive-id`), all one Legion type on one worker (`agents_per_worker: N`), so they share that worker's board. ### On HF Sandboxes The controller and the team's one worker run on this machine, each agent in its own HF Sandbox (`cpu-basic`) and the board on a Space: ```sh DS=../s3-aggregation # this dataset, at the revision team.py pins uv run python $DS/legion/team.py --problem 7 --agents 4 --where sandbox --out runs/agg-p07-n04 BOARD_SPACE=/s3-agg-p07-n04 uv run legion launch runs/agg-p07-n04/spec.yaml uv run legion status agg-p07-n04 uv run python $DS/eval/metrics.py .legion/agg-p07-n04-