fix(server): Codex forks no longer request full turn history#24537

open3
main
fix/issue-24460
opened1d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 1d ago

Problem

Forking a Codex conversation requested its complete historical turns even though T3 only consumes the returned thread metadata. Large histories can exceed the app-server transport limit. A real web fork on main sent no excludeTurns flag and returned the source turn.

Change

Send excludeTurns: true on the existing typed thread/fork request. Keep the inclusive selected-turn boundary and fork-local revert fallback. Add a regression for the outgoing request and update exact replay expectations used by existing tests.

Scope and approval

Fixes https://github.com/pingdotgg/t3code/issues/24460

GitCafe: #24460

Triaged bug via the automated issue flow. This is a focused fix to avoid transferring unused provider history; it adds no settings or persisted state.

Verification

  • Regression failed before the fix because excludeTurns: true was missing from the actual outbound frame; it passes with the fix.
  • All 87 tests across CodexAdapterV2.test.ts, ThreadFork.integration.test.ts, and ThreadMergeBack.integration.test.ts pass. The old integration fixtures reproduced two failures before their request expectations were updated. Server typecheck passes. Targeted lint has no errors and two preexisting unused-variable warnings.
  • Final scoped run at df41a3727c: 87 passing tests.
  • Real dev web app on Linux with Codex CLI 0.163.0: a fresh source has a completed marker turn; the fork request sends excludeTurns: true and the selected lastTurnId; its response has turns: []; continuation on the returned native thread recalls the marker without the follow-up supplying it.
  • No client contracts or render paths change. The visual fixture matrix is empty.

Evidence index and reproduction steps, extraction script, empty fixture matrix.

The reporter's private 590 MB history and old global hang were not reproduced. The runtime proof establishes response-history suppression and retained fork context on small valid history. The attempted synthetic rollout-only enlargement was discarded because it did not produce a valid large-history fixture. Other Codex versions and native client shells were not exercised.

Models: Claude Opus 5.5 through the Claude harness; GPT-6.1-Sol through the Codex harness in T3 Code.

Checks

22 successful · 7 skipped
All checks passed
df41a37

Added 3 commits

  • test(server): reproduce Codex fork requesting full turn history (#24460)184fa0f
  • fix(server): Codex fork no longer requests full turn history (#24460)325c7af
  • test(server): Codex fork replay fixtures expect excludeTurns (#24460)df41a37
Synced from GitHub

Approvability

Verdict: Approved at df41a37

Macroscope's review found this PR approvable — This focused server fix adds excludeTurns: true to Codex fork requests, avoiding oversized unused history responses while preserving fork boundaries and continuation behavior. The production change is isolated and covered by targeted tests and updated replay fixtures.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB+7 B (+0.1%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.2 KiB+7 B (+0.6%)2.0 KiB✅
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: 8176b58 · PR result: df41a37 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 8176b589310fac6f59f1878ede4f7287c6c36d8f and df41a3727c9e76846a5c56e3529290c08601a162.

External image Files selected for processing: 4
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
  • apps/server/src/orchestration-v2/testkit/fixtures/thread_fork_native_prior_turn/codex_transcript.ndjson
  • apps/server/src/orchestration-v2/testkit/fixtures/thread_merge_back_siblings/codex_transcript.ndjson

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The Codex adapter now sends excludeTurns: true with thread/fork. Replay tests and fixtures cover fork requests, including a native turn-boundary case where the fork response contains metadata only.

Changes: Codex fork request

Layer / File(s)Summary
Fork request and replay coverage
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts, apps/server/src/orchestration-v2/testkit/fixtures/*
forkThread adds excludeTurns: true. Replay coverage checks the request parameter and verifies that a native turn-boundary fork succeeds from thread metadata without a subsequent outbound request. Fixtures update the expected fork requests.

Priority: External image Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: t3dotgg, only21mil

Merge Risk: External image Minimal · up to df41a

The fork change is mergeable on the supplied evidence; no actionable risk remains beyond normal checks.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check nameStatusExplanationResolution
Linked Issues checkInconclusiveDirectly linked issue #24460 has one active coding target: the fork path must send excludeTurns: true. Evidence supports this. The test diff in CodexAdapterV2.test.ts adds excludeTurns: true to the ex…Establish whether the reviewed head already has a test that asserts pending requests complete with an error when the transport reader fails. If it does not, the missing evidence is a test result or a code reference for that behavior. Also c…
Passed Passed checks: 3 passed
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the main change: Codex forks no longer request the full turn history.
Description checkPassedThe description covers the problem, change, scope, linked issue, regression tests, integration tests, typecheck, lint, and runtime verification. It also states known verification limits.
Out of Scope Changes checkPassedAll changes relate to the fork request named in #24460. The adapter change adds excludeTurns: true to the existing thread/fork request. The CodexAdapterV2.test.ts changes update the exact replay expec…
Full details: Out of Scope Changes check

Explanation

All changes relate to the fork request named in #24460. The adapter change adds excludeTurns: true to the existing thread/fork request. The CodexAdapterV2.test.ts changes update the exact replay expectation for that request and add a regression for the inclusive-boundary fork. The two fixture changes update the outbound thread/fork frames in the same way, and the merge-back fixture also records the sibling forks' merge result. No settings, persisted state, client contracts, or render paths change, consistent with the PR description and the changed-file list. The adapter hunk could not be read directly, so this verdict relies on the AI summary of that hunk and on the matching test expectations. The changed-file list shows no unrelated file.

Full details: Linked Issues check

Explanation

Directly linked issue #24460 has one active coding target: the fork path must send excludeTurns: true. Evidence supports this. The test diff in CodexAdapterV2.test.ts adds excludeTurns: true to the expected thread/fork outbound frame in the paginated-history fallback test. A new test asserts that forking at the inclusive lastTurnId (native-turn-first) sends excludeTurns: true, returns the fork metadata, and sends no further request. The fixture diffs for thread_fork_native_prior_turn and thread_merge_back_siblings update the same outbound frames. The PR summary reports a runtime check with Codex CLI 0.163.0 that shows the same request and an empty turns response. The forkThread hunk in CodexAdapterV2.ts could not be read directly (changed blob unavailable). Its +1 line change rests on the AI summary and the matching test expectations. The issue also asks for focused coverage of pending-request completion when the transport reader fails. The changed files do not include a test for that path, and the PR says it did not test it. The issue expects that an oversized response must not strand pending requests. Whether existing coverage at the reviewed head already asserts that behavior was not established within the inspection limit. The fork-local revert fallback is not directly asserted by the new test. It is covered only indirectly by the updated fallback test.

Resolution

Establish whether the reviewed head already has a test that asserts pending requests complete with an error when the transport reader fails. If it does not, the missing evidence is a test result or a code reference for that behavior. Also confirm that the forkThread hunk in CodexAdapterV2.ts contains only the excludeTurns: true addition, using a readable diff or blob.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.