Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): discard abandoned Codex replies after reconnecting #46778

Mergedwangfeng87(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/46778/headmerged by juliusmarminge View on GitHub

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.

    1. Pushedcf2a848

    2. 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.

      1. Start a new Codex thread and send: ZEBRA: Do not use any tools or run any commands. Reply directly with a 300-word essay about tide pools.
      2. Cut the first marked answer stream after 20 deltas and allow Codex to recover.
      3. Wait for completion, reload, and inspect the top of the conversation.
      BeforeAfter
      3763606d20cf2a8487fb
      Before: truncated abandoned draft persists above the full essay after reloadAfter: only the completed replacement essay remains after reload
      Before recovery and reload recordingAfter recovery and reload recording

      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:

      • Repeated disconnects within one turn were not exercised; each recorded run induced one disconnect.
      • Preservation when no nonempty replacement completes, preservation when the provider still reports the draft, and legitimate commentary retention were not exercised by this direct-answer reproduction.
      • Desktop and mobile clients were not exercised; proof covers the real server and web client.
    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged thisf0471c8

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.