Python orchestration for coding agents in local, container, and cloud sandboxes.
Project description
SwarmBox
SwarmBox runs coding agents in isolated, git-aware workspaces from Python. Use it to hand a task to Claude Code, Codex, OpenCode, Pi, or another terminal-native coding agent, let the agent work in a branch or sandbox, then collect the commits and logs in a predictable way.
It is built for local automation, CI workers, and multi-agent workflows where you need repeatable setup, branch isolation, prompt files, streamed output, and recovery paths when sync or merge operations need human help.
Install
python -m pip install swarmbox
Optional sandbox SDKs:
python -m pip install "swarmbox[vercel]"
python -m pip install "swarmbox[daytona]"
For local development:
python -m pip install -e ".[dev]"
Quick Start
Create a SwarmBox config directory:
swarmbox init --agent codex-cli --sandbox docker --template blank --no-build
Run an agent from Python:
from swarmbox import codex, docker, run
result = run(
agent=codex("gpt-5.4-codex"),
sandbox=docker(),
prompt_file=".swarmbox/prompt.md",
name="fix-login",
)
print(result.branch)
print([commit.sha for commit in result.commits])
Run from the CLI:
swarmbox run \
--agent codex-cli \
--sandbox docker \
--prompt-file .swarmbox/prompt.md \
--name fix-login
Core Concepts
- Agents build print-mode and interactive commands for coding-agent CLIs.
- Sandboxes run those commands on the host, in Docker/Podman, or in cloud workspaces.
- Worktrees isolate task branches under
.swarmbox/worktrees. - Prompt files support
{{ARG}}substitution plus marked shell expansion with!`command`. - Hooks run setup commands on the host or inside the sandbox before the agent starts.
- Sync and recovery move commits, diffs, and untracked files between isolated sandboxes and the host repo.
Supported Agents
First-class adapters:
claude-clicodex-cliopencode-clipi
Registry-backed generic adapters include Gemini CLI, GitHub Copilot CLI, Cursor Agent, Qwen Code, Goose, Aider, Amp, Augment, Continue, OpenHands, Replit Agent, Roo Code, Warp, Windsurf, Zencoder, and other SwarmVault or SwarmClaw-compatible command-line agents.
Useful commands:
swarmbox agents list
swarmbox agents detect
swarmbox agents doctor
Sandbox Providers
from swarmbox import docker, podman, no_sandbox, vercel, daytona
docker()andpodman()use bind mounts for fast local iteration.no_sandbox()runs directly in the selected worktree.vercel()anddaytona()use optional SDK integrations for isolated cloud workspaces.
Image helpers:
swarmbox docker build-image
swarmbox docker remove-image
swarmbox podman build-image
swarmbox podman remove-image
Branch Strategies
from swarmbox import branch, head, merge_to_head
head()runs on the current branch and bind-mounted repo.merge_to_head()runs on a temporary branch and merges successful commits back to the current branch.branch("swarmbox/task-123", base_branch="main")runs on an explicit branch.
Streaming, Sessions, And Timeouts
from swarmbox import Timeouts, codex, docker, run
events = []
result = run(
agent=codex("gpt-5.4-codex"),
sandbox=docker(),
prompt_file=".swarmbox/prompt.md",
idle_timeout_seconds=600,
timeouts=Timeouts(copy_to_worktree_ms=60_000),
logging={
"type": "file",
"on_agent_stream_event": events.append,
},
)
SwarmBox can capture streamed text and tool-call events, enforce idle timeouts, transfer Claude-compatible session files, and preserve worktrees when an agent leaves uncommitted changes behind.
Configuration
swarmbox init creates .swarmbox/ with:
.env.examplefor agent and backlog manager credentialsDockerfileorContainerfilemain.py- prompt templates
swarmbox.json
Runtime secrets belong in .swarmbox/.env, which is ignored by git.
Never commit API keys, PyPI tokens, provider tokens, or agent credentials.
Templates
blanksimple-loopsequential-reviewerparallel-plannerparallel-planner-with-review
Each template can be paired with GitHub Issues or Beads backlog commands and customized after scaffolding.
Development
python -m pip install -e ".[dev]"
python -m unittest discover -s tests -v
ruff check .
python -m build
twine check dist/*
Live smoke tests for Docker, Podman, Vercel, Daytona, and real coding-agent CLIs should be run before a release when those tools are available.
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 swarmbox-0.2.0.tar.gz.
File metadata
- Download URL: swarmbox-0.2.0.tar.gz
- Upload date:
- Size: 39.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bb753bfb99a1ae85098b4874830510f546dd1a6c65ced758a2b81416a94f59f
|
|
| MD5 |
590f440dd3980015c80a72404b37aefb
|
|
| BLAKE2b-256 |
db2df72039cb773beea07e6193a8977a869188a4d561da2c66d3491fed420255
|
File details
Details for the file swarmbox-0.2.0-py3-none-any.whl.
File metadata
- Download URL: swarmbox-0.2.0-py3-none-any.whl
- Upload date:
- Size: 41.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c409177d9a0a3facdab105bf352fc4647088652cdbe23c07cce70db409320879
|
|
| MD5 |
df5bd73bffebe638cf8f37ac231de61a
|
|
| BLAKE2b-256 |
282b284abafbc0999463b6b3e5f87de069b8c36f6508e7ff5e4a95eb8f315891
|