Multi-agent orchestration framework
Project description
OpenSwarm
Cut your AI coding costs by ~70%. Define agent teams in YAML — cheap models do bulk work, expensive models make decisions. Works inside Claude Code, Cursor, Copilot, and any MCP-compatible IDE.
agents:
- name: "senior"
model: claude-sonnet-4-20250514
role: senior
rules: ["Break down tasks", "Review junior's output"]
- name: "junior"
model: deepseek-chat
role: junior
rules: ["Execute assigned tasks", "Write tests"]
openswarm run "Build user auth API" --config team.yaml
Senior breaks it down, delegates to Junior, reviews results, assembles final output. One command.
Install
pipx install "openswarm-ai[mcp]"
This installs everything: the openswarm CLI, the openswarm-mcp server, and all dependencies. The [mcp] extra adds MCP server support for IDE integration (Claude Code, Cursor, etc.).
Why pipx? It installs OpenSwarm globally in an isolated environment — available from any project, no venv conflicts. Install pipx if you don't have it. Or use
brew install pipxon macOS.
Get Started
1. Add team.yaml to your project
Drop this in your project root — like a CLAUDE.md, but for your agent team:
team:
name: "backend-team"
goal: "Build and maintain backend services"
workflow: hierarchical
lead: "senior"
agents:
- name: "senior"
role: senior
model: claude-sonnet-4-20250514
host: https://api.anthropic.com
api_key: ${ANTHROPIC_API_KEY}
max_tokens: 4096
rules: ["Break down tasks", "Review output before approving"]
- name: "junior"
role: junior
model: deepseek-chat
host: https://api.deepseek.com/v1
api_key: ${DEEPSEEK_API_KEY}
max_tokens: 2048
rules: ["Execute assigned tasks", "Write tests for all code"]
2. Register with your IDE (one-time)
Claude Code
claude mcp add openswarm -- openswarm-mcp
Cursor
Go to Cursor Settings → MCP → Add new MCP server:
- Name:
openswarm - Type:
command - Command:
openswarm-mcp
GitHub Copilot (VS Code)
Add to VS Code settings.json:
{
"github.copilot.chat.mcp.servers": {
"openswarm": {
"command": "openswarm-mcp",
"args": []
}
}
}
Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"openswarm": {
"command": "openswarm-mcp",
"args": []
}
}
}
OpenCode
Add to your opencode.json:
{
"mcp": {
"openswarm": {
"type": "local",
"command": ["openswarm-mcp"],
"timeout": 300000
}
}
}
3. Use your IDE normally
That's it. Open your project, give coding tasks — your IDE automatically delegates to the team. No special commands, no prompting needed.
Supported IDEs
| Tool | Integration | Status |
|---|---|---|
| Claude Code | MCP server (auto-discovery via .mcp.json) |
Ready |
| OpenCode | MCP server (auto-discovery via opencode.json) |
Ready |
| Cursor | MCP server (via Cursor settings) | Ready |
| Windsurf | MCP server (via ~/.codeium/windsurf/mcp_config.json) |
Ready |
| GitHub Copilot | MCP server (via VS Code settings.json) |
Ready |
Any tool that supports MCP works with OpenSwarm — the setup is the same pattern everywhere.
How It Works
User: "Build user auth API"
↓
Senior (Claude): decomposes task
├── "Write User model" → Junior (DeepSeek)
├── "Write endpoints" → Junior (DeepSeek)
└── "Design JWT strategy" → Senior handles directly
↓
Junior returns code → Senior reviews → requests fixes or approves
↓
Final result → User
How does the IDE know to use OpenSwarm? When team.yaml exists in your project, the MCP server tells your IDE to delegate all coding tasks to the team automatically. You just use your IDE normally.
What if the task doesn't match the team? For example, you have a frontend team but ask a backend question. The team's lead agent recognizes it's outside their scope and says so — your IDE then handles it directly. You never need to decide; just ask, and the system routes it to the right place.
MCP Tools
| Tool | Description |
|---|---|
openswarm_run(task, team?) |
Delegate a task to an agent team (auto-selects if one team exists) |
openswarm_teams() |
List available teams (local + global) |
openswarm_team_info(team) |
Show team details — agents, models, workflow |
Config discovery: team.yaml / openswarm.yaml in project root, openswarm/*.yaml subdirectory, and ~/.openswarm/teams/ globally.
CLI Usage
# Run with config file
openswarm run "Build a REST API" --config team.yaml
# Run with named team (from ~/.openswarm/teams/<name>.yaml)
openswarm run "Fix the login bug" --team backend
# Verbose — see inter-agent messages in real-time
openswarm run "Refactor auth module" --config team.yaml -v
# List all configured teams
openswarm team-list
# Show team details
openswarm team-info backend
# Run as Python module
python -m openswarm run "Do the thing" --config team.yaml
Interactive Mode (experimental)
Chat with your team in a persistent session. We're actively improving this.
openswarm interactive --team backend
openswarm interactive --team backend -v # with real-time message display
Slash commands: /quit, /team, /history, /clear. Ctrl+C cancels current task without exiting.
Team Config
team:
name: "backend-team"
goal: "Build and maintain backend services"
workflow: hierarchical
lead: "senior"
max_rounds: 10
agents:
- name: "senior"
role: senior
model: claude-sonnet-4-20250514
host: https://api.anthropic.com
api_key: ${ANTHROPIC_API_KEY}
max_tokens: 4096
temperature: 0.7
rules:
- "Break down tasks and delegate to junior"
- "Review output before marking done"
- name: "junior"
role: junior
model: deepseek-chat
host: https://api.deepseek.com/v1
api_key: ${DEEPSEEK_API_KEY}
max_tokens: 2048
temperature: 0.3
rules:
- "Execute assigned tasks"
- "Write tests for all code"
Agent Config Fields
| Field | Required | Default | Description |
|---|---|---|---|
name |
yes | — | Agent identifier |
role |
yes | — | What this agent does |
model |
yes | — | LLM model name |
host |
yes | — | API endpoint URL (OpenAI-compatible) |
api_key |
yes | — | API key (supports ${ENV_VAR} syntax) |
max_tokens |
no | 4096 |
Max tokens per response (≥ 1) |
temperature |
no | 0.7 |
Sampling temperature (0.0–2.0) |
max_history |
no | 40 |
Max messages kept in agent history (≥ 1) |
rules |
no | [] |
Agent behavior rules |
What models can I use? Any model with an OpenAI-compatible API — Claude, GPT, DeepSeek, Mistral, Llama, local models via Ollama. If litellm supports it, OpenSwarm supports it.
Workflow Types
| Type | How it works | Best for |
|---|---|---|
| hierarchical | Lead delegates, reviews, requests revisions, assembles | Dev teams, review workflows |
| pipeline | Sequential: A → B → C — each agent transforms output | Content pipelines, data processing |
| collaborative | All agents discuss → consensus | Brainstorming, code review, decision-making |
Pipeline Workflow
Sequential chain where each agent receives the previous agent's output:
team:
name: "content-pipeline"
goal: "Write and polish articles"
workflow: pipeline
agents:
- name: "writer"
role: writer
# ...
- name: "editor"
role: editor
# ...
- name: "reviewer"
role: reviewer
# ...
Agents execute in config list order. No lead required.
Collaborative Workflow
All agents see the task simultaneously and discuss in rounds. First agent in the list acts as moderator. Early exit if all agents agree. Moderator synthesizes the final answer.
team:
name: "review-panel"
goal: "Review and decide on architecture"
workflow: collaborative
max_rounds: 5
agents:
- name: "moderator"
role: architect
# ... (first agent = moderator)
- name: "backend"
role: backend-specialist
# ...
- name: "frontend"
role: frontend-specialist
# ...
Requires at least 2 agents. No lead field needed.
Error Handling
- LLM calls retry once on transient errors (rate limits, timeouts, connection issues)
- Permanent errors (bad API key, invalid model) fail immediately with a clear message
openswarm runshows clean error output instead of tracebacks- Config validation catches problems at load time (missing lead agent, invalid temperature/token values)
Cost Comparison
Why pay for an expensive model to write boilerplate? Let the cheap model do the heavy lifting.
Example: "Build user auth API"
Without OpenSwarm — Claude Code does everything with Claude Sonnet:
| Step | Model | Input tokens | Output tokens | Cost |
|---|---|---|---|---|
| Decompose task | Sonnet | ~2,000 | ~500 | $0.009 |
| Write User model | Sonnet | ~3,000 | ~1,500 | $0.019 |
| Write endpoints | Sonnet | ~4,000 | ~2,000 | $0.024 |
| Write tests | Sonnet | ~5,000 | ~2,500 | $0.030 |
| Review & fix | Sonnet | ~6,000 | ~1,500 | $0.027 |
| Total | ~20,000 | ~8,000 | ~$0.109 |
Sonnet: $3/M input, $15/M output
With OpenSwarm — Senior (Sonnet) delegates bulk work to Junior (DeepSeek):
| Step | Model | Input tokens | Output tokens | Cost |
|---|---|---|---|---|
| Decompose + delegate | Sonnet | ~2,000 | ~500 | $0.009 |
| Write User model | DeepSeek | ~3,000 | ~1,500 | $0.001 |
| Write endpoints | DeepSeek | ~4,000 | ~2,000 | $0.002 |
| Write tests | DeepSeek | ~5,000 | ~2,500 | $0.002 |
| Review & approve | Sonnet | ~4,000 | ~500 | $0.020 |
| Total | ~18,000 | ~7,000 | ~$0.034 |
DeepSeek: $0.14/M input, $0.28/M output
Result: ~70% cost reduction on the same task, with the expensive model only doing what it's good at — architecture and review.
At scale
| Scenario | Without OpenSwarm | With OpenSwarm | Savings |
|---|---|---|---|
| 10 features/day | ~$1.09 | ~$0.34 | 69% |
| 100 features/day | ~$10.90 | ~$3.40 | 69% |
| With Opus as lead | ~$3.00 | ~$0.85 | 72% |
The more work you can route to cheap models, the more you save. Senior handles ~20% of tokens but makes the decisions that matter.
Environment Variables
| Variable | Default | Purpose |
|---|---|---|
OPENSWARM_CONFIG_DIR |
~/.openswarm |
Global config directory |
OPENSWARM_LOG_LEVEL |
INFO |
Log level |
Development
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,mcp]"
pytest tests/ -v
ruff check src/ tests/ && ruff format src/ tests/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openswarm_ai-1.0.3.tar.gz.
File metadata
- Download URL: openswarm_ai-1.0.3.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6134edadc365551af733373aad2301a0668e9f8f1fb85109fbf68c84f8f8a116
|
|
| MD5 |
3bca697dcf8a4fa88457a079543e8031
|
|
| BLAKE2b-256 |
6874fb55d4290a9051025c95ac6725110ce60c911692e11d8f9c896c58fd49b9
|
Provenance
The following attestation bundles were made for openswarm_ai-1.0.3.tar.gz:
Publisher:
publish.yml on ErfanMomeniii/openswarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openswarm_ai-1.0.3.tar.gz -
Subject digest:
6134edadc365551af733373aad2301a0668e9f8f1fb85109fbf68c84f8f8a116 - Sigstore transparency entry: 1615307147
- Sigstore integration time:
-
Permalink:
ErfanMomeniii/openswarm@c47537b1444469c0b2fef6641b5f08dc5e22f486 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/ErfanMomeniii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c47537b1444469c0b2fef6641b5f08dc5e22f486 -
Trigger Event:
release
-
Statement type:
File details
Details for the file openswarm_ai-1.0.3-py3-none-any.whl.
File metadata
- Download URL: openswarm_ai-1.0.3-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b833ced33928995122192f7a35aff93adc1fdc2faaca2ffe36d9daf4fc788d70
|
|
| MD5 |
e9011beb9cd1f19481a0c38156dd958f
|
|
| BLAKE2b-256 |
be3deae461d99e44837d15bfa3bf710b01dd832a4ab373db2de168e3bfdb0fa8
|
Provenance
The following attestation bundles were made for openswarm_ai-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on ErfanMomeniii/openswarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openswarm_ai-1.0.3-py3-none-any.whl -
Subject digest:
b833ced33928995122192f7a35aff93adc1fdc2faaca2ffe36d9daf4fc788d70 - Sigstore transparency entry: 1615307173
- Sigstore integration time:
-
Permalink:
ErfanMomeniii/openswarm@c47537b1444469c0b2fef6641b5f08dc5e22f486 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/ErfanMomeniii
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c47537b1444469c0b2fef6641b5f08dc5e22f486 -
Trigger Event:
release
-
Statement type: