fix(server): avoid full history on Codex resume #6400
main fromrefs/pull/6400/head·opened View on GitHubSummary#
- resume Codex threads with the app-server's
excludeTurns: trueoption - 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.tspnpm vp test run apps/server/src/provider/Layers/CodexSessionRuntime.test.ts(21 passed)cd apps/server && pnpm typecheckgit 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.
Note
Exclude historical turns when resuming a Codex thread#
- Changes
openCodexThreadto useclient.raw.requestforthread/resumeinstead of the typedclient.request, addingexcludeTurns: trueto the resume payload to avoid sending full history. - Decodes the raw resume response via a new
decodeV2ThreadResumeResponseschema decoder, mapping decode failures toCodexAppServerProtocolParseError. - Recoverable resume failures still fall back to
thread/startas before.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Needs human review
This PR changes session resume behavior by adding
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).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.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.
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: trueresume change locally, the affected thread resumed, answered a test request, and returned to ready. Updating from0.0.34-nightly.20260825.1187to0.0.35-nightly.20260826.1193installed a fresh bundle, requiring us to reapply and validate the patch. The provider CLI currently installed iscodex-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.
Closing as a duplicate of #8629, which carries the same
excludeTurns: trueresume 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.juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
e30c18c5-7a8d-4ca8-a586-165bec91ec16You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share