What it is
Codex Swarm turns a product spec into a graph of small coding tasks and runs the independent tasks in parallel. Each task runs in its own Docker container against a copy of your repository. A web dashboard shows the task graph, the streaming output and the resulting diffs. A team of two built it at Codex Mumbai 2026.
The problem
Working with a coding agent one prompt at a time is sequential. You wait for one task, then write the next prompt by hand. Work that does not depend on earlier work still waits in line.
Codex Swarm adds the missing coordination layer. It decides which tasks can run now, which must wait, and what happens to the rest of the run when one task fails.
How it works
The repository is a pnpm monorepo with two packages: packages/server (a Hono HTTP and WebSocket server) and packages/web (a SvelteKit dashboard). A run has five stages.
- Refine.
refineSpecindecomposer.tssends the raw spec to a chat model and gets back a tighter engineering brief. - Decompose.
decomposesends the brief and the output ofgit ls-filesto a model in JSON mode. The model returns tasks with anid, a list of files and a list of dependency ids. The code rejects any dependency that names an unknown task. - Schedule. The
Orchestratorclass inorchestrator.tsstarts every task whose dependencies are allcompleted, up tomaxConcurrency(default 4). - Execute. For each task,
sandbox-runner.tscopies the repository to a sibling directory, asks the model for a JSON plan ofwrite_fileandshellactions, starts a container, and runs the actions withdocker exec. - Apply. The runner captures
git diff --cachedfrom the copy, sends it to the dashboard, and copies only the changed files back to the original repository.
The browser and server talk over one WebSocket at /ws. The client sends start, cancel and retry. The server sends refining, refined, dag, task_update, agent_output, task_diff, swarm_complete and error. The shared types live in packages/server/src/types.ts.
The dashboard components in packages/web/src/lib/components map to the run: TaskGraph (SVG graph), AgentFeed (streaming logs), Timeline (start and end times), DiffViewer, Summary and ExportPanel. A Svelte 5 rune store, swarm.svelte.ts, holds the state.
One point is easy to miss. The project name refers to the Codex CLI, but the server does not launch it. Each "agent" is a single chat-completions call that returns a plan. Containers only execute that plan.
What I built
I built the task dependency graph (DAG), which decides what can run in parallel, and the Vercel AI SDK integration that drives the agents.
Design decisions
Event-driven scheduling instead of waves. scheduleReady runs at the start of a run and in the finally block of every task. A slot that opens is refilled at once. The alternative is to run the graph in topological layers, which leaves slots idle while the slowest task in a layer finishes. The cost is that each call rescans all tasks, which is acceptable for graphs of this size.
Plan first, execute in a container. The model never touches the host. It produces a list of actions, and the container runs them. This keeps untrusted generated commands inside a boundary. The trade-off is a single-shot plan with no feedback loop between actions. The runner also logs a failing command and continues. Because of that, a task can finish as completed even if one of its commands failed.
Copy the repository instead of sharing it. Each task gets its own copy, mounted at /workspace with --memory 4g --cpus 2. Parallel tasks cannot overwrite each other mid-run, and the original repository changes only in the apply step. The cost is a full copy per task. The container command sets no network restrictions.
Conflict avoidance lives in the prompt. The decomposer prompt tells the model to give each task its own files and to chain tasks that share a file. The code checks only that dependency ids exist. If two independent tasks do touch the same file, the later copy-back overwrites the earlier one.
Failures propagate, and retries undo them. When a task fails, failDependents marks every queued descendant as failed with the message Dependency "<id>" failed. The retry message requeues the failed task and resets the descendants that failed for that reason.
Run it locally
You need Node.js 22, pnpm 9, Docker and an OpenAI-compatible API key.
- Clone the repository:
git clone https://github.com/WhyAsh5114/codex-hackathon.git - Install dependencies:
cd codex-hackathon && pnpm install - Create the config file:
cp .env.example .env - Set
OPENAI_API_KEYin.env. - Start the server and dashboard:
pnpm dev - Open the dashboard at the URL that Vite prints. The dev server proxies
/wsand/apito port 3001. - Enter a spec and the absolute path to a local repository, then launch the run. The server builds the
codex-swarm-agentimage on the first run.
Reference
The server reads these environment variables in packages/server/src/config.ts.
| Variable | Default | Purpose |
|---|---|---|
OPENAI_API_KEY | required | API key for the model provider |
OPENAI_BASE_URL | OpenAI endpoint | Points the OpenAI SDK at another compatible provider |
REFINE_MODEL | o3-mini | Model for spec refinement |
DECOMPOSE_MODEL | o3-mini | Model for the task graph (needs JSON mode) |
AGENT_MODEL | DECOMPOSE_MODEL, else o3-mini | Model that plans each task |
MAX_CONCURRENCY | 4 | Ceiling for parallel containers; clients can only lower it |
AGENT_TIMEOUT_MS | 600000 | Per-task timeout |
PORT | 3001 | Server port |
CORS_ORIGIN | * | Allowed CORS origin |
The stack choices:
| Layer | Choice | Used for |
|---|---|---|
| Server | Hono, @hono/node-ws, TypeScript on Node.js | HTTP, WebSocket and orchestration |
| Model access | openai SDK | Refine, decompose and plan calls |
| Sandbox | Docker (node:22-slim plus git, curl, build tools, Python 3) | Per-task execution |
| Dashboard | Svelte 5, SvelteKit, Tailwind CSS 4, shadcn-svelte | Live UI |
| Workspace | pnpm workspaces | Server and web packages |
Outcome
A team of two built Codex Swarm at Codex Mumbai 2026, held on 4 April 2026. The hackathon page records about 3.5 hours of actual hacking time and no placement. The repository has 26 commits, all dated 4 April 2026, and an MIT license.