Cordium documentation · Latest
Parallel Agents
Coding agents are non-deterministic: the same task given to different agents, different models, or even the same model twice often produces solutions of very different quality. This example fans one task out to several agents running in parallel, each in its own Workspace forked from the exact same state, and compares their results by running the test suite. It is the basis of "best-of-N" workflows and of evaluating agents and models on your own codebase.
WorkspaceSnapshots make the fan-out cheap and fair: a developer prepares a Workspace once (e.g. the repository at the right commit, its dependencies downloaded, its build cache warm, and a failing test that reproduces the bug), snapshots it, and every agent starts from an identical copy of it within seconds (read more about snapshots here).
The Template
The following Template of the payments Space installs both Claude Code and Codex, and configures both of them to use the anthropic and openai Octelium LLM Services, so that no API key is present in any Workspace (read more here):
Preparing the Baseline
A developer creates a persistent Workspace from the Template, checks out the commit to work on, and reproduces the bug with a failing test:
Then, they snapshot the Workspace. Stopping it first gives a clean snapshot, while a running Workspace can be snapshotted too:
The Orchestrator
The following Go program forks the issue-1842 snapshot into one ephemeral Workspace per agent, runs the agents in parallel with the same prompt, runs the whole test suite in each Workspace, saves each agent's diff locally, and prints a comparison:
The developer then reviews the patches of the successful attempts and applies the best one to their own Workspace via git apply. Here are a few notes about this program:
The prompt is passed as an environment variable of each
execsession, so it never needs to be quoted for the shell.The agents' standard input is redirected from
/dev/null, sinceexecsessions do not signal the end of the standard input.Every Workspace is ephemeral and deleted after its attempt, while the snapshot remains available for more attempts. Delete it via
cordium delete snapshot issue-1842once you are done.Each Workspace run is a separate Octelium Session, which means that the LLM token usage of every attempt is attributed and can be budgeted separately (read more here).