Skip to content

$ cat index.mdx$ cat ~/blogs/engineering/codex-vs-claude-code-paired-run/index.mdx # I put my name on this

What Codex did with its extra tool calls on the same 5 bugs

I wrote this. You can take notes.

I run Claude Code and Codex side by side in my herdr setup, and I have had to fix my scripts around Codex before. On 12 October a commit replaced codex --full-auto, because the current Codex build rejects that flag. On 13 November two commits changed how a sandboxed Codex worker gets its config and auth: its own CODEX_HOME, and auth copied into the sandbox instead of bound.

Next to each other, Codex often looks busier on the same small fix: more tool calls, more seconds. Composio's comparison put a number on it, saying Codex "made about 27% more tool calls, so it often used a more iterative process." A count like that says Codex does more. It does not say what the extra calls are.

I gave both agents the same five small bugs, twice, with two different model pairs, and saved every tool call in order. With Opus 5.5 on Claude Code and gpt-6.1-sol on Codex, Codex took a median 9 tool calls per bug to Claude Code's 4. With each tool's default model, the gap nearly closed, at 8 against 7.

The count was the less interesting part. When I sorted Codex's calls by what each command did, most of the extra ones were looks at files and checks on its own work that Claude Code never ran. Codex ran git status, looked for AGENTS.md instruction files, hashed its own test files with sha256sum, and tried edge cases the test file did not have. The table in "The checks Codex ran on itself" has the counts. Claude Code ran none of those four kinds of check. All 20 runs ended green, with the test files untouched.

Why I ran it

Speed comparisons between these two tools travel well. A YouTube video titled "Claude Code vs Codex vs Gemini: the same request, 57 seconds vs 18 minutes" from Daily AI Minute had 5,776 views about eleven days after it went up on 15 November.

The Composio number pairs Fable 5 with Claude Code and GPT-5.6 Sol with Codex, so it compares two model and tool bundles, not two tools. The same page has a fixed-model test: DeepSeek V4 Flash run through both agents on 30 tasks gave Claude Code 358 tool calls and Codex 448, with median times of 122.7 s and 245.0 s. "More iterative" is a description of the count. I wanted to see what the extra calls actually were, and how much the gap moves when you change the models.

The five bugs

Five tasks, each a small Python module with one bug and a test file. Every file is below, so you can rebuild the set exactly.

t1-slugify/slugify.py:

def slugify(text):
    # Expected: lowercase, runs of non-alphanumeric characters become one hyphen,
    # no leading or trailing hyphen.
    return text.replace(" ", "-")

t1-slugify/test_slugify.py:

from slugify import slugify
 
 
def test_spaces_become_hyphens():
    assert slugify("Hello World") == "hello-world"
 
 
def test_runs_collapse():
    assert slugify("a   b") == "a-b"
 
 
def test_punctuation_removed():
    assert slugify("Yes, really!") == "yes-really"
 
 
def test_no_edge_hyphens():
    assert slugify("  Trim me  ") == "trim-me"

t2-median/stats.py:

def median(values):
    # Expected: the median of a non-empty list of numbers. For an even count,
    # it is the mean of the two middle values.
    ordered = sorted(values)
    return ordered[len(ordered) // 2]

t2-median/test_stats.py:

from stats import median
 
 
def test_odd_count():
    assert median([3, 1, 2]) == 2
 
 
def test_even_count_averages_middle():
    assert median([1, 2, 3, 4]) == 2.5
 
 
def test_single_value():
    assert median([7]) == 7
 
 
def test_unsorted_input_not_mutated():
    data = [5, 1, 3]
    median(data)
    assert data == [5, 1, 3]

t3-duration/durations.py:

import re
 
 
def to_minutes(text):
    # Expected: "1h30m" -> 90, "45m" -> 45, "2h" -> 120. Units may be absent.
    # Raise ValueError for an empty string or anything else.
    match = re.fullmatch(r"(\d+)h", text)
    if match:
        return int(match.group(1)) * 60
    return int(re.fullmatch(r"(\d+)m", text).group(1))

t3-duration/test_durations.py:

from durations import to_minutes
 
 
def test_hours_only():
    assert to_minutes("2h") == 120
 
 
def test_minutes_only():
    assert to_minutes("45m") == 45
 
 
def test_hours_and_minutes():
    assert to_minutes("1h30m") == 90
 
 
def test_empty_raises():
    try:
        to_minutes("")
    except ValueError:
        return
    raise AssertionError("expected ValueError")

t4-dedupe/dedupe.py:

def dedupe(items):
    # Expected: remove duplicates, keep the first occurrence, keep order.
    return list(set(items))

t4-dedupe/test_dedupe.py:

from dedupe import dedupe
 
 
def test_keeps_first_occurrence_order():
    assert dedupe([3, 1, 3, 2, 1]) == [3, 1, 2]
 
 
def test_empty():
    assert dedupe([]) == []
 
 
def test_strings():
    assert dedupe(["b", "a", "b"]) == ["b", "a"]

t5-roman/roman.py:

VALUES = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}
 
 
def roman_to_int(text):
    # Expected: standard Roman numerals, including subtractive pairs (IV = 4, XL = 40).
    total = 0
    for ch in text:
        total += VALUES[ch]
    return total

t5-roman/test_roman.py:

from roman import roman_to_int
 
 
def test_simple():
    assert roman_to_int("III") == 3
 
 
def test_subtractive_pair():
    assert roman_to_int("IV") == 4
 
 
def test_mixed():
    assert roman_to_int("MCMXCIV") == 1994
 
 
def test_xl():
    assert roman_to_int("XL") == 40

No test framework such as pytest is installed on the machine, so each fixture also gets this 37-line run_tests.py:

"""Minimal test runner for the fixtures (no pytest on this machine).
 
Usage: python3 -I run_tests.py [dir]
Imports every test_*.py in the directory, runs every function named test_*,
prints one line per test and a summary, and exits 1 on any failure.
"""
import importlib.util
import pathlib
import sys
import traceback
 
 
def main(root):
    root = pathlib.Path(root).resolve()
    sys.path.insert(0, str(root))
    passed = failed = 0
    for path in sorted(root.glob("test_*.py")):
        spec = importlib.util.spec_from_file_location(path.stem, path)
        module = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)
        for name in sorted(dir(module)):
            if not name.startswith("test_"):
                continue
            try:
                getattr(module, name)()
                passed += 1
                print(f"PASS {path.name}::{name}")
            except Exception:
                failed += 1
                print(f"FAIL {path.name}::{name}")
                traceback.print_exc(limit=1)
    print(f"passed={passed} failed={failed}")
    return 1 if failed else 0
 
 
if __name__ == "__main__":
    sys.exit(main(sys.argv[1] if len(sys.argv) > 1 else "."))

Method

Each agent got the same prompt, in a fresh copy of the fixture:

Make every test in this directory pass by fixing the module code, not the tests. Do not edit test_*.py or run_tests.py. Then stop.

The two commands:

claude -p PROMPT --output-format stream-json --verbose --permission-mode acceptEdits --allowedTools "Bash(python3:*)" Read Edit Write --model <model>
codex exec --json --skip-git-repo-check -s danger-full-access -m <model> PROMPT

Before each run, the script copied the fixture and the runner into a fresh directory. After the run, it ran the pristine runner from outside that directory on the result, and compared the test-file hashes with the fixture. The runs were sequential, one trial per task and agent, so each arm has 10 runs and the two arms have 20. The versions were codex-cli 0.166.0 and Claude Code 2.1.332.

"Pinned arm" means I chose the model on each side: claude-opus-5-5 for Claude Code and gpt-6.1-sol for Codex. It does not mean the two models are equal in size, price or skill. The "default arm" passes no model flag. The Claude output names its model, and it printed claude-haiku-5-5 for that arm. The Codex output names no model. So the Codex default model for that arm is not recorded, and this post does not name it. The Claude side changed model between the arms. The Codex side may or may not have, because its default is not recorded, so a shift between arms belongs to the model setup and not to one tool.

One thing broke during setup. Codex's workspace sandbox failed in my shell with bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted. The bwrap command in that message is bubblewrap, a Linux sandboxing tool. I did not find the cause, so the Codex arm ran with danger-full-access, while the Claude arm ran with an allowlist. The two arms therefore also differ in permission mode. Probe runs came before the set, and none of them is in any number below.

The two tools write different event formats, so each needs its own counter. For Claude Code I count each tool_use block in an assistant message. For Codex I count each item.completed event except agent messages and reasoning. So a Claude Code call and a Codex call are not one-to-one identical actions.

Results

ArmTaskClaude Code callsClaude Code sCodex callsCodex s
Pinned: Opus 5.5 vs gpt-6.1-solt1-slugify413.8934.6
t2-median412.5924.0
t3-duration314.2735.0
t4-dedupe716.2932.0
t5-roman312.6930.1
median413.8932.0
Default: Haiku 5.5 vs Codex defaultt1-slugify814.9827.7
t2-median713.2724.0
t3-duration615.6828.1
t4-dedupe713.0723.6
t5-roman815.5825.8
median714.9825.8

Every run in both arms passed, and every test file was unchanged. In the pinned arm, Codex used more calls and more seconds on every task.

Most of the change between the arms is on the Claude side: swapping Opus 5.5 for Haiku 5.5 moved Claude Code's count far more than the switch to the default setup moved Codex's. If the gap belonged to the tool, it should have held when the model setup changed. The ratio of Codex to Claude Code median calls shrank from 2.25 to 1.14.

This is five tasks, one trial each, on one machine, with no variance estimate. Treat the call counts as a result for these fixtures and these model pairs, not as a property of either tool.

What the extra calls were

To see past the count, I wrote each run's calls as a string of letters. T is a shell call that executes run_tests.py. L is a shell call that only looks at files: its first command is cat, sed -n, head, ls, rg, grep or similar. S is any other shell call. R is Claude Code's Read tool, E is an edit or file change, and W is a whole-file Write call, which in these runs always rewrote the existing module file. Only the kind is recorded, never the command text.

This is the classifier, copied from the script that built the tables below. Feed it each tool's JSON output, one event per line:

import json, re, shlex
 
RUNNER = re.compile(r"(^|[\s;&|(])python3?(\s+-\S+)*\s+(\./)?run_tests\.py\b")
LOOK = {"cat", "sed", "head", "tail", "nl", "ls", "find", "rg", "grep", "wc", "pwd"}
 
def shell_kind(cmd):
    inner = cmd
    m = re.match(r"^\S*(bash|sh|zsh)\s+-l?c\s+(.*)$", cmd, re.S)
    if m:
        try: inner = shlex.split(m.group(2))[0]
        except ValueError: inner = m.group(2)
    if RUNNER.search(inner): return "T"
    verb = inner.strip().split()[0] if inner.strip() else ""
    verb = verb.rsplit("/", 1)[-1]
    if verb in LOOK and not re.search(r"sed\s+-i", inner): return "L"
    return "S"
 
def seq_claude(text):
    s = []
    for line in text.splitlines():
        try: ev = json.loads(line)
        except ValueError: continue
        if ev.get("type") != "assistant": continue
        for b in ev.get("message", {}).get("content", []):
            if b.get("type") != "tool_use": continue
            name = b.get("name")
            if name == "Bash": s.append(shell_kind(str(b.get("input", {}).get("command", ""))))
            else: s.append({"Read": "R", "Edit": "E", "Write": "W"}.get(name, "O"))
    return "".join(s)
 
def seq_codex(text):
    s = []
    for line in text.splitlines():
        try: ev = json.loads(line)
        except ValueError: continue
        if ev.get("type") != "item.completed": continue
        item = ev.get("item", {}); t = item.get("type")
        if t in ("agent_message", "reasoning"): continue
        if t == "command_execution": s.append(shell_kind(str(item.get("command", ""))))
        elif t == "file_change": s.append("E")
        else: s.append("O")
    return "".join(s)
TaskClaude Code, OpusCodex, gpt-6.1-solClaude Code, HaikuCodex, default
t1-slugifyLLWTLLLLLTETSLLRRRWTTLLSTLEST
t2-medianTLETSLSLLSTETLLRRRETLLSTLET
t3-durationLWTLLLTLETLRRTETLSLTLEST
t4-dedupeLLRRRETLLLSSTETSLSRRRETLLLTLET
t5-romanLWTLLLSTSETSLTLLTETTLSLLLTET

Codex works to the same shape in every run, in both arms. It looks at several files, runs the tests once to see the failure, makes one change, and runs the tests once more. That is exactly two test runs per task, ten in each arm, and none of them repeats a run on unchanged code. Claude Code with Opus mostly skipped the first test run. In four of five tasks it looked, wrote the fix, and ran the tests once.

So in the pinned arm, the 22 extra Codex calls are not extra testing. Four are the extra test runs. Eight are extra looks at files: Codex looked at files 18 times through the shell, where Claude Code looked 10 times, 7 through the shell and 3 with Read. The other ten are the S calls, and those are the interesting ones.

The checks Codex ran on itself

I counted the shell calls that contain each kind of command. The table gives the number of runs, out of five per cell, where the agent ran it at least once.

CommandClaude Code, OpusCodex, gpt-6.1-solClaude Code, HaikuCodex, default
git status0505
looks for AGENTS.md0501
sha256sum on the test files and runner0300
its own edge cases, outside the test file0202

The prompt asked for none of these. git status shows what changed in the working tree. Codex's docs say it "reads AGENTS.md files before doing any work", yet it also searched for the file with shell commands. The hash calls covered the test files and the runner, the two kinds of file the prompt said not to edit, and in each of those three runs Codex ran them twice. The edge cases were short Python snippets that imported the module and tried inputs the test file never used, such as 0h0m for the duration parser.

Claude Code did none of these. Both approaches ended green on every task here, and the fixtures are too small to show a case where the extra checks caught something. What the table does show is that "Codex makes more tool calls" is partly "Codex checks its own work more", and the model setup matters, as the two Codex columns of the table differ.

I checked one way these counts could mislead. A file change made through a shell command, such as sed -i or a redirect, would hide inside an S or L. None of Codex's 71 shell calls across both arms, test runs included, matched a file-writing pattern. In every Codex run the one file change came as a file-change event.

Where the calls went

The same calls by kind, totalled over five tasks:

Tool kindClaude Code, Opus armCodex, Opus armClaude Code, default armCodex, default arm
shell13382033
of which test runs6101010
read30110
edit2545
write3010
total21433638

Read calls are not comparable across the two agents. Codex's events have no read type, so its file reads sit inside shell commands. Haiku 5.5 leaned on the Read tool far more than Opus 5.5 did: the default arm made 15 more calls than the Opus arm on the Claude side, and 8 of them were reads.

Seconds per call

Calls alone do not explain the time. In the default arm, Claude Code made 36 calls in 72.2 s, and Codex made 38 calls in 129.2 s. That is 2.01 s per call for Claude Code and 3.40 s for Codex. The pinned arm is closer: 3.30 s per call for Claude Code and 3.62 s for Codex. So in the default arm the time gap sits in seconds per call, not in call count. These are whole-run seconds divided by calls, so they include model time between calls, not only tool time.

Done gate: the check that decides "done"

In three pinned runs, Codex hashed its own test files. That is the core of a done gate, run by the agent on itself. A check the agent runs on itself is still the agent grading its own work, which is the problem self-signed done describes. I also covered Codex reviewing Claude Code's work in how Claude and Codex learned to tag each other, and the Claude Code side of this pillar starts with Why Claude Code Subagents Refuse to Write FINDINGS.md.

The version I trust runs outside the agent. It is a 25-line script. You take a snapshot of the test-file hashes before the agent starts, and you run the check when it says it is done. Its exit code is the answer.

"""Done gate: "done" counts only if test files are unchanged and tests pass.
  python3 done_gate.py snapshot DIR MANIFEST              (before the agent starts)
  python3 done_gate.py check DIR MANIFEST TEST_CMD...     (0 green, 1 red, 2 tests edited)
"""
import hashlib, json, pathlib, subprocess, sys
 
def hashes(project):
    return {p.name: hashlib.sha256(p.read_bytes()).hexdigest()
            for p in sorted(pathlib.Path(project).glob("test_*.py"))}
 
def main(argv):
    mode, project, manifest = argv[1], argv[2], pathlib.Path(argv[3])
    if mode == "snapshot":
        manifest.write_text(json.dumps(hashes(project), indent=1))
        print(f"snapshot: {len(hashes(project))} test files")
        return 0
    if hashes(project) != json.loads(manifest.read_text()):
        print("BLOCK: test files were edited since the snapshot")
        return 2
    run = subprocess.run(argv[4:], cwd=project, capture_output=True, text=True)
    print("GREEN" if run.returncode == 0 else "RED", "exit", run.returncode)
    return 0 if run.returncode == 0 else 1
 
if __name__ == "__main__":
    sys.exit(main(sys.argv))

I ran it on the t1-slugify fixture three ways:

Case A (fixture as shipped, tests red, test file unchanged)
RED exit 1
case A rc=1

Case B (correct slugify.py written, test file unchanged)
GREEN exit 0
case B rc=0

Case C (test file appended to after the snapshot)
BLOCK: test files were edited since the snapshot
case C rc=2

I also ran the gate on the final tree of each pinned-arm run, using the fixture's test files as the snapshot. All 10 trees exited 0, and in all 10 the run's copy of the test runner matched the pristine checker byte for byte. The default-arm trees are not in this check, because their directories do not carry the run label.

The check hashes only test_*.py. If the agent can edit the test runner, the check proves nothing, so point the test command at a copy the agent cannot reach. Tokens and cost are not in this post.

What to do with this

Before you compare two agents on your own work, pin both models, and run the comparison again with a second model pair. If the gap moves as much as it did here, you are measuring the pair, not the tool.

Then sort the calls by what they did, not just how many there were. A one-letter code per call, built from either tool's JSON output, showed that most of Codex's extra calls here were looks at files and checks on its own work, and that Codex ran the tests exactly twice per task. If you pay per call or per second, those checks are the cost. If you have been bitten by an agent that edited its tests, they are the part you would want to keep, and the done gate above is how to keep them without trusting the agent to run them.

$ ls ~/read/related

my other essays