Pair-programming with two agents at once
I tried something this week that I wouldn’t have tried six months ago: I ran two agents on the same task at the same time. Claude in one terminal, Codex in another, both working on the same refactor. I picked the better diff and discarded the other.
Here’s what I learned.
The setup
The task was a medium-sized refactor: convert the homelab repo’s main entry point from a flat script to a proper Python package. The change touches 8 files. The new structure is a src/homelab/ package with submodules for each concern. The CLI is in homelab.cli. The configuration is in homelab.config. The HTTP client is in homelab.api. The tests get restructured to match.
I opened two terminals. In one, I started Claude Code pointed at the repo. In the other, I started Codex CLI pointed at the same repo. I gave each the same prompt:
Convert the flat script in
homelab.pyto a proper Python package atsrc/homelab/. The CLI entry point moves tosrc/homelab/cli.py. The HTTP client moves tosrc/homelab/api.py. The configuration loading moves tosrc/homelab/config.py. Update the tests to match. Updatepyproject.tomlto use the new package layout. Run the tests when you’re done. Don’t write any new functionality. This is a pure refactor.
The results
Both agents worked for about 12 minutes. Both came back with diffs. The diffs were different.
Codex’s diff: Tight. 7 files changed. The package structure was exactly what I asked for. The test restructuring was minimal (just import path updates). The CLI argparse setup was preserved verbatim. The total diff was 380 lines added, 220 lines removed.
Claude’s diff: Looser. 11 files changed. The package structure included an extra __init__.py that re-exported the public API (I didn’t ask for that, but it was nice to have). The test restructuring created a conftest.py that I didn’t ask for (also nice). The CLI argparse setup was slightly refactored to use a subparser pattern. The total diff was 540 lines added, 280 lines removed.
What I picked
I picked Claude’s diff. The reasons:
- The
__init__.pyre-exports made the package usable asfrom homelab import do_thinginstead offrom homelab.api import do_thing. I would have written that eventually. - The
conftest.pyconsolidated the test fixtures I’d been duplicating across the test files. I would have written that eventually. - The subparser pattern in the CLI was a real improvement. The original argparse setup was getting unwieldy.
The Codex diff was correct and minimal. The Claude diff was correct and a little more than minimal. The “little more than minimal” was the right amount of “more” for a refactor of this size.
What I learned
The two agents make different tradeoffs. Codex optimizes for “do exactly what was asked.” Claude optimizes for “do what was asked and the obvious next things.” For a refactor, the “obvious next things” are usually right. For a bug fix, they’re often wrong.
The two agents make different mistakes. Codex’s mistake would have been the test restructuring being too minimal. Claude’s mistake would have been the test restructuring being too aggressive. I would have caught both on review. The review is the part that matters.
The cost is real but acceptable. I used two paid agent sessions instead of one. The cost is about 2x. The benefit is that I got a better diff to start from. The time saved on review is worth the 2x cost.
This doesn’t scale to every change. For a one-line rename, this is silly. For an 8-file refactor, this is a useful pattern. The threshold is around 3-4 files of changes.
The pattern I’m trying next
The pattern that seems to work: pick the bigger refactors (5+ files) and run two agents in parallel. Pick the smaller changes (1-2 files) and run one agent. The bigger the change, the more value there is in having two perspectives.
The pattern doesn’t work for bug hunts. Two agents on the same bug produce two different guesses. I end up evaluating the guesses, which is the same work as running one agent and reading the result.
The honest summary
I used two agents on one refactor. I got a better result than I would have with one. The cost was 2x. The pattern works for medium-to-large refactors. It doesn’t work for small changes or bug hunts.
The agents are tools. The two-agent pattern is a tool. Use it when it fits. Don’t use it when it doesn’t.