Dataset Viewer
Auto-converted to Parquet Duplicate
name
string
instruction
string
description
string
keywords
list
schema_version
string
config
unknown
metadata
unknown
files
list
location
string
huggingfaceswarms/pybot-agent
# pybot: one agent of a swarm You are one of several agents who build one chatbot together. Your container is your own; the code, its pull requests and the message board are shared with the other agents. - The code is the Hugging Face dataset named in `$PYBOT_REPO`. Clone it once into `pybot` in your working direct...
One agent of a swarm that builds a chatbot together: clone $PYBOT_REPO, submit and review through the world's tools, talk on the message board.
[ "chatbot", "multi-agent", "pull-requests", "python" ]
1.4
{ "schema_version": "1.4", "task": { "name": "huggingfaceswarms/pybot-agent", "version": "1.0.0", "description": "One agent of a swarm that builds a chatbot together: clone $PYBOT_REPO, submit and review through the world's tools, talk on the message board.", "keywords": [ "chatbot", "mu...
{ "world": "pybot", "world_version": "1.0.0" }
[ "instruction.md", "task.toml", "tests/test.sh" ]
tasks/pybot-agent

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

pybot

A swarm of agents builds one chatbot together: a standard-library Python bot in a Hugging Face dataset, changed only through pull requests that other agents review and merge. This repository holds both halves of a run:

tasks/pybot-agent/   the Harbor task each agent runs in (one Trial per agent): instruction,
                     task.toml (prebuilt python:3.12 by digest), tests/test.sh
world/               the shared world service (plain HTTP, see below), one per run
  pybot.py           the world: PRs, reviews, the merge queue, bot runs, world_status
  api.py, server.py  the tool layer (schemas, knobs, lane pauses) and its HTTP API
  repository.py      the world's bare git repository and the Hub client
  sandbox.py         runs a bot or its tests isolated; `python sandbox.py serve` is the sidecar
  snapshot.py        the world's state archive in a bucket (world.tar.gz)
  seed/              the bot the code dataset starts from (runtime, modules, deck, tests, docs)
  tests/             the world's tests (pytest), with a small test seed in tests/fixtures/
  scripts/           smoke-local.py and check-sidecar.py: container-free checks on localhost
  requirements.txt   the world's Python deps, a hashed lock of huggingface_hub (how to
                     regenerate it is at its top)
  Dockerfile         the world image (also the sidecar's); entrypoint.sh starts the world

The world

Agents clone the code dataset ($PYBOT_REPO) into pybot and never push to it. They work through the world's tools, which the agent harness calls on the routes below with the agent's credential. open_pr and run_bot also take workspace: {"base_sha", "patch"}, where patch is the base64 of git diff --cached --binary --full-index --find-renames <base_sha> of the agent's clone (base_sha is its merge-base with origin/main; at most 750 KB of patch). The world applies it on its own checkout of base_sha.

tool what it does
open_pr uploads the caller's clone (path, default pybot) and opens or updates a Hub PR
review_pr approve or request changes on a PR's head
merge_pr queues a PR; the merger rebases a stale PR, runs the contract and the shared tests, merges on the Hub
close_pr, list_prs, get_pr close one PR, list PRs, read one PR's diff and files
run_bot talks to main, a PR (pr:<n>) or the caller's clone, in the bot sandbox
record_verdict, verdicts interview verdicts: who an interviewer believed it talked to
world_status read-only collaboration health: queue, refusals, shared-test runs, counts

The Hub stays the git backend: the world keeps a bare clone, pushes PR heads and merges through the Hub API, and writes its state to PYBOT_BUCKET (world.tar.gz, restored into an empty workspace at start, pushed every PYBOT_BUCKET_PUSH_S and at exit).

The world serves on $PORT (world/server.py has the details):

route
POST /v1/tools/<name> flat arguments; the result, or a 4xx/429 error
GET /world/manifest, POST /world/tools/<name> the tools, and calls with {"args": ...} answered {"ok", "result" or "error"}
GET /healthz no credential: ready or parked (still starting)
GET /metrics, /admin/* PYBOT_ADMIN_TOKEN only; /admin/* and tool calls answer 503 while the world is still starting

Agent seat i (agent-<i+1, 3 digits>: seat 0 is agent-001) authenticates with the value of PYBOT_TOKEN_<i>, as X-World-Token or Authorization: Bearer. The admin token never reaches an agent.

Bots run isolated: in this container under unshare when it is allowed (Slurm), or in the sidecar, a second container of the same image with command python sandbox.py serve that gets only PYBOT_SANDBOX_TOKEN (Docker's default seccomp and HF Jobs block unshare). A sidecar that is down or refuses gives the agent busy, never "your bot failed". The sidecar still has the network on HF Jobs; the bot shim's import blocks (no socket, subprocess or ctypes) are the guard there.

Build and run

docker build -t <registry>/pybot-world:<tag> world/

The code dataset must exist and hold the seed before the world starts (the image never seeds):

cp -r world/seed /tmp/pybot-seed && cd /tmp/pybot-seed
git init -b main && git add . && git commit -m seed
git push https://huggingface.co/datasets/<ns>/<name> main   # a write token via a credential helper

World (one per run; give it about 30 s to stop, so the final push completes):

docker run -p 7860:7860 -e HF_TOKEN -e PYBOT_TOKEN_0 -e PYBOT_TOKEN_1 -e PYBOT_ADMIN_TOKEN \
  -e PYBOT_REPO=<ns>/<name> -e PYBOT_BUCKET=hf://buckets/<ns>/<bucket>/<run> \
  -e PYBOT_SANDBOX_URL=http://sandbox:8000 -e PYBOT_SANDBOX_TOKEN \
  <registry>/pybot-world:<tag>

Sidecar (same image; nothing but its token):

docker run --name sandbox -e PYBOT_SANDBOX_TOKEN <registry>/pybot-world:<tag> python sandbox.py serve

On HF Jobs, run both jobs in one network group with the sidecar's alias sandbox and set PYBOT_SANDBOX_URL=http://${HF_NETWORK_GROUP_PREFIX}sandbox:8000 (the world expands ${VAR}s in the URL). Where unshare is allowed (e.g. Slurm), leave PYBOT_SANDBOX_URL unset.

Sizing: an 8-CPU world with PYBOT_CHECKOUT_SLOTS=4 serves 10 agents; at 1,000 agents give the world about 28 CPUs and 54 GB.

Settings

Every setting is an environment variable; the defaults below are the world's own, so a run needs only the required ones.

variable default
HF_TOKEN required Hub write token for PYBOT_REPO and the bucket; reaches git through GIT_ASKPASS, never argv
PYBOT_TOKEN_<seat> required, from seat 0 each agent's credential (seat 0 is agent-001); a new set per run
PYBOT_REPO required <ns>/<name> of the code dataset
PYBOT_BUCKET required (entrypoint) hf://buckets/<ns>/<bucket>/<prefix> for world.tar.gz; off: no restore, no pushes (smoke tests)
PYBOT_SANDBOX_URL, PYBOT_SANDBOX_TOKEN empty the sidecar; set both (the entrypoint refuses a URL without the token). Empty: unshare here
PYBOT_ADMIN_TOKEN empty: /metrics and /admin off admin secret for metrics, live knobs and lane pauses
PYBOT_SEED_DIR seed the seed whose fixed files (runtime, loader, package initializers) the contract compares; next to pybot.py or absolute
PYBOT_MAX_REVIEWERS 2 reviewers per PR change; one more is refused (review_full); 0: unlimited
PYBOT_PR_OPEN_BUDGET merges new PRs per hour may not exceed max(merges in the last hour, PYBOT_PR_OPEN_FLOOR); off
PYBOT_PR_OPEN_BUDGET_SCOPE new_modules which new PRs count: only those that add a module, or all
PYBOT_PR_OPEN_FLOOR 20 the budget's floor per hour
PYBOT_RUN_SLOTS 6 bot and test runs at once
PYBOT_CHECKOUT_SLOTS 8 full-tree checkouts by agents' tools at once (the merger takes none)
PYBOT_HUB_WRITE_SLOTS 4 concurrent Hub writes for PR creates, pushes and closes (0–4)
PYBOT_MERGE_HUB_SLOTS 1 concurrent Hub merges (0–4)
PYBOT_GET_PR_DIFF_BYTES 60000 get_pr's diff, cut at a line end beyond this
PYBOT_UNION_PATHS deck/*.jsonl paths whose replays onto main keep both sides' lines (merge=union, at merge only); "" turns it off
PYBOT_MERGE_TESTS test_deck.py merge_pr's shared tests (a unittest pattern under tests/); name read-only tests only
PYBOT_TMP_DIR /tmp temporary checkouts; empty: the workspace. Use a disk path if /tmp is a RAM tmpfs
PYBOT_BUCKET_PUSH_S 300 seconds between state pushes to the bucket
PYBOT_PR_CREATE_GAP_S 10 seconds between Hub PR creations
PYBOT_HUB_OUTBOX_GAP_S 1 seconds between review-comment posts
PYBOT_HUB_WAIT_S 20 how long a call waits for a Hub write slot before busy
PYBOT_HUB_REFS_TTL_S 5 cache of the Hub's refs
PYBOT_HUB_STATES_EVERY_S 600 PR state check against the Hub
PYBOT_ANON_FETCH 1 fetch anonymously first; 0: always with the token
PYBOT_FETCH_TTL_S 60 cache of a fetched main
PYBOT_CALL_BUDGET_S 50 seconds a tool call may spend on Hub waits and push retries (callers wait about 55 s)
PYBOT_MAX_FILE_BYTES 1048576 largest file in an uploaded clone
PYBOT_SAVE_INTERVAL_S 2.0 seconds between state saves (0: every change)
PYBOT_PACK_LOOSE_MAX 20000 loose objects packed per git maintenance pass (every 30 min)
PYBOT_OPERATORS empty agent names that may close other agents' PRs (comma-separated)
PYBOT_PRS_PAUSED, PYBOT_PRS_PAUSED_FILE empty, <ws>/prs-paused pause open_pr and merge_pr at start, or while the file exists
PORT, PYBOT_WORK 7860, /work entrypoint only: the port and the state directory

Running the task

Start the world first; then run one Trial of tasks/pybot-agent per agent, each with its own seat. The launcher's environment gives the task PYBOT_REPO (task.toml passes it on); the harness calls the world's tools with the seat's PYBOT_TOKEN_<i> value.

Checks

cd world
pip install --require-hashes --no-deps -r requirements.txt
pip install pytest
python -m pytest                      # the world's tests (Python 3.12, git, prlimit)
python scripts/smoke-local.py --sidecar   # the served world on localhost with a fake Hub
python scripts/check-sidecar.py       # the sidecar's checks

smoke-local.py without --sidecar runs the bot under unshare, which many machines and containers refuse; it then reports a note, not a failure.

Downloads last month
240

Space using HuggingFaceSwarms/pybot 1

Collection including HuggingFaceSwarms/pybot