fix(server): avoid loading Codex history on resume - #8629
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This focused fix changes every resumed Codex session to request metadata-only history loading, altering the product's default resume behavior. Although the change is small and tested, its unconditional default behavior change warrants human review. You can add or adjust custom eligibility rules. Learn more. |
What Changed
Codex thread resume requests now send
excludeTurns: true, so app-server returns thread metadata without reconstructing and serializing the complete turn history.The generated protocol binding now includes the experimental
excludeTurnsfield that the pinned Codex schema omits. T3 already negotiates the experimental API. Focused tests cover both the encoded request and the runtime resume payload.Why
T3 only reads the resumed thread id, working directory, and model. Loading every historical turn wastes memory and can exhaust the server heap on large, image-heavy Codex rollouts. Reporters reproduced the crash with histories between 673 MiB and roughly 1 GiB.
Fixes #7075
Testing
vp test run packages/effect-codex-app-server/src apps/server/src/provider/Layers/CodexSessionRuntime.test.tspasses, 65/65vp run typecheckpasses inpackages/effect-codex-app-servervp run typecheckpasses inapps/server; it emits existing Effect suggestions outside the changed linesvp linton changed files passes; it emits five existingno-inline-schema-compilewarnings inschema.test.tsChecklist
Model: GPT-5.6 Sol
Harness: Codex in T3 Code
Note
Medium Risk
Changes Codex session resume on a hot path; behavior is narrower (metadata-only) but aligns with what the server already consumes and is covered by runtime and schema tests.
Overview
Codex session open now resumes with
excludeTurns: true, sothread/resumereturns thread metadata without serializing full turn history. Recoverable resume failures still fall back tothread/start; tests assert the resume payload includesexcludeTurnsplus the existing cwd/model/sandbox fields.The
effect-codex-app-servergenerator patches the pinned protocol schema to expose the experimentalexcludeTurnsfield onV2ThreadResumeParams, with generated types and an encode test so the flag is typed on the wire.This targets server heap exhaustion when large Codex rollouts (hundreds of MiB to ~1 GiB of history) were loaded even though resume only needs the thread id and basic session fields.
Reviewed by Cursor Bugbot for commit 46c75df. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Set
excludeTurns: trueinthread/resumerequests to skip loading Codex historyopenCodexThreadnow sendsexcludeTurns: truein thethread/resumepayload, requesting metadata-only resume without populatingthread.turns.ExperimentalTopLevelSchemaPropertiesmap soV2ThreadResumeParamsincludes the new optionalexcludeTurns?: booleanfield.thread/resumerequest carriesexcludeTurns: trueand that the schema encoder preserves it.thread/resumeresponses will no longer include turn history; any consumer relying on populatedthread.turnsafter resume must now fetch turns separately.Macroscope summarized 46c75df.