Codex Swarm

Splits a product spec into a dependency graph of coding tasks and runs them in parallel Docker sandboxes, with a live dashboard.

Codex Mumbai 2026

🎓 SudoMeet

📌 Mumbai

🚀 8 hours Hackathon Project

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.

  1. Refine. refineSpec in decomposer.ts sends the raw spec to a chat model and gets back a tighter engineering brief.
  2. Decompose. decompose sends the brief and the output of git ls-files to a model in JSON mode. The model returns tasks with an id, a list of files and a list of dependency ids. The code rejects any dependency that names an unknown task.
  3. Schedule. The Orchestrator class in orchestrator.ts starts every task whose dependencies are all completed, up to maxConcurrency (default 4).
  4. Execute. For each task, sandbox-runner.ts copies the repository to a sibling directory, asks the model for a JSON plan of write_file and shell actions, starts a container, and runs the actions with docker exec.
  5. Apply. The runner captures git diff --cached from 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.

  1. Clone the repository: git clone https://github.com/WhyAsh5114/codex-hackathon.git
  2. Install dependencies: cd codex-hackathon && pnpm install
  3. Create the config file: cp .env.example .env
  4. Set OPENAI_API_KEY in .env.
  5. Start the server and dashboard: pnpm dev
  6. Open the dashboard at the URL that Vite prints. The dev server proxies /ws and /api to port 3001.
  7. Enter a spec and the absolute path to a local repository, then launch the run. The server builds the codex-swarm-agent image on the first run.

Reference

The server reads these environment variables in packages/server/src/config.ts.

VariableDefaultPurpose
OPENAI_API_KEYrequiredAPI key for the model provider
OPENAI_BASE_URLOpenAI endpointPoints the OpenAI SDK at another compatible provider
REFINE_MODELo3-miniModel for spec refinement
DECOMPOSE_MODELo3-miniModel for the task graph (needs JSON mode)
AGENT_MODELDECOMPOSE_MODEL, else o3-miniModel that plans each task
MAX_CONCURRENCY4Ceiling for parallel containers; clients can only lower it
AGENT_TIMEOUT_MS600000Per-task timeout
PORT3001Server port
CORS_ORIGIN*Allowed CORS origin

The stack choices:

LayerChoiceUsed for
ServerHono, @hono/node-ws, TypeScript on Node.jsHTTP, WebSocket and orchestration
Model accessopenai SDKRefine, decompose and plan calls
SandboxDocker (node:22-slim plus git, curl, build tools, Python 3)Per-task execution
DashboardSvelte 5, SvelteKit, Tailwind CSS 4, shadcn-svelteLive UI
Workspacepnpm workspacesServer 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.

Liked Codex Swarm? Here's my background.

Full-stack TypeScript, shipped to real users.