Guides
Deployment Guide
Production deployment options for Agent Swarm
Deployment Guide
Agent Swarm supports multiple deployment options, from Docker Compose to systemd services.
Docker Compose (Recommended)
The easiest way to deploy a full swarm with API, workers, and lead agent.
Quick Start
cp docker-compose.example.yml docker-compose.yml
cp .env.docker.example .env
# Edit .env with your values
docker-compose up -dWhat's Included
The example docker-compose.yml sets up:
- API service (port 3013) — MCP HTTP server
- 2 Worker agents — Containerized Claude workers
- 1 Lead agent — Coordinator agent
Volumes
| Volume | Purpose |
|---|---|
swarm_api | SQLite database persistence |
swarm_logs | Session logs |
swarm_shared | Shared workspace between agents |
swarm_lead | Lead agent's personal workspace |
swarm_worker_* | Personal workspace per worker |
Graceful Shutdown
The docker-compose example uses stop_grace_period: 60s to allow graceful task pause during deployments. When a container receives SIGTERM:
- In-progress tasks are paused (not failed)
- Task state and progress are preserved
- After restart, paused tasks are automatically resumed with context
Use stable AGENT_ID values for each worker to enable task resume after restarts.
Docker Worker
Pull from Registry
docker pull ghcr.io/desplega-ai/agent-swarm-worker:latestRun
docker run --rm -it \
-e CLAUDE_CODE_OAUTH_TOKEN=your-token \
-e API_KEY=your-api-key \
-v ./logs:/logs \
-v ./work:/workspace \
ghcr.io/desplega-ai/agent-swarm-workerWith Custom System Prompt
docker run --rm -it \
-e CLAUDE_CODE_OAUTH_TOKEN=your-token \
-e API_KEY=your-api-key \
-e SYSTEM_PROMPT="You are a Python specialist" \
-v ./logs:/logs \
-v ./work:/workspace \
ghcr.io/desplega-ai/agent-swarm-workerServer Deployment (systemd)
Deploy the MCP server to a Linux host with systemd.
Prerequisites
- Linux with systemd
- Bun installed (
curl -fsSL https://bun.sh/install | bash)
Install
git clone https://github.com/desplega-ai/agent-swarm.git
cd agent-swarm
sudo bun deploy/install.tsThis will:
- Copy files to
/opt/agent-swarm - Create
.envfile (edit to setAPI_KEY) - Install systemd service with health checks every 30s
- Start the service on port 3013
Management
sudo systemctl status agent-swarm # Check status
sudo journalctl -u agent-swarm -f # View logs
sudo systemctl restart agent-swarm # Restart
sudo systemctl stop agent-swarm # StopUpdate
git pull
sudo bun deploy/update.tsGraceful Shutdown Configuration
# Grace period before force-pausing tasks (milliseconds)
SHUTDOWN_TIMEOUT=30000
# Docker compose stop grace period (should be >= SHUTDOWN_TIMEOUT + buffer)
stop_grace_period: 60sResume Behavior
When a worker starts, it:
- Registers with the MCP server
- Checks for paused tasks assigned to its
AGENT_ID - Resumes each paused task with original context and progress
Best Practices
- Use stable Agent IDs — Set explicit
AGENT_IDfor each worker - Save progress regularly — Workers should call
store-progressduring long tasks - Test deployments — Verify tasks resume correctly in staging first
Related
- Getting Started — Initial setup and first deployment
- Environment Variables — All configuration options
- Architecture Overview — How the system components fit together
- Task Lifecycle — Graceful shutdown and task resume behavior