fix(server): fork Codex threads with active writers - #7414
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Straightforward bug fix adding error recovery for 'active writer' conflicts by forking threads instead of failing. Follows existing error handling patterns in the same file, has limited scope, and includes comprehensive test coverage. You can add or adjust custom eligibility rules. Learn more. |
|
Hit this in the wild today on The other writer was ChatGPT Desktop's bundled app-server ( So the fork fallback here is the right call, since Desktop won't hand the lock back while it's running. One thing worth surfacing in the UI: after a fork the T3 task continues on a new thread id, so anything sent to the old thread from Desktop afterward won't appear in T3. A short note in the chat that the thread was forked because another app owned it would make that divergence visible instead of silent. |
|
Hitting this today on the current stable Windows build, multi-account Codex setup (shared Matches the fix described here exactly — the first account's app-server process is still holding the writer lock when the second account's process tries +1 for merging. |
|
closing this version as part of a pr cleanup at the request of @StiensWout. automatically forking on an active-writer conflict changes the native conversation identity without a user-facing explanation. recovery is useful, but the fork and resulting divergence should be explicit to the user, with a recovery choice where appropriate, rather than only recorded in a server log. thanks for the contribution. if you disagree with this decision, you are welcome to open a new pr, link back to this one, and explain how your proposal addresses these concerns or why a different approach is warranted. |
Problem
Codex rejects
thread/resumewhen another app-server process already owns the thread writer. T3 currently stops the session and surfaces the provider stack trace, even though Codex can branch the conversation safely.Fix
Detect the specific active-writer response and call
thread/forkwith the requested working directory, model, service tier, approval policy, and sandbox mode. T3 then stores the forked thread ID and continues from the persisted conversation history. Missing-thread fallback and unrelated resume failures keep their existing behavior.Tests
vp test run apps/server/src/provider/Layers/CodexSessionRuntime.test.tsvp run --filter ./apps/server typecheckModel: gpt-5.6-sol
Harness: T3 Code Codex
Note
Medium Risk
Changes Codex session open/resume behavior on a specific provider error path; incorrect detection could fork when a fresh start was intended, but scope is narrow and covered by tests.
Overview
When
thread/resumefails because another Codex app-server process already holds the thread writer, the server no longer surfaces a fatal error. It detects that case viaisThreadActiveWriterError, logs a warning, and callsthread/forkwith the session’s cwd, runtime mode (approval policy and sandbox), model, and optional service tier so the conversation can continue from persisted history under a new provider thread id.Missing-thread and other recoverable resume failures still fall back to
thread/start; unrelated resume errors are unchanged. Tests cover the detector, the resume→fork path, and existing fallback/propagation behavior.Reviewed by Cursor Bugbot for commit e884bb3. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fork Codex threads when
thread/resumefails with an active writer errorisThreadActiveWriterErrorpredicate inCodexSessionRuntime.tsthat detects errors containing both 'thread' and 'already has an active writer'.thread/resumefails with this error,openCodexThreadnow callsthread/forkinstead of failing or starting a fresh thread, preserving thread continuity.CodexThreadOpenResponseandCodexThreadOpenMethodtypes are extended to includethread/fork.Macroscope summarized e884bb3.
Closes #8259