huggingface/legion
Harbor-based orchestration for coding agents in separate containers
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Legion adds team orchestration around Harbor: each agent runs as a Trial in its own container, while Legion launches agents, maintains their sessions, and reports progress and model usage. Specs define the task, model endpoint, team size, and role instructions. The mini-swarm configuration demonstrates that the controller and worker can run locally while agent execution and the message board run on separate hosted services.
The Python 3.12+ stack declares Typer, Pydantic, PyYAML, FastAPI, and Uvicorn, and pins harbor[e2b] to 0.25.0 and msgboard[hf] to a Git commit. The extension point is a Python module exposing a TOOLS mapping. Legion packages the selected functions for agents and describes them in their instructions; a tool list in the spec replaces the default board tools rather than extending them.
Key Capabilities & Differentiators
Teams can share instructions through team_file or specialize through agents.roles; supported coding harnesses are Pi, Codex, and Claude Code. A spec loop can send prompts automatically, or an operator can target a role with legion prompt --swarm my-team --type agent. Model calls can use Hugging Face Inference Providers or an OpenAI-compatible endpoint you operate.
The message board lets agents exchange findings without sharing a task container. The four-agent escape-room example uses separate task copies with one board; ProgramBench adds a shared Hugging Face repository for exchanging code. Tasks can be selected from a Hugging Face dataset at a pinned revision. For local runs, legion status shows state and usage, and the run bundle under .legion/ supports later inspection of outcomes and rewards from Python.
Trade-offs & Limitations
Use Harbor directly for independent trials, or run Pi, Codex, or Claude Code directly for a single interactive coding session. Legion earns its extra operational layer when separate agents need coordinated roles, shared findings, and team-level run visibility. Containers separate task environments, but shared boards and repositories still need access controls, and the inference credential enters every agent container.
For hosted runs, scope inference separately from infrastructure permissions and include both sandbox and inference charges in cost estimates. Stopping a mini-swarm run does not delete its board Space; clean up only a Space created for that run, after its workers stop. CLI, spec, and API changes can break integrations without deprecation, so pin a Legion commit and test upgrades against representative specs. Licensing is unspecified and should be resolved before commercial adoption.
Hardware & Deployment Guide
Install with Python 3.12+, Git, and uv, then use uv sync and uv run legion. Rootless Podman is the default task-container backend; Docker with Compose is supported for local runs only. Hugging Face Jobs and Slurm are execution options, and the root contains Dockerfile.controller and Dockerfile.worker. The mini-swarm path needs neither local container engine: its controller and worker run locally, agents run in paid HF Sandboxes, and the board runs on a Space.
The local Docker quickstart requires no Jobs or Space permissions, but private Hub tasks still require Hub read access and model calls require a reachable inference endpoint. Self-hosting does not by itself establish a fully offline deployment. Size task compute for the chosen images and concurrent agents, and size model serving separately if you host it. The manifest version is 0.0.1, no latest release is listed, and docs/migrations.md maps the former Flock names and breaking spec changes.
harbor[e2b]==0.25.0.team_file supplies shared instructions, while agents.roles defines distinct roles using Pi, Codex, or Claude Code.task.repo, task.revision, and task.selector locate and pin a Harbor task independently of Legion code.message_board.* and calculator.add select Python tools; an explicit list replaces the defaults.legion status reports agent state and model usage; local runs persist logs and a run bundle under .legion/.HF_TOKEN as the inference key; agents receive a separately scoped inference credential.Engineering and research teams running collaborative Harbor tasks that need per-agent environments, configurable roles, shared findings, and run-level usage tracking.
You need only one coding session or independent trials, or require stable interfaces, confirmed commercial licensing, or a verified fully offline deployment.
Quick Start & Installation
git clone https://github.com/huggingface/legion cd legion uv sync
Comparison vs. Top Agents & Frameworks Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| legion ★ | 125 | +24 | Python | — | Harbor-based orchestration for coding agents in separate containers |
| browser-use | 122.7k | +477 | Python | MIT | Python REPL and CDP for adaptive browser automation |
| langchain | 150.4k | +299 | Python | MIT | Modular Python framework for building agents across model providers |
| agentscope | 37.2k | +342 | Python | Apache-2.0 | Python ReAct SDK and FastAPI service for observable, interruptible agent workflo |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/huggingface/legion.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about legion
How do I integrate an existing Harbor task without changing Legion?
task.repo at a Hugging Face dataset containing a self-contained Harbor task, pin task.revision to a published commit, and select the task with task.selector. You do not need to modify Legion. If you explicitly list Python tools in the spec, include message_board.* to retain the board tools.Does the Legion host need a GPU, and how should I size it?
Does self-hosting make Legion suitable for commercial use?
When should I use Legion instead of Harbor directly or a standalone coding harness?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy