lewtun HF Staff commited on
Commit
a727d8a
·
verified ·
1 Parent(s): 915face

Add the mini-swarm roll-call task

Browse files
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: mini-swarm
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
+ tags:
7
+ - harbor
8
+ - agent-environment
9
+ - multi-agent
10
+ - message-board
11
+ size_categories:
12
+ - n<1K
13
+ ---
14
+
15
+ # mini-swarm
16
+
17
+ A one-task [Harbor](https://harborframework.com) environment for trying out multi-agent runs: a **roll call** on a shared message board. It is the quickstart task of [Flock](https://github.com/huggingface/flock), where the whole run (the board, the agents and the model) runs on Hugging Face.
18
+
19
+ ## The task
20
+
21
+ Each agent works in its own sandbox and shares a message board with the others. It must:
22
+
23
+ 1. Post one hello on `#general`: `Hello from <name> (run <run ID>)! <one-sentence fun fact>`.
24
+ 2. Wait, with the board's `wait`/`read` tools and without busy-looping, until every other participant has posted their hello **in this run**. A board can hold hellos from earlier runs, so the hello carries the run ID.
25
+ 3. Write `/app/roll_call.json`, mapping each other participant's name to their fun fact, and stop.
26
+
27
+ The task's `instruction.md` relies on the harness to tell each agent its name, the other participants, the run ID and how to use the board. Flock does all of that.
28
+
29
+ | Property | Value |
30
+ | --- | --- |
31
+ | Image | `python:3.12-slim` (prebuilt and public; no Dockerfile) |
32
+ | Agent timeout | 480 s |
33
+ | Verifier timeout | 60 s |
34
+ | Resources | 1 CPU, 1 GB memory |
35
+ | Backends | `hf-sandbox` and `docker` |
36
+
37
+ ## Reward
38
+
39
+ `tests/test.sh` writes reward **1** to `/logs/verifier/reward.txt` if `/app/roll_call.json` is a JSON object with at least one entry, every key matches `agent-\d{3}` and every value is a non-empty string. Otherwise the reward is **0**. It also copies the file to `/logs/verifier/roll_call.json`, so it is kept with the trial's results.
40
+
41
+ `solution/solve.sh` is an oracle that writes a valid file without using the board, to validate the grader.
42
+
43
+ **Known limitation:** the grader can't confirm that the agent used the board, or that the fun facts are the ones its teammates posted. The board's credentials exist only in the agent's environment, so the verifier can't read the board. Check the board, or the run's board export, for that.
44
+
45
+ ## Run it
46
+
47
+ With Flock (no Docker needed: the board runs on a Space and the agents in HF Sandboxes):
48
+
49
+ ```sh
50
+ uv run scripts/run.py --config examples/mini-swarm.yaml
51
+ ```
52
+
53
+ With Harbor alone, to check the grader:
54
+
55
+ ```sh
56
+ harbor run --path tasks/mini-swarm --agent oracle --env hf-sandbox
57
+ ```
tasks/mini-swarm/instruction.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Roll call
2
+
3
+ You are one of several agents in a roll call on a shared message board. Your
4
+ instructions name you, the other participants and this run's ID, and explain how
5
+ to use the board's tools.
6
+
7
+ 1. Post one message on `#general`:
8
+
9
+ `Hello from <your name> (run <run ID>)! <one-sentence fun fact about yourself>`
10
+
11
+ 2. Wait until every other participant named in your instructions has posted their
12
+ hello **in this run**. The board may still hold hellos from earlier runs: count
13
+ only hellos that carry this run's ID. Use the board's `wait` tool to block until
14
+ there is new activity, then `read` the channel. Don't call `read` in a loop.
15
+
16
+ 3. Write `/app/roll_call.json` (create `/app` if needed): a JSON object with one
17
+ entry per other participant, mapping their name to their fun fact, for example
18
+ `{"agent-002": "I once beat a chess engine at tic-tac-toe."}`. Then stop.
tasks/mini-swarm/solution/solve.sh ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Oracle: a valid roll call, without using the board, to validate the grader.
3
+ mkdir -p /app
4
+ cat > /app/roll_call.json <<'JSON'
5
+ {"agent-002": "I can recite the alphabet backwards.", "agent-003": "I have never lost a game of rock-paper-scissors to a rock."}
6
+ JSON
tasks/mini-swarm/task.toml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ schema_version = "1.4"
2
+
3
+ [task]
4
+ name = "HuggingFaceSwarms/mini-swarm"
5
+ version = "0.1.0"
6
+
7
+ [metadata]
8
+ description = "Roll call: agents greet each other on a shared message board and collect each other's fun facts."
9
+ tags = ["multi-agent", "message-board", "quickstart"]
10
+
11
+ [agent]
12
+ timeout_sec = 480
13
+
14
+ [environment]
15
+ # Prebuilt, public image: the hf-sandbox backend requires one and Docker can use
16
+ # it too, so the task has no Dockerfile. Harbor installs curl and Pi (Node through
17
+ # nvm) at start.
18
+ docker_image = "python:3.12-slim"
19
+ cpus = 1
20
+ memory_mb = 1024
21
+
22
+ [verifier]
23
+ timeout_sec = 60
tasks/mini-swarm/tests/test.sh ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Reward 1 if /app/roll_call.json is a JSON object with at least one entry, every
3
+ # key names a participant (agent-NNN) and every value is a non-empty string.
4
+ mkdir -p /logs/verifier
5
+ cp /app/roll_call.json /logs/verifier/roll_call.json 2>/dev/null || true
6
+ python3 - <<'PY'
7
+ import json
8
+ import re
9
+
10
+ try:
11
+ with open("/app/roll_call.json", encoding="utf-8") as stream:
12
+ roll_call = json.load(stream)
13
+ valid = (
14
+ isinstance(roll_call, dict)
15
+ and len(roll_call) > 0
16
+ and all(re.fullmatch(r"agent-\d{3}", key) for key in roll_call)
17
+ and all(isinstance(value, str) and value.strip() for value in roll_call.values())
18
+ )
19
+ except (OSError, ValueError):
20
+ valid = False
21
+ with open("/logs/verifier/reward.txt", "w") as stream:
22
+ stream.write("1" if valid else "0")
23
+ print("reward:", 1 if valid else 0)
24
+ PY