Build1 distinct publisher3 min readPublished
OpenAI's Codex harness is now Apache-2.0 and Pi is MIT. That means the comparison can be run directly instead of inferred from a leaked bundle. The three loops agree about the middle and diverge at the edges.
The Engineer · Build desk
Compiled by The EngineerSomething wrong?How this is made
Five steps describes the loop correctly, but the description does not size the work of building one. Assemble context, call the model, execute any tool calls, append the results, decide whether to go round again [4]. Claude Code's `while(true)` opens at line 307 and closes at 1728, so the body alone is 1,421 lines [5]. That averages 284 lines per step [2], with a further 308 lines of the same file sitting outside the loop [3].
The extra bulk is plumbing: streaming, where tool calls arrive before the message is finished and you have to decide whether to start executing; parallel execution, which is safe or unsafe depending on what the tools touch; mid-turn interrupts, which have to unwind without corrupting the transcript; compaction when the context fills; telling retryable provider failures from the other kind; and approvals, which can park the loop indefinitely while a human decides [8]. None of it is intelligence. A tutorial loop is 50 lines because nobody in a tutorial hits escape halfway through a turn.
The counts themselves travel badly. They come from a single clone taken on 2026-09-01 for a teardown published on dev.to [3]: 1,729 lines of TypeScript, 983 of Rust, 794 of TypeScript [2], with Codex and Pi spreading comparable work across neighbouring modules, which is why the author compares file to file rather than loop body to loop body [6]. The 189 lines between Codex and Pi [5] tell you about module boundaries and brace style, not about difficulty. The factor of 2.18 across the full range [1] survives translation because it is coarse. Measured against the "~50-200 lines" row the same author printed earlier and has now retracted, Pi alone is roughly 16 times the low end [4][7].
The divergence worth reading is the boundary: what sits outside the loop, and how the loop talks to it [9]. Claude Code keeps the loop, the tools, the permission checks, compaction and the UI in one process, coordinating by function call and shared state, which is what lets its five-level compression pipeline decide using information the loop has not committed to anything yet [10]. The bill for that is reach. Everything must be in-process, and another program cannot drive the agent except through the surface Anthropic chose to expose [11]. Codex went the other way, pulling the agent core into `app-server` behind a documented, bidirectional JSON-RPC 2.0 interface whose README starts from a Thread primitive, one conversation between a user and the agent [12].
In my context that decision comes before the line count. If you own the process and the UI, in-process wins on compaction fidelity, because the compressor can use state that never had to be serialised onto a wire [10]. If you want a job runner or an IDE to drive the agent, the RPC surface is the part you cannot retrofit cheaply [12]. And a harness well under 800 lines has made a choice about which of those six hard parts it does not handle, which is worth establishing before you adopt it.
Ranked by verification strength, evidence, and original report placement.
OpenAI published the Codex harness under Apache-2.0 in August 2026, including codex exec, the SDK, and the app-server that hosts the agent core. Pi is MIT. Both are on GitHub with permanent history.
Claude Code's agent loop is 1,729 lines of TypeScript, Codex's is 983 lines of Rust, and Pi's is 794 lines of TypeScript. Three teams, three languages, no shared code and no shared lineage, and in Pi's case an explicit design goal of being the small one.
Every number in the piece comes from a clone the author made on 2026-09-01 and can be checked by readers. The author's earlier Part 2 teardown of Claude Code's query.ts was only possible because of a leak, and line numbers from a leaked bundle are a snapshot of a build nobody can check.
Stripped to control flow, each of the three implementations runs the same five steps: assemble context, call the model, execute tool calls if the response contains them, append the results to the conversation, and decide whether to loop again or stop.
Claude Code's while(true) runs from line 307 to line 1728, so the loop body alone is 1,421 lines.
Codex and Pi spread more of the same work across neighbouring modules, so the author treats file-to-file as the honest comparison; file-to-file, the spread is 794 to 1,729 lines, slightly more than a factor of two across three independent teams.
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · September 1, 2026
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Two of three subjects are clonable
The strength here is unusual for a teardown: the licences make Codex and Pi checkable, the clone is dated, and dev.to names its counting rule — file-to-file — so a reader who prefers a different rule can say exactly where they differ. The weakness is one subject. Claude Code is not open, so its 1,729-line file and the 307-to-1728 loop range can only come from the leaked bundle the same piece calls a snapshot nobody can verify. The comparison is therefore two-thirds reproducible and one-third inherited from the very source it retired.
Availability documented, uptake not
What can be pinned down is that the code is obtainable: Apache-2.0 for Codex's harness, MIT for Pi, both with permanent history. Beyond that the reporting is silent — no downloads, no installs, no deployment counts for any of the three. The one indirect usage signal is architectural: a protocol that ships an overload error and treats the VS Code extension as merely one client among peers is written by people who already expect several things to be connected at once. That is inference from design, not a number, and we score it as such.
Retracts more than it oversells
The rare direction. dev.to's headline finding is convergence, and the author immediately calls that the least interesting thing about the three systems; then he withdraws a claim from his own earlier instalment because Pi's 794 lines disprove the 50-to-200-line figure he printed. Writers protecting a thesis do not usually do that. The overreach that remains is rhetorical rather than factual — the boundary question 'determines nearly everything else about the system' is asserted from three readings and cannot be checked — and the unacknowledged soft spot is that Claude Code's numbers still come from a leak.
One author's series, corrected against himself
The pull to watch for is authorial, not commercial: this is an instalment in a running series that cites its own earlier parts, and series accrue readers by finding patterns. No vendor relationship, funding or sponsorship is disclosed anywhere, and the piece has no product to sell for Anthropic, OpenAI or Pi — it praises and faults each. Cutting the other way, the retraction costs the author credibility he had already banked, which is the cheapest possible signal to fake and the most awkward to actually publish.
Verifiable method, single voice
Confidence is capped by arithmetic, not by doubt about the author: one publisher, one reader, one clone, one day. Where the artifacts are public that ceiling barely matters, because anyone can repeat the count. Where they are not — Claude Code — nobody can, and no second publisher has come along to check any of it, so the interpretive layer about what sits outside the loop stands or falls on one person's reading of three codebases.
Follow any of these and your For You feed starts watching them — no settings page required.
leadership
A Government Switched Off Two Frontier Models. Your Board Will Want The Fallback Plan.1 distinct publisher
leadership
Serval's Catalyst mines the ticket queue for automation work, not the project backlog1 distinct publisher
build
The agent harness is the product: DeepSeek ships a runtime that routes to its rivals1 distinct publisher
build
Hash-anchored edits turn a lost race into an error, and that contract outranks the tool count1 distinct publisher