Skip to content

fix(native-chat): only Codex's turn completion ends a Codex turn - #23682

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/codex-turn-ends-on-completion
Sep 29, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/codex-turn-ends-on-completion

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Codex fails a turn (for example "Selected model is at capacity"), it sends two messages: an error, and a few milliseconds later its own "this turn is finished, and it failed" message. Orca used to treat the error as the end of the turn and mostly ignore the finish message that followed. Now the error is only the message you read in the chat, and Codex's own finish message is the one thing that ends the turn. The failed turn is recorded the same way whether you watch it live or reopen the chat later.

What Changed

Before

  • A failed Codex turn was ended by its error frame. The finish message Codex sent right after it was dropped, so the stored turn kept the error's arrival time and never got Codex's own duration.
  • The same failed turn could be stored two ways. Live, it was "completed" with the verdict "failure". Read back from Codex's turn history, it was "interrupted" with the verdict "failure". Orca asks Codex to skip old turns when resuming, and both captured versions accept that, so the history path runs only for an older Codex that rejects it. Both shapes display the same, because structured chats read only whether a turn is running and take the verdict from "failure", but the stored records of one turn disagreed.
  • Codex records a failed turn's queued input after the error and before it finishes the turn. Orca had already closed the turn by then, so that input rewrote a turn that was already closed.
  • An error frame that named no turn ended whatever turn was running, even though Codex was still working on it.
  • Because a failed turn had two ends, fix(native-chat): a failed Codex turn keeps its failure and "Worked for" #23514 added a rule that the first end is final, and the unmerged fix(native-chat): turn facts come from the turn record, and /compact is a message the chat sends #23059 needed a second copy of that rule for a failed /compact.
  • The write queue and the journal disagreed about two lifecycle writes with the same settlement id. The journal keeps the first one. The queue kept the last one if the first had not been written yet.
  • The translator had code to clean up after a notification that was too big to read. The reader has had no size limit since the Codex records were uncapped, so that code could never run.

After

  • turn/completed is the only live end of a Codex turn. The failed completion arrives 0-32 ms after the error in every captured case, and it settles the turn with Codex's duration, its arrival time, and the start and send Orca already saw.
  • The error frame writes the same error row as before, inside the turn that is still open. A retrying error (willRetry: true) is unchanged: the turn keeps running.
  • A failed completion is stored as "completed, failed", live and on resume alike. Only an interrupted completion is stored as interrupted.
  • If Codex exits between the error and its completion, the existing exit sweep ends the turn as interrupted, with no verdict. It already does this for any turn open when Codex exits.
  • The first-end-final rule from fix(native-chat): a failed Codex turn keeps its failure and "Worked for" #23514 is gone from the translator (see "The fix(native-chat): a failed Codex turn keeps its failure and "Worked for" #23514 rule" below).
  • The same holds for a subagent's thread: its error no longer ends the subagent's open items, and its own completion does, a few milliseconds later. A subagent's status already came from its completion, so nothing on screen changes.
  • A lifecycle write whose settlement id is already queued is accepted and dropped, so the queue keeps the first write, as the journal does.
  • The unreachable oversized-notification cleanup and its test are deleted. A connection test now proves why it was dead: a notification bigger than the old 16 MiB limit arrives whole, and no oversized frame is reported.

For the user this is a small change on screen. The error message and the stop look the same. "Working" lasts the extra few milliseconds until Codex's finish message. Reopening the chat shows the stored record, as before, and that record now carries Codex's duration.

Why

One ending, from the provider's own completion. Codex decides that a turn failed at the moment it completes it: it keeps the error as the turn's last error, records any queued input, and then marks the completed turn failed because of that error. The completion is Codex's own record of the turn. It carries the verdict, the duration and the error. Ending on the error meant ending on half of that record and then guarding against the other half. With one end there is nothing to guard. The idempotence the old rule gave now comes from the settlement id, which the queue and the journal already key on.

Evidence. The real codex app-server was run with only the upstream model provider faked, on 0.141.0 (the oldest version Orca exercises; it is the pin in the SSH end-to-end test) and on 0.158.0 (the latest). It covered seven failure scenarios: model rejected, model too new for the CLI, "at capacity" by stream and by HTTP 503, stream dropped, connection refused, and /compact at capacity, plus a successful control and a turn with a bad working directory, which Codex accepted and completed normally. There were 13 turn-ending errors, and each was followed by a failed turn/completed for the same turn 0-32 ms later. An interrupt never sends error. On 0.158.0, connection refused retries for four minutes with willRetry: true and no completion, because the turn really is still open. A trimmed copy of those frame orders, with synthetic ids, is committed as a test fixture and replayed through the translator.

The #23514 rule. It is removed, because a duplicate completion does not occur and would not matter if it did.

  • Codex sends one completion per turn: finishing and aborting a turn both take the turn's task under the same lock, and whichever takes it sends the only completion. In the captures, 21 closed turns got 21 completions. A turn/interrupt sent 30 s after a failed completion got "no active turn to interrupt" and no second completion.
  • The only way Orca delivers a completion twice is the retry of a frame the sink refused, and a refused completion changes nothing. A new test refuses the completion once and shows the retry settles the turn once, with its start kept.
  • If a second completion did arrive, the settlement id keeps the first record when that record was written in one batch, which is the normal case. A journal test sends a second completion while the first is still queued and after it is written, and the first record survives both. Without the queue fix in this PR, the queued case fails. A first settlement big enough to be split into several batches has different batch ids, so a second completion after it would replace the turn row with a copy that lacks the start time. That needs a duplicate Codex does not send, so no guard is kept for it.

Alternatives rejected.

  • Keep ending on the error and keep the first-end-final rule. That means two ends for one fact, losing Codex's duration, closing the turn before Codex records its queued input, and adding a second copy of the rule for /compact.
  • Remember in memory that Codex said "failed", and apply it if Codex exits before completing the turn. The failure belongs to the completion, and that note would be a second copy of it that nothing re-derives. The exit sweep already ends the turn.
  • Store a failed completion as interrupted everywhere (the history shape). "Interrupted" is Codex's own status for a stopped turn, and Orca's for a turn open when Codex exited. A provider failure is a turn Codex completed and marked failed, which is also the shape failed turns have had live since fix(native-chat): end a structured turn when the agent reports it failed #22047.
  • Keep a translator-side duplicate guard. There is no evidence of a duplicate, and the settlement id already covers one.

Differences from the common pattern

  • An exit between the error and the completion. One common pattern marks every open turn failed when the provider process exits; others end the session and give the turn no verdict. Orca records the turn as interrupted with no verdict, because Orca records only an ending it observed: the exit is observed, and the failure Codex would have named arrives only in the completion that never came.
  • The error itself. The common pattern also flips a session-level status to "error" on the error frame. Orca keeps the error as a row in the turn, and the chat status is derived from the turn record, so there is no separate status to write.
  • No per-provider "this error ends the turn" switch. The common pattern keeps one for providers whose protocol has no completion after a fatal error. Codex always sends one, so Orca has none.
  • Where duplicates are absorbed. The first-write-wins rule lives in the durable settlement id, in both the queue and the journal, not in the Codex translator.

Linked Issue

This revisits #22044 ("a provider error that ends a turn leaves structured chat stuck on Working"), fixed by #22047. For Codex, #22047 ended the turn on the error, on the premise that Codex might never send turn/completed after it. Before #22047 a failed completion already ended the turn, so a stuck Codex chat needed a completion that never arrived. The captures found none: all 13 turn-ending errors were followed by their failed completion. The rest of #22047 is unchanged: Claude's idle still ends a Claude turn, and a Codex thread that stops running still releases a send whose dispatch was never answered. If a Codex build ever did skip the completion, the turn would read "Working" until Codex exits, when the exit sweep ends it.

It also follows up #23514, which left "end on turn/completed alone" for when there was a capture from the oldest Codex showing that the completion always follows the error. The captures above are that evidence. #23059 can then end a failed /compact on its completion the same way, instead of keeping its copy of the first-end-final rule.

Visual Proof

Live QA on a Mac with real Codex (an app-server launched by Orca, with a model the account rejects, which makes Codex send an error and then a failed completion for the same turn). Built at 85f3c6f; the later commits change tests only.

A failed Codex turn settles as one turn that reads Failed, with its "Worked for":

A failed Codex turn settles as one turn that reads Failed

Expanded, the model error row sits inside that turn:

The model error row is inside the failed turn

After restarting the app, the turn still reads Failed:

After an app restart the turn still reads Failed

Pressing Stop mid-answer (cases 3 and 4 ran in the same chat). The answer is cut off where Stop landed, with "Worked for 14s", and the tab's status dot is red; its label reads Interrupted. The stored record is interrupted with outcome cancellation. The transcript itself draws no stopped mark on that turn, which is the same on main and outside this PR:

After Stop: the answer is cut off, "Worked for 14s", and the tab's status is red (Interrupted)

A normal turn sent next in the same chat completes:

A normal turn: "name a fruit that is red", Worked for 2s, "An apple is a fruit that is red."

After it, that chat's tab shows a green check, the status of this newest turn (the other Codex tab, red, is the failed chat from case 1):

The chat's tab shows a green check after the normal turn completes

The stored turn record for the failed turn is completed with outcome failure, with its start time and a 1945 ms duration. It was unchanged 10 seconds later and after the restart. On main the same turn looks the same on screen but is stored at the moment the error arrived, with no duration.

Two things in these screenshots also appear on main and are not caused by this PR: the red "codex · notification:thread/status/changed" row, which is Codex's own "system error" status frame printed as a row, and a settled turn header whose screen-reader label still says "Agent is responding".

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Manual test: real Codex, launched by Orca on a Mac, with a model the account rejects, so Codex sends an error and then a failed completion for the same turn. The turn settled once and read Failed, with "Worked for 2s" and the error row inside it. Its stored record was completed with outcome failure and a 1945 ms duration, unchanged 10 seconds later and after an app restart. After Stop, the turn's stored record was interrupted with outcome cancellation and the tab read Interrupted (the transcript itself shows no stopped mark, as on main); a normal turn sent next completed. On main the failed turn looked the same on screen, but its record kept the error's arrival time and had no duration.

Each new test was written first and failed against main's behaviour, then passed after the change:

  • The captured frame orders replay to one terminal record per turn, with Codex's time, duration and verdict, and with the start Orca saw. 13 cases failed on main; the control, interrupt and bad-cwd cases passed on both.
  • An error followed by a failed completion is one "completed, failed" turn, with the start and the attributed send kept.
  • An error followed by an exit, with no completion, gives an interrupted turn with no verdict.
  • A send Codex echoes between the error and the completion revises the open turn.
  • A failed turn restored from history is "completed, failed".
  • The queue keeps the first lifecycle write for a settlement id.
  • An error that names no turn settles nothing.
  • A completion, live or restored, whose status Orca cannot place is completed with no verdict. Mapping it to interrupted again fails 3 tests, and giving it a success verdict fails 5.

Tests that pass on main too, and pin behaviour that must not change: an interrupt stays interrupted with outcome "cancellation", 0.158.0's four minutes of willRetry: true keep the turn running until the exit sweep ends it, and a completion the sink refused settles once on its retry.

Each behaviour was then broken on purpose to check its test fails: ending the turn on the error again (21 failures), a verdict on the exit sweep (2), the old failed-to-interrupted mapping (22), a queue that lets the later write win (2), an interrupt stored as completed (4), a retrying error that ends the turn (23), a capped stdio reader (2), and a completion that forgets the turn before the sink accepts it (1).

Lint, the changed-code quality gate, the main-process typecheck, and the Codex, agent-session-wire and journal unit tests (287 files) pass.

Notes

  • Wire and stored data. No wire change. The only row-shape change is that a failed turn/completed writes "completed, failed" instead of "interrupted, failed". That is the shape a failed turn already had live, so released clients read it. When Codex's turn history is restored, which happens only for a Codex too old to skip it on resume, a failed turn in it is written in the new shape. Rows already stored in either shape are left as they are and display the same.
  • SSH. The translator runs on the execution host, and the exit sweep reacts to that host's own observation that Codex exited. Nothing is inferred from losing contact.
  • Folder workspaces, Windows, Linux. No path or platform logic is touched.
  • Turn statuses. Codex's turn status is completed, interrupted, failed or inProgress, and a completion only ever carries the first three. An inProgress or unrecognised status on a completion is now stored as completed with no verdict, where it used to be stored as interrupted. A completion proves the turn ended, not how it ended. "Interrupted" would claim a stop nobody asked for, and a success verdict would claim a clean finish, which is what lights the "agent finished" notification. With no verdict Orca sends no finished notification and shows no Failed or Stopped mark.
  • Codex versions. Captured on 0.141.0 and 0.158.0. The behaviour comes from how Codex builds a failed turn, which is the same across that range.
  • The dispatcher's handling of oversized frames is unreachable for the same reason, including the frame:oversized-notification it still emits, which now falls through to an ordinary unhandled-frame row. It is left for a separate change, because it also covers responses and requests, which this PR does not touch.

Author X: @BrennanKB5

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

… the journal does

The journal applies a lifecycle batch's settlement id once and skips any later
batch with the same id. The deferred sink queue coalesced the same key the other
way: a second batch replaced the first while it was still queued. So which
record survived depended on whether the first had drained yet.

A lifecycle batch now keeps the queued operation with its key, and a later one
is accepted and dropped, which is what the journal does once the first is
written.
Codex follows every turn-ending `error` (willRetry=false) with a failed
`turn/completed` for the same turn, 0-32 ms later. That was captured from the
real app-server on 0.141.0 and 0.158.0 across eight failure scenarios, and it is
how Codex builds a failed turn: it records the error as the turn's last error,
records any pending input, and then derives `failed` from that error when it
completes the turn.

The translator ended the turn twice: once on the error, and again on the
completion, with a guard to make the first end final. Ending on the error threw
away what only the completion carries: Codex's duration, and the completion's
receipt time. It also forgot the turn before Codex recorded the turn's pending
input.

Now the error is only the row the user reads, inside the still-open turn, and
`turn/completed` is the turn's only live end. A process exit between the two is
the existing exit sweep's observed end, recorded as interrupted.

A failed completion is stored as completed with outcome failure, live and on
restore alike. Only `interrupted` maps to the interrupted state.

The first-end-final guard is gone. Codex sends one completion per turn, the only
redelivery Orca has is the retry of a refused frame (which changes nothing), and
the settlement id already keeps the first record in the queue and the journal.
…ment

The translator settled a streamed item when the transport rejected its
notification as oversized. Nothing can produce that frame. The Codex stdio
reader frames with `maxLineBytes: Number.POSITIVE_INFINITY`
(codex-app-server-record-reader.ts), which it has done since the app-server
records were uncapped. With an infinite limit the framer never reports
`line-too-long`: no line, pending suffix or paused queue can exceed it. So the
dispatcher never emits `frame:oversized-notification`, and the arm that settles
it never runs.

The arm, its helper module and its test go. In place of the test, the
connection test now proves the reason: a notification past the old 16 MiB wire
limit arrives whole, and no oversized frame is reported.
…h synthetic ones

The replay reads ids only to group frames, so the real thread, turn and
response ids from the capture account carry nothing the test needs. The
fixture moves beside the Codex tests that read it.
'cancelled' read as a stop being recorded as a completion.
…h no verdict

Codex's history carries the same status field as the live completion, so the
restore path is pinned to the same mapping: completed, and no outcome.
@brennanb2025
brennanb2025 marked this pull request as ready for review September 28, 2026 21:47
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how Codex turn completion is detected and settled.

The PR appears safe to merge; no actionable new failure was established.

Summary

The PR makes Codex’s turn/completed notification the live turn-ending event, records failed completions consistently with restored history, and makes queued lifecycle batches retain the first write for a settlement ID.

  • Error notifications remain rows within an open turn; an exit before completion settles that turn as interrupted.
  • Tests replay captured Codex frame orders and cover completion retries, queue deduplication, and uncapped notification delivery.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["turn/started"] --> B["Running turn"]
  B --> C["error notification"]
  C --> D["Error row; turn remains open"]
  D --> E["turn/completed: failed"]
  E --> F["Completed turn; failure outcome and duration"]
  D --> G["Provider exits before completion"]
  G --> H["Interrupted turn; no verdict"]
Loading

Reviews (2) · Last reviewed commit: "test(codex): a restored turn with a stat..."

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 24443289-ce58-4446-92ed-2f39a1848254

📥 Commits

Reviewing files that changed from the base of the PR and between fe7e13d and fdb16a8.

📒 Files selected for processing (20)
  • src/main/codex/__fixtures__/codex-app-server-turn-endings.jsonl
  • src/main/codex/codex-app-server-connection.test.ts
  • src/main/codex/codex-structured-journal-provider-verdicts.ts
  • src/main/codex/codex-structured-journal-settlement.ts
  • src/main/codex/codex-structured-journal-translation-frames.ts
  • src/main/codex/codex-structured-journal-translation-streams.test.ts
  • src/main/codex/codex-structured-journal-translation-turn-boundaries.ts
  • src/main/codex/codex-structured-journal-translation-turn-lifecycle.test.ts
  • src/main/codex/codex-structured-journal-translation-turn-settles-once.test.ts
  • src/main/codex/codex-structured-journal-translation-turn-state.ts
  • src/main/codex/codex-structured-journal-translation-turns.ts
  • src/main/codex/codex-structured-journal-translation-writers.ts
  • src/main/codex/codex-structured-journal-translation.test.ts
  • src/main/codex/codex-structured-journal-translation.ts
  • src/main/codex/codex-structured-journal-turn-endings-replay.test.ts
  • src/main/codex/codex-structured-journal-turn-settles-once-journal.test.ts
  • src/main/codex/codex-structured-thread-facts.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-sink-queue.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.ts
💤 Files with no reviewable changes (5)
  • src/main/codex/codex-structured-thread-facts.ts
  • src/main/codex/codex-structured-journal-provider-verdicts.ts
  • src/main/codex/codex-structured-journal-settlement.ts
  • src/main/codex/codex-structured-journal-translation-frames.ts
  • src/main/codex/codex-structured-journal-translation-streams.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Codex turn errors no longer settle turns as failures; turn/completed records the terminal lifecycle, with interrupted status mapping to an interrupted state. The translator records notifications and provider frames as unhandled, and a connection test checks delivery of a notification larger than 16 MiB. Lifecycle-batch queue submissions preserve the first queued operation for a settlement ID. Tests and captured traces cover turn outcomes, retries, timing, and queue behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to fdb16

Codex turns now end only when Codex reports completion, and failed turns are recorded as completed with a failure verdict. Captured traces show this holds today. A Codex version that emits a terminal error without a completion could leave a turn appearing to run. This is a small residual risk that the owner should be aware of.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to fdb16

The change makes failed turns more consistent, but turn completion now carries more responsibility for closing and attributing a turn. A duplicate or missing completion could leave the recorded lifecycle or its request attribution incomplete. No security exploit is established.

Retained concerns

  • Medium · reliability · inferred: A repeated completion can replace the recent in-memory record for an already settled turn without its start time, preventing a later exact-send echo from attaching request provenance. The first durable settlement remains protected, but the live attribution path can diverge from it.
  • Low · reliability · inferred: After an error, a connected provider that does not send completion leaves the turn open; the observed fallback interrupts open turns only when the session ends. This is a failure-containment concern conditional on the completion guarantee failing, not an established attack path.
Security review details

Security Blast Radius

  • inferred — The demonstrated effects concern Codex session lifecycle records, associated item and prompt settlement, and request attribution. The supplied evidence does not establish a broader tenant, credential, or deployment boundary change.

Trust Boundaries and Controls

  • observed — The local Codex process supplies completion IDs and statuses across the provider-to-journal boundary. The journal batch uses a settlement ID, while the changed queue preserves the first queued operation with that key; upstream provenance guarantees for completion IDs were not established.

Resilience and Maintainability Implications

  • observed — When the provider session ends, open primary-thread turns are written as interrupted without a provider verdict and active tracking is cleared after accepted settlement.

Hardening Proposals

  • proposed — Preserve the first recent-turn lifecycle on repeated completion, while allowing legitimate out-of-order completion for distinct active turns; verify that a late exact-send echo can still attach request provenance.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 14 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: only Codex turn completion ends a Codex turn.
Description check ✅ Passed The description is comprehensive and covers the required change, rationale, linked issues, visual proof, testing, compatibility considerations, and checklist. Some template sections are not explicitly…
Full details: Docstring Coverage

Explanation

Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 14 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — read the complete raw diff (20 files, 7 commits), traced the deleted symbols for dangling references, and ran the focused Codex/agent-session-wire suites (226 tests) plus pnpm tc:node, all green.

  • Only turn/completed ends a Codex turn — the error frame is now just a notification:error row inside the still-open turn. readCodexProviderVerdict, CodexJournalTurnBoundaries.fail()/end(), the first-end-final recentTurns.has guard, and CodexJournalActiveTurns.isActive are removed; a failed turn settles on Codex's own completion with its duration and the host start.
  • Failed completions store as completed, failed — codexTurnLifecycleState now maps only interrupted to interrupted; the same change applies to the restore/history path, so live and restored failed turns agree.
  • Sink queue agrees with the journal on first-write-wins — a per-operation keepsFirst flag drops a lifecycle batch whose lifecycle:<settlementId> is already queued, mirroring the reducer's applied-settlement-id rule. Set only on appendLifecycleBatch.
  • Unreachable oversized-notification path deleted — settler, its frame arm, and its test are gone; a new connection test proves a 16 MiB+1 notification arrives whole. frame:oversized-notification is still emitted and now falls through to a generic row, explicitly deferred to a separate change.
  • New evidence — a committed fixture of real 0.141.0/0.158.0 turn-ending frame orders (synthetic ids) replayed through the translator, plus journal-queue and refuse-then-retry settlement tests.

The one real trade-off — a Codex build that skipped the completion would leave the turn "Working" until the exit sweep marks it interrupted with no verdict — is called out in the PR body's rejected alternatives, and the chunk-splitting gap against a duplicate completion is likewise documented. Both are reasoned and acceptable.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 marked this pull request as draft September 28, 2026 23:06
@brennanb2025
brennanb2025 marked this pull request as ready for review September 28, 2026 23:17
@brennanb2025
brennanb2025 merged commit 94b5a7d into main Sep 29, 2026
100 checks passed
nwparker added a commit that referenced this pull request Sep 29, 2026
#23682 established that only `turn/completed` ends a Codex turn and deleted
`codex-structured-journal-provider-verdicts.ts`, but the child-turn reader kept
importing `readCodexProviderVerdict` and branching on its `turn-failed` verdict.
The module is gone, so the import resolves to nothing: typecheck and static
analysis fail on every pull request, which skips the whole unit matrix behind
them, and the esbuild pass behind Bun profile scope detection throws, so every
run falls back to all six platforms.

A closed thread is now the only child-turn end without `turn/completed`, which
is what #23682 intended: Codex follows a turn-ending `error` with a failed
`turn/completed` for the same turn 0-32 ms later, and that completion carries
the duration and receipt time the error does not.
nwparker added a commit that referenced this pull request Sep 29, 2026
…ot retry

#23801 removed the child-path reading of Codex's turn-ending `error` along with
the import of the module #23682 deleted. That was the wrong half to remove: the
primary journal path can rely on Codex's failed `turn/completed` arriving within
~32 ms, which is what #23682 established, but a child turn has no such
guarantee, and without the error as its end the child's lifecycle row latches on
`working` for the life of the session. Three tests assert exactly that and could
not run, because the unresolved import had been skipping the unit matrix since
#23682 merged.

The reading is restored inline against `readCodexErrorWillRetry`, itself restored
to `codex-structured-thread-facts.ts`, rather than by reviving the deleted
module: its `thread-stopped-running` arm lost its only consumer when #23682
rewrote the primary path, so restoring the file would re-add dead code.

Also drops `pr-workflow-parallelism.test.mjs`'s read of
`.github/workflows/track-community-prs.yaml`, which #23796 deleted while leaving
the assertion behind. Same failure class, and it fails the same shard.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…3614) into #23059

Conflicts, resolved to keep main's mechanism and #23059's turn facts:
- Codex turn boundaries and translator: main's #23682 wins; the error-driven
  `fail` end and the oversized-notification settler are gone, and only
  `turn/completed` ends a turn, a command's turn included.
- Codex adapter: the compaction tracker stays deleted; #23618's settlement of
  sends in an ended turn is kept, and `codexDispatchRejection` is imported from
  its new home.
- Journal reducer: main's per-item creating fence (#23456) moves into the item
  and submission folds this branch split out of the reducer.
- Stale-turn verdict: main's proof-of-death revision; every turn revision states
  the thread scope.
- Failure words: main's retry-control rules (#23608) with this branch's any-command
  retry step; `commandRefused` drops its retry step beside a Retry, as hostFault does.
- Delivery: both the commit wake and main's death-evidence resettle and dispose.
- Fold row and transcript slots: both the turn-outcome flag and main's `agentId`.
- pr.yml and pnpm-lock.yaml taken from main.

Beyond the conflicts, the merged files needed:
- use-structured-agent-session: both sides added the same `submissions` key; one kept.
- structured-agent-session-projection: the root-item import main still used is unused here.
- The desktop message list and the mobile chat view each grew past the line limit
  from both sides' additions: the turn-membership memo moves into its own hook, and
  the mobile list footer (live status, then waiting rows) into its own helper.
nwparker added a commit that referenced this pull request Sep 29, 2026
…ot retry (#23808)

#23801 removed the child-path reading of Codex's turn-ending `error` along with
the import of the module #23682 deleted. That was the wrong half to remove: the
primary journal path can rely on Codex's failed `turn/completed` arriving within
~32 ms, which is what #23682 established, but a child turn has no such
guarantee, and without the error as its end the child's lifecycle row latches on
`working` for the life of the session. Three tests assert exactly that and could
not run, because the unresolved import had been skipping the unit matrix since
#23682 merged.

The reading is restored inline against `readCodexErrorWillRetry`, itself restored
to `codex-structured-thread-facts.ts`, rather than by reviving the deleted
module: its `thread-stopped-running` arm lost its only consumer when #23682
rewrote the primary path, so restoring the file would re-add dead code.

Also drops `pr-workflow-parallelism.test.mjs`'s read of
`.github/workflows/track-community-prs.yaml`, which #23796 deleted while leaving
the assertion behind. Same failure class, and it fails the same shard.
brennanb2025 added a commit that referenced this pull request Sep 29, 2026
…ts own turn/completed (#23783)

* fix(native-chat): a Codex child's turn ends on its own turn/completed

#22553 ended a child thread's turn on an `error` Codex will not retry, reading
the verdict module #23682 deleted when it made turn/completed the only end of a
Codex turn. The two landed minutes apart with no textual conflict, so main no
longer typechecks.

Codex runs every thread's events, spawned children included, through the same
per-thread handler: a turn-ending error is recorded as the turn's last error and
the turn then completes as failed. So a child's failed turn/completed is its end,
as on the primary thread, and a closed thread stays the one child ending with no
completion.

* refactor(native-chat): a closed Codex child thread is its own frame

With a child's turn now ending only on its own turn/completed, the
turn-ended frame carried a fixed turnId (null) and state (unverifiable),
and endTurn took parameters nothing passed. Name the one remaining case:
a thread-closed frame, and closeThread ending the running turn as
unverifiable. Drop a test step that no longer exercised anything.
nwparker added a commit that referenced this pull request Sep 29, 2026
A merge resolution kept this module while main's #23682 removed the only
export it imports, so nothing built. Main already dropped the error path
it served.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant