Skip to content

fix(server): stopping Codex during startup no longer loses its accepted turn - #49435

Merged
juliusmarminge merged 7 commits into
pingdotgg:mainfrom
StiensWout:wf/find-d5ee1dd78723363e5e2ae31f
Dec 5, 2026
Merged

juliusmarminge merged 7 commits into
pingdotgg:mainfrom
StiensWout:wf/find-d5ee1dd78723363e5e2ae31f

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Pressing Stop while a Codex message was still starting could leave Codex running the turn it had already accepted: T3 forgot the pending start, so the late turn/started was filed as an untracked subagent turn that Stop could no longer reach. The Codex adapter now keeps the pending root turn when its start is interrupted after turn/start was sent, and clears it once the turn registers, so the delayed start becomes the run's turn and Stop can interrupt it.

Related: #24439, #35440

Reproduction on main

Commit 3ab8694e2d (main). The conversation looks stopped while Codex starts the accepted message. T3 has forgotten that running turn, so further stop handling cannot target it. Expected: Stop prevents the message from starting or interrupts the accepted message when its delayed start arrives.

  1. Open a Codex conversation.
  2. Send a message.
  3. Press Stop while the message is still starting, before its start acknowledgment reaches T3.

The cause is at apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts:8515, startNativeTurn's finalizer removes pendingRootTurns when startup is interrupted even if Codex already accepted turn/start. The late turn/started then falls through to rememberSubagentTurnStarted at line 5852 instead of retaining the root turn's ownership. No active root context remains for interruptTurn.. Ran cd apps/server && pnpm exec vp test run src/orchestration-v2/Adapters/CodexAdapterV2.test.ts --testNamePattern '\x6beeps\x20an\x20accepted\x20root\x20turn\x20stoppable\x20after\x20startup\x20is\x20cancelled\x20before\x20acknowledgment' with the repro test added. It failed in 3 of 3 runs on a clean boat.dev VM, with expected 'Failure' to be 'Success' in the output. The test runs from a Replay transcript fixture. The live provider reproduced the same failure.

Evidence

Environment: Linux x64 on a boat.dev VM reset before each run, the repository's own tests.

Proven: the repro fails at the test commit 739c6acfa9 and passes on the head 2ec4963657, both on main c8586cabf8.

Before After
Commit 739c6acfa9 2ec4963657
Result failed with "expected 'Failure' to be 'Success'" passed

Tests

  • 739c6acfa9 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed c8586cabf825e43b596071174c2a00e60b875439 passed on head.

Not in this change

  • The regression test keeps its recorded Replay transcript; a shorter inline replay version was possible but is not part of this change.
  • A turn/start that times out (rather than being interrupted) still drops its pending root turn, so a later turn/started is not adopted.
  • If Codex never starts an interrupted turn, its pending entry stays until the next turn start on that thread replaces it.
  • compactThread still clears its pending entry on any error, including interruption after thread/compact/start was sent.

Who did the work

  • Repro written by GPT 6.1 Sol, in Codex
  • Duplicate check judged by Gemini 4 Neon, in Antigravity
  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by Gemini 4 Neon, in Antigravity, and by GPT 6.1 Sol, in Codex
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by Gemini 4 Neon, GPT 6.1 Sol and Claude Opus 5.5

StiensWout and others added 5 commits December 5, 2026 14:55
…pable

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…ed turn

When Stop interrupts a Codex turn start after turn/start was sent, keep the
pending root turn so a late turn/started registers it as the run's turn
instead of an untracked subagent turn that Stop cannot reach.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Replace the recorded transcript with an inline replay that interrupts the
start while Codex's turn/start reply is held back.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Dec 5, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Dec 5, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 3c821c4

Macroscope's review found this PR approvable — The adapter preserves tracking of an accepted Codex turn when startup is interrupted, allowing Stop to reach it when its delayed start notification arrives. The change is limited to turn ownership and cleanup, with no product-default or permission changes.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 5, 2026
juliusmarminge and others added 2 commits December 5, 2026 14:11
The recorded transcript test also carried a live-provider branch and a
44-line fixture; the inline replay proves the same regression without them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review December 5, 2026 14:15

Dismissing prior approval to re-evaluate 3c821c4

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Dec 5, 2026
@coderabbitai

coderabbitai Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

CodexAdapterV2 now preserves a pending root-turn entry when an accepted turn/start is interrupted. A regression test verifies that a later turn/started notification registers the turn, and that stopping it produces an interrupted terminal event.

Changes: Codex accepted-start cancellation

Layer / File(s) Summary
Preserve pending root turns after interruption
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
Pending root-turn entries track whether turn/start was sent. An interrupted sent start retains its matching entry until root-turn registration clears it. The test checks that a late turn/started notification registers the turn and that stopping it ends the turn as interrupted.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge, saphid, t3dotgg

Merge Risk: Minimal · up to 3c821

This change fixes a startup race so a delayed turn start can still be stopped. No concrete merge-blocking risk was found in the changed code.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: stopping Codex during startup no longer loses its accepted turn. The raw summary says the adapter now keeps the pending root turn when turn/start was sent and then int…
Description check Passed The description follows the template. It has a Problem section that explains the Stop race and expected behavior, and a Change section that explains the retained pending root turn. It names a Scope vi…
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.
Full details: Title check

Explanation

The title names the main change: stopping Codex during startup no longer loses its accepted turn. The raw summary says the adapter now keeps the pending root turn when turn/start was sent and then interrupted, so a late turn/started registers as the run's turn. The title is specific and matches the changeset. It uses the conventional commit form with the fix(server) scope.

Full details: Description check

Explanation

The description follows the template. It has a Problem section that explains the Stop race and expected behavior, and a Change section that explains the retained pending root turn. It names a Scope via a linked issue set (#24439, #35440), but it does not clearly say why the fix is a bug fix or whether a maintainer requested it. The Verification section gives a concrete before/after test result, the commands run, and the commits. It also states what is not covered. The Scope section is thin, and the author should state explicitly why the change needs no separate issue or link the bug issue that shows the defect.

Resolution

Optionally, state the bug issue that shows this defect, or say why no issue is needed. Also state whether a maintainer requested the PR. The rest of the template is filled in.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c344f33 and 3c821c4.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts

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

@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Real web/server app on fresh per-commit databases; browser 1280×800, light theme; Codex CLI 0.174.0, OpenAI API-key mode via the configured endpoint, GPT-6.1-Sol / Low / Full access. Same default project, new draft state, prompt and scripted Stop on each side. No copied database or replay provider.

On each commit, start the real web/server app with T3CODE_DEV_SEED=0 and a fresh database. In Settings → Providers set Codex's binary path to the ordered delay proxy around installed Codex 0.174.0. Open a new draft in the default server project, select GPT-6.1-Sol / Low / Full access, collapse sidebar and thread details. Send 'Write the numbers from 1 to 150 as English words, one per line. No tools.' Click Stop generation four seconds after submission. The proxy holds every stdout message from the first native turn/start acceptance response for eight seconds, then releases all messages in original order. Continue capturing beyond native turn/completed.

Before After
c344f335ab 3c821c4a22
Before: stopped UI while native Codex continues After: stopped UI and native Codex interrupted
Before recording After recording
Native turn accepted at proxy +1.013s; stream released +9.001s; zero turn/interrupt requests; native turn completed +16.670s with all 150 lines. Native turn accepted at proxy +1.677s; stream released +9.625s; targeted turn/interrupt +9.659s; native turn completed interrupted +9.719s.
Native protocol · 150-line native output Native protocol · Native output: none

The UI alone looks normally stopped on both commits: this is a native ownership/cost defect. The newly captured real-provider traces establish the difference; the empty before screenshot is not itself evidence of failure. The head capture contains no late assistant numbers. Both runs preserve stdout order, so deltas cannot overtake turn/started. Screenshots were checked for stability and captures inspected.

Ordered delay proxy · Reproduction driver and environment · Browser submission/Stop timestamps and UI text. The proxy export uses portable paths; protocol extracts omit private setup/context and retain actual turn events, start response, assistant deltas and completion.

Not shown:

  • The stopped UI still says 'Run interrupted before provider start' on both commits even though native acceptance occurred. This proof establishes native interruption, not correction of that wording.
  • The previously reported late partial-output inconsistency did not appear in these order-preserving runs. This single timing does not establish behavior when assistant text has already been emitted and buffered before Stop reaches Codex.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 5, 2026
@juliusmarminge
juliusmarminge merged commit 8b306d5 into pingdotgg:main Dec 5, 2026
59 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 5, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Dec 6, 2026
**v0.1.15-nightly.20261205.5786** · 61 changes from 12 contributors

- **Large file previews.** Load remote files that exceed the automatic preview limit.
- **Project-specific MCP servers.** Import configurations with the same name and command but different credentials or headers.
- **GitHub issue forms.** Use issue templates with numeric or boolean options and empty optional fields.
- **Cursor text generation.** Generate commit messages, branch names, and thread titles with Cursor again.
- **Workflow reasons.** Unsent workflow question reasons now survive an environment reconnect.
- **Shared worktree protection.** Deleting a thread no longer removes a worktree another thread started using during confirmation.

### Plus 53 more bug fixes and performance improvements.

<details>
<summary>Full changelog</summary>

## What's Changed
* fix(server): stopping Codex during startup no longer loses its accepted turn by @StiensWout in pingdotgg/t3code#49435
* fix(workflows): open invoked runs from older workflows by @UtkarshUsername in pingdotgg/t3code#49437
* fix(web): omit inverted line range on empty file reads by @only21mil in pingdotgg/t3code#49452
* perf(server): t3 --version no longer loads the whole CLI by @juliusmarminge in pingdotgg/t3code#49461
* fix(preview): let users load oversized files by @Yash-Singh1 in pingdotgg/t3code#49470
* fix(mobile): a saved draft waits for a project choice when its project is removed by @StiensWout in pingdotgg/t3code#49455
* fix(client-runtime): file previews refresh when a background command finishes late by @StiensWout in pingdotgg/t3code#49458
* fix(server): fixed-time scheduled tasks interrupted before dispatch no longer skip the slot by @taogezhizun in pingdotgg/t3code#49417
* perf(web): reuse the read-only file preview cache key by @UtkarshUsername in pingdotgg/t3code#49464
* fix(shared): thread find no longer matches across line breaks in user HTML by @only21mil in pingdotgg/t3code#49449
* fix(web): ignore Shift and Alt on prompt stash delete shortcut by @only21mil in pingdotgg/t3code#49473
* fix(server): failed updates no longer lose recent data when the database is symlinked by @StiensWout in pingdotgg/t3code#49459
* fix(shared): relative file links with ../ resolve to the normalized path by @juliusmarminge in pingdotgg/t3code#49479
* fix(test): VcsStatusBroadcaster checkout test no longer flakes when HEAD.lock events arrive apart by @t3dotgg in pingdotgg/t3code#49494
* fix(server): fresh-session task waits while its previous occurrence awaits background work by @juliusmarminge in pingdotgg/t3code#49490
* fix(server): finish force stop when the target run settles by @UtkarshUsername in pingdotgg/t3code#49486
* perf(client-runtime): recording a thread open no longer replaces quiet thread shells by @shivamhwp in pingdotgg/t3code#49475
* perf(server): Read saved previews for live workflow lists by @UtkarshUsername in pingdotgg/t3code#49484
* fix(server): commit on new branch waits for a multi-repository worktree thread by @StiensWout in pingdotgg/t3code#49482
* fix(web): only capture keybindings while recording a SnapShot shortcut by @only21mil in pingdotgg/t3code#49489
* fix(web): ignore extra modifiers on workflow editor save shortcut by @only21mil in pingdotgg/t3code#49506
* fix(server): SSH readiness check retries after an interrupted response by @StiensWout in pingdotgg/t3code#49512
* fix(web): importing an MCP server keeps other projects' configurations available by @StiensWout in pingdotgg/t3code#49516
* fix(web): ignore Shift, Alt, and IME composition on spreadsheet copy by @only21mil in pingdotgg/t3code#49520
* fix(web): Word previews handle malformed links and spaced internal parts by @only21mil in pingdotgg/t3code#49519
* fix(shared): byte sizes just under the next unit no longer read "1024 KB" by @dev-dami in pingdotgg/t3code#49524
* fix(server): connecting during a checkout keeps the current Git status by @StiensWout in pingdotgg/t3code#49526
* fix(server): keep content search highlights and whole-word matches accurate on non-UTF-8 lines by @only21mil in pingdotgg/t3code#49535
* fix(web): image annotation shortcuts ignore extra modifiers and work with CapsLock by @only21mil in pingdotgg/t3code#49534
* fix(web): show the linked workflow run in All runs by @UtkarshUsername in pingdotgg/t3code#49543
* fix(provider-core): surface Codex managed requirements rejections for granular approval policies by @vibecodooor in pingdotgg/t3code#49540
* fix(web,mobile): choosing a question option sets an image-only answer aside by @juliusmarminge in pingdotgg/t3code#49517
* fix(server): MCP PR review comments preserve the old path on renamed files by @only21mil in pingdotgg/t3code#49557
* fix(server): creating a missing workflow helper makes its workflow load by @StiensWout in pingdotgg/t3code#49562
* fix(github): accept YAML scalars and empty keys in issue templates by @only21mil in pingdotgg/t3code#49558
* fix(server): a stalled cancellation cleanup no longer holds up other workflows' timeouts by @StiensWout in pingdotgg/t3code#49561
* fix(mobile): Usage cache savings ratio uses the app language's decimal separator by @tiliakoos in pingdotgg/t3code#49560
* fix(server): restarting after a pool place is given back keeps the requested resume by @StiensWout in pingdotgg/t3code#49567
* fix(server): retrying a failed project action save now saves it by @StiensWout in pingdotgg/t3code#49573
* fix(server): client connections no longer start Xwayland on Linux by @juliusmarminge in pingdotgg/t3code#49596
* fix(mobile-nitro): Android draft screen matches React Native's header, font and composer by @juliusmarminge in pingdotgg/t3code#49441
* fix(workflows): an agent step's turn no longer waits on its issue tracker by @Kamo2323 in pingdotgg/t3code#49582
* fix(mobile-nitro): a list shows its new rows at once when all of them are replaced on Android by @juliusmarminge in pingdotgg/t3code#49454
* fix(mobile-nitro): Android text fields are readable in dark mode by @juliusmarminge in pingdotgg/t3code#49466
* fix(web): unsent workflow reasons survive an environment reconnect by @StiensWout in pingdotgg/t3code#49603
* fix(server): service install after uninstall no longer refuses as a downgrade by @juliusmarminge in pingdotgg/t3code#49611
* fix(web): deleting a thread keeps a worktree another thread started using by @StiensWout in pingdotgg/t3code#49599
* fix(web,mobile): voice model benchmarks use the app language's decimal separator by @tiliakoos in pingdotgg/t3code#49581
* fix(cursor): Cursor text generation uses Composer 2.5 instead of the retired Composer 2 by @juliusmarminge in pingdotgg/t3code#49614
* fix(mobile-nitro): iOS text inputs use the app theme's colors by @juliusmarminge in pingdotgg/t3code#49509
* fix(mobile-nitro): Android survives Activity recreation (blank screen, colour scheme crash) by @juliusmarminge in pingdotgg/t3code#49572
* fix(mobile-nitro): a tap on a markdown link opens it, and thread links open their thread by @juliusmarminge in pingdotgg/t3code#49546
* fix(server): device access error says the setting is in desktop or web settings by @juliusmarminge in pingdotgg/t3code#49616
* fix(server): OpenCode commands no longer stay running after a failed status check by @StiensWout in pingdotgg/t3code#49602
* feat(mobile-nitro): user message links, thread chips and mentions match React Native by @juliusmarminge in pingdotgg/t3code#49569
* fix(mobile-nitro): Android markdown draws chips, mentions and quoted links like iOS by @juliusmarminge in pingdotgg/t3code#49590
* fix(mobile): guide file links open hidden test files by @StiensWout in pingdotgg/t3code#49600
* fix(server): workflows retry an engine that did not start after a reload by @StiensWout in pingdotgg/t3code#49563
* fix(mobile-nitro): choosing another project drops the draft's pull request by @StiensWout in pingdotgg/t3code#49597
* fix(mobile): pull request diffs no longer mix revisions after reconnecting by @StiensWout in pingdotgg/t3code#49607

## New Contributors
* @dev-dami made their first contribution in pingdotgg/t3code#49524
* @vibecodooor made their first contribution in pingdotgg/t3code#49540

**Full Changelog**: pingdotgg/t3code@v0.1.14-nightly.20261205.5772...v0.1.15-nightly.20261205.5786

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.15-nightly.20261205.5786
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants