Blog

Pi vs Codex on the same model: 4 coding tasks

Same model, four coding tasks: Pi and Codex both passed, neither consistently faster. Codex's sandbox refused a write outside its roots; Pi wrote the file.

On this page · 8 sections
  1. Pi vs Codex test scope
  2. Results from four coding tasks
  3. How I ran the tasks
  4. Context-file behavior (AGENTS.md and CLAUDE.md)
  5. A narrow write-boundary probe
  6. Token usage and cost
  7. Which one I would use
  8. Related

This Pi vs Codex comparison runs Pi coding agent and OpenAI Codex CLI on the same model and the same four coding tasks. Both passed all 13 fixture unit tests and 16 independent edge assertions, each was faster on two of the four tasks, and they behaved differently on context files and on a write outside Codex's writable roots ([workdir, /tmp, $TMPDIR]).

I'm Larry 🍀 Orbi, the creator of Orbi. On 2 December 2026 (UTC+8), I ran Pi 1.7.0 and Codex CLI 0.167.0 with the model ID gpt-6.1-sol at low reasoning. Orbi uses Pi for issue-driven repository work, so I wanted a direct same-day check against Codex CLI instead of combining older runs. Neither CLI won on speed or test result in this small sample.

Pi vs Codex test scope

This test compares two configured CLIs on one Linux host. Pi and Codex CLI use different tool lists, context-loading defaults, and filesystem policies, so differences in runtime, context files, or write behavior reflect those configured setups as well as the model.

On 2 December 2026, each CLI ran once on fresh copies of four small synthetic Python tasks, followed by 16 independent post-run edge assertions. I also ran a read-only no-op control, plus JSON follow-up runs to test whether token usage could be compared. For write boundaries, an earlier /tmp probe showed both CLIs could write there, followed by one narrow probe against a disposable file outside Codex's workspace-write grants. Five one-run context-file probes in disposable scratch fixtures tested AGENTS.md and CLAUDE.md.

These runs leave out normalized token comparison, subscription or price comparison, real-repository testing, long-run reliability, and general model ranking.

Results from four coding tasks

Each CLI ran once on four synthetic Python fixtures: cart total (src/shop/cart.py), billable minutes (src/billing.py), top_words (src/word_stats.py), and tag normalization (src/tags.py). Wall-clock times measure each CLI command from start to exit, rounded to one decimal place.

Task Baseline tests Pi 1.7.0 Codex CLI 0.167.0 Test files and README
Cart total 2/2 passed 14.2 s; 2/2 passed 18.7 s; 2/2 passed Unchanged
Billable minutes 4 tests, 2 failures 18.7 s; 4/4 passed 17.4 s; 4/4 passed Unchanged
top_words 3 tests, 3 errors 21.6 s; 3/3 passed 18.8 s; 3/3 passed Unchanged
Tag normalization 4 tests, 4 errors 18.9 s; 4/4 passed 19.0 s; 4/4 passed Unchanged

These two setups were not symmetric: Pi ran with sessions, extensions, MCP, skills, prompt templates, and context files disabled, while Codex ran with this machine's normal user configuration and hooks. Treat the wall-clock figures as single-run observations of those two configured CLIs, not a like-for-like speed benchmark.

The fixtures started in different states. Cart total already passed its 2 baseline tests, while its README called for integer half-up percentage rounding and capping the fixed coupon at the remaining subtotal. Both CLIs updated src/shop/cart.py and kept 2/2 passing. Billable minutes started with 2 failures out of 4 tests, and both brought it to 4/4. top_words started as a missing implementation raising NotImplementedError (3 errors out of 3), and both implemented it to 3/3. Tag normalization also started with NotImplementedError (4 errors out of 4), asking for normalize_tags(tags) to strip surrounding whitespace, lowercase entries, drop empty strings, and deduplicate while preserving first-seen order. Both brought it to 4/4.

After the agent runs finished, I verified that every fixture's README.md and test file remained byte-for-byte unchanged. I then ran 16 independent Python assertions outside the fixture suites: 3 for cart rounding, coupon cap, and shipping; 5 for billing boundaries (0, 1, 60, and 61 seconds) and negative input raising ValueError; 4 for top_words punctuation and case folding, empty input, and zero or negative limits; and 4 for tag normalization trimming, lowercasing, deduplication, first-seen ordering, and whitespace-only or empty input. Both Pi and Codex passed 16/16.

Timings were mixed. Pi finished faster on cart total (Pi 14.2 s vs Codex 18.7 s) and 0.1 s faster on tag normalization (Pi 18.9 s vs Codex 19.0 s), while Codex finished faster on billable minutes (Pi 18.7 s vs Codex 17.4 s) and top_words (Pi 21.6 s vs Codex 18.8 s). Each task ran once per CLI, so run-to-run variance is unmeasured.

How I ran the tasks

Both CLIs ran on 2 December 2026 (+08) with model ID gpt-6.1-sol at low reasoning. Fixture tests and edge assertions ran on Python 3.14.7.

Pi 1.7.0 used the openai-codex provider and --thinking low. Its task command disabled sessions, extensions, MCP, skills, prompt templates, and context files (--no-session, --no-extensions, --no-mcp, --no-skills, --no-prompt-templates, --no-context-files), enabled only read,bash,edit,write,grep,find,ls, and passed --approve. Codex CLI 0.167.0 ran in ephemeral mode with --sandbox workspace-write, model ID gpt-6.1-sol, and model_reasoning_effort="low". The four coding-task Codex commands did not pass --ignore-user-config, so they ran with this machine's normal Codex user configuration and executed the hooks recorded in the transcripts: SessionStart, UserPromptSubmit, and Stop. The recorded Codex wall times include that startup, configuration, and hook work. Keep this comparison scoped to these exact CLI setups; the two commands were not symmetrically stripped baselines.

The common task prompt told each CLI to read the fixture README.md, source file, and tests, implement only the README contract in the existing source file, leave README.md, tests, and external paths untouched, run the README test command, and report the actual command and output. That test command was:

python3 -m unittest discover -s tests -v

If you repeat this comparison yourself, record or align CLI versions, model ID, enabled tools, and user configuration on both sides, and start each CLI on a fresh independent copy of every fixture. Run the baseline tests first so you know what failed beforehand. Afterward, compare the tracked fixture files (excluding __pycache__ and other run artifacts) to confirm no files were added or removed, and verify that the README and test files stayed byte-for-byte unchanged. Then rerun the test suite and a few unseen assertions yourself instead of trusting agent output.

In a separate no-op control, I asked each CLI to read the top_words README and source without writing files or running commands. Both completed with no fixture files changed in either directory. That check confirms only that no fixture paths changed; it does not rule out tool calls. When Codex ran with this machine's normal configuration, it used its node_repl MCP tool to read the local files, including in the initial JSON no-op attempt.

Context-file behavior (AGENTS.md and CLAUDE.md)

In separate one-run probes, I created disposable scratch git fixtures where task.txt asked only for the word READY, while an AGENTS.md or CLAUDE.md file instructed the CLI to append a marker. I counted a file as loaded only when the reply contained that file's requested marker text.

  • Pi loaded both marker files (AGENTS.md and CLAUDE.md). When run with --no-context-files, Pi did not load the AGENTS.md marker (CLAUDE.md was not tested under --no-context-files).
  • Codex, run with --ignore-user-config, loaded the AGENTS.md marker and did not load the CLAUDE.md marker.

A narrow write-boundary probe

In a separate probe from a temporary workspace, I asked each CLI to write the exact text scope probe to a single disposable file outside Codex's workspace-write grants. Codex's CLI log lists those writable roots as [workdir, /tmp, $TMPDIR]. A separate earlier probe targeting a path under /tmp confirmed that both CLIs could write there, so Codex workspace-write does not block all writes outside the working directory.

For the tested path outside [workdir, /tmp, $TMPDIR]:

  • Pi created the file under the normal OS permissions of the account that started it. Although the command passed --approve, Pi 1.7.0's security and CLI documentation states that --approve is a project-local resource trust option (not a filesystem permission or sandbox) and that enabled tools still use the starting OS user's permissions.
  • Codex with --sandbox workspace-write refused the write, did not create the file, and reported that the target path was on a read-only filesystem.
  • As a control, Codex with --sandbox danger-full-access created the file and verified the exact same text.

All three runs returned exit code 0, including the refused workspace-write run. Judging an automated shell run by exit code alone hides a refused write, so I checked the target path directly after every run.

Token usage and cost

Both CLIs emitted usage events in JSON mode during the read-only no-op follow-up runs, but this experiment produced no normalized Pi vs Codex token comparison. Codex returned turn.completed.usage in both JSON attempts, while Pi returned per-turn usage totals on each assistant message_end event. (An initial parser check only scanned for token_count events and missed Codex's turn.completed.usage; re-parsing the saved raw JSONL logs recovered the actual fields.)

JSON no-op run CLI-reported usage metric (not equivalent) Completion path
Pi run 1 (same stripped flags as the four tasks) 8,403 summed totalTokens (5 assistant turns) Read local README and source with built-in tools and summarized
Pi run 2 (same flags and prompt) 12,551 summed totalTokens (7 assistant turns) Read local README and source with built-in tools and summarized
Codex initial (normal user config) turn.completed.usage: 176,376 input / 386 output / 12 reasoning tokens Read local files through node_repl MCP and summarized
Codex retry (--ignore-user-config) turn.completed.usage: 150,930 input / 211 output / 24 reasoning tokens Under this no-command prompt constraint, called list_mcp_resources; reported no local file-reading tool and did not read the README or source (does not mean Codex cannot read files when commands are allowed)

Those totals are not comparable across CLIs. Codex's counters include different system and tool contexts (including MCP/resource metadata), and the --ignore-user-config retry did not complete the same file-reading task. Even within Pi's own minimal setup, two runs of the same read-only prompt reported 8,403 and 12,551 total tokens depending on tool-call turn count.

For the same reason, this experiment cannot estimate a per-task bill or compare Codex vs Pi subscriptions: it lacks normalized task usage, plan verification, account limits, and server-side invoices.

Which one I would use

These four coding tasks did not separate Pi and Codex CLI on test outcomes or speed. For me, single-run timings are not enough to pick one. I would choose the CLI that fits the repository workflow, including which context files it expects, and verify its behavior on the actual paths it needs to touch.

In this one write probe, Codex with workspace-write refused the write outside [workdir, /tmp, $TMPDIR], while Pi wrote the file under the starting OS user's permissions and the Codex full-access control wrote it too. Because all three processes returned exit code 0, I checked the file itself.

In my own workflow, Orbi uses Pi for issue-driven repository work (see why Orbi runs on Pi) and does not run Codex. That existing integration is not evidence that Pi won this comparison.

What is new in Orbi, every week

One email a week: new features, hands-on posts and numbers from our own work with Orbi. Unsubscribe anytime.