Skip to content

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

Open
nickmatteo wants to merge 2 commits into
pingdotgg:mainfrom
nickmatteo:codex/fix-codex-large-resume
Open

fix(server): avoid full history on Codex resume#6400
nickmatteo wants to merge 2 commits into
pingdotgg:mainfrom
nickmatteo:codex/fix-codex-large-resume

Conversation

@nickmatteo

@nickmatteo nickmatteo commented Aug 12, 2026

Copy link
Copy Markdown

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 for commit 0143edc. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 12, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

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.

@CDVolvik CDVolvik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Large Codex resume buffers full turn history and wedges the local backend

2 participants