Problem#
After a Codex upstream stream disconnects with a retryable HTTP 429, T3 can keep several drafts from one successful turn as replies. This was observed with the desktop host and a mobile client.
The replay in this PR starts and streams a final_answer item, emits error with willRetry: true, and repeats the sequence twice. The abandoned items never receive item/completed. A replacement item completes, followed by a successful turn/completed. On the base, the turn-end buffer drain promotes the abandoned drafts to completed replies. The settled turn should retain the completed reply and any legitimate commentary.
Change#
Track final-answer items open at a retryable Codex error. On successful turn completion, withdraw a superseded draft when the provider's final item list omits it and a nonempty replacement completed. The web and mobile timelines hide withdrawn empty messages. A draft can remain visible during recovery, and a provider can finish a replacement under a new or reused item ID.
Scope#
Follow-up to #19349 and #18652. The merged #19023 keeps a held draft in its original position. This change addresses the additional completed replies left by multiple retry attempts after the final answer is already correctly positioned.
Verification#
- Codex adapter replay on main at
57c1ddc8: 260 tests passed with the patch. The three new cases use a new final ID or reuse the first or last draft ID. The event assertions retain “Checking the sources” and “The completed reply” and settle the previously streamed draft.
- Web session logic: 54 tests passed. A draft already on screen disappears from the projected timeline after its replacement completes.
- Scoped lint, formatting and
git diff --check passed. The full check:changed run hit missing dependencies in the local workspace. The mobile feed case is included for CI, and an on-device check is pending.
- The reproduction uses synthetic provider messages.
Written and verified with GPT-6.2 Sol in Codex, running in T3 Code.
Evidence#
Linux, Chromium, 1280×800, light theme; real Codex CLI 0.172.0 with GPT-6.1-Sol (low). Separate fresh app databases and synthetic project data on both commits. The proxy forwards actual upstream responses and cuts one stream after 20 answer-text deltas; it generates no responses.
ZEBRA: Do not use any tools or run any commands. Reply directly with a 300-word essay about tide pools.Base retained two replies, including the draft ending “Along rocky shores, seaw”. Head kept the draft visible during recovery, then removed it when the replacement completed; reload retained only the completed essay. Head was repeated with the same fault for the recording; its still is from the preceding successful run. Both head runs passed. Stills were checked for stability and all captures were visually inspected.
Reproduction driver · Forwarding fault proxy · Run instructions · Base proxy events · Head proxy events
Not shown: