Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): avoid full history on Codex resume #6400

Closednickmatteo(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/6400/headopened View on GitHub

Summary

  • resume Codex threads with the app-server's excludeTurns: true option
  • decode the raw experimental response with the existing typed response schema
  • preserve fresh starts and recoverable stale-resume fallback behavior
  • add a regression test for the exact resume wire payload

Why

T3 already persists and renders its own projected transcript, so it does not use the historical thread.turns returned by Codex during provider resume. On sufficiently large Codex rollouts, rebuilding and buffering that full JSON-RPC response can starve the local server before session/ready; Desktop then reports that /.well-known/t3/environment timed out even though port 3773 is still listening.

Codex exposes excludeTurns specifically for clients that only need thread metadata and the live resume subscription. T3 already initializes Codex with capabilities.experimentalApi: true. The generated request binding omits experimental request fields, so this follows the existing raw-request-plus-schema-decode pattern used by turn/start collaboration mode.

Fixes #6399

Related: #5351, #4773, #3601, #6153

Validation

  • pnpm vp fmt --check apps/server/src/provider/Layers/CodexSessionRuntime.ts apps/server/src/provider/Layers/CodexSessionRuntime.test.ts
  • pnpm vp test run apps/server/src/provider/Layers/CodexSessionRuntime.test.ts (21 passed)
  • cd apps/server && pnpm typecheck
  • git diff --check

The repository requests Node 24.13.1; these checks ran successfully on Node 26.5.1 with the package manager's engine warning.


Note

Medium Risk Touches Codex session open/resume on the critical path; behavior change is narrow (metadata-only resume) with fallback preserved, but large-thread readiness regressions are the main thing to watch.

Overview Codex thread resume no longer asks the app-server to rebuild and return full thread.turns history. openCodexThread now calls client.raw.request("thread/resume", …) with excludeTurns: true, since T3 already owns the projected transcript and large rollouts were starving the local backend before session/ready.

Resume responses are decoded through V2ThreadResumeResponse (same raw-request + schema pattern as turn/start). thread/start and recoverable resume → fresh start fallback are unchanged. Tests mock client.raw, align thread fixture shapes with the v2 schema, and assert the resume wire payload includes excludeTurns: true.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 0143edc56bb93ac80c3e61f1ee38b2200ffc4ed4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Exclude historical turns when resuming a Codex thread

  • Changes openCodexThread to use client.raw.request for thread/resume instead of the typed client.request, adding excludeTurns: true to the resume payload to avoid sending full history.
  • Decodes the raw resume response via a new decodeV2ThreadResumeResponse schema decoder, mapping decode failures to CodexAppServerProtocolParseError.
  • Recoverable resume failures still fall back to thread/start as before.
Macroscope summarized 0143edc.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: e30c18c5-7a8d-4ca8-a586-165bec91ec16

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: Needs human review

      This PR changes session resume behavior by adding excludeTurns: true, which prevents the backend from returning historical turns. While documented as a performance optimization, it materially affects what data is returned during resume. The author is not the primary maintainer of this file, suggesting additional review is warranted.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. CodexSessionRuntime.test.ts: 21/21.

      Resuming with a full history replay is slow and can re-emit old events. Avoiding that on resume is correct. MERGEABLE. Related to #6671 (missing rollout) — they touch the same file; rebase if both land.

    5. Adding user-impact and workaround evidence for #6399. I run the T3 backend under Ubuntu/WSL2 with remote desktop clients. An affected Codex rollout was approximately 275 MB.

      After applying an equivalent excludeTurns: true resume change locally, the affected thread resumed, answered a test request, and returned to ready. Updating from 0.0.34-nightly.20260825.1187 to 0.0.35-nightly.20260826.1193 installed a fresh bundle, requiring us to reapply and validate the patch. The provider CLI currently installed is codex-cli 0.147.0.

      I now have to maintain this workaround across updates to keep existing long-running threads usable. This validates our local equivalent change, not the complete PR test suite.

      I'd appreciate an upstream resolution—whether this PR or another implementation—and can help test a candidate build or provide sanitized diagnostics.

      Agent-assisted investigation and drafting: OpenAI Codex; exact model variant not recorded.

    6. Closing as a duplicate of #8629, which carries the same excludeTurns: true resume fix through the generated protocol binding. Keeping review there; the linked resume issues remain open until the fix lands. Thanks for the investigation and workaround validation.

    7. juliusmarminge closed this

Sign in to join this conversation.