Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): Codex plan streaming no longer commits every token #19317

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/19317/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Closes #18956.

When Codex streams a proposed plan, each token delta commits three events (node.updated, plan.updated, turn-item.updated), and two of them carry the whole plan written so far. The recorded 1.3 KB plan fixture commits 782 events (2.1 MB). Assistant text and reasoning avoid this because they go through makeProviderTextDeltaCoalescer. Plan deltas did not.

Fix

item/plan/delta now appends to a makeProviderTextDeltaCoalescer, the same one the Codex adapter uses for assistant text and reasoning. It flushes at most every 400 ms, the cadence clients already see for assistant text.

  • item/completed completes the plan through the coalescer. It drops any pending flush and always emits the final plan, as before.
  • When the turn ends, any buffered plan text is flushed. On an interrupted turn the partial plan stays streaming, as it did before.
  • No contract or wire change. Clients still see the plan stream in, a few times a second.

Proof

Issue method: the recorded proposed_plan Codex fixture replayed through the orchestrator, counting result.domainEvents:

eventsbytesturn-item.updatedplan.updatednode.updated
main7822,110,566254252256
this PR2970,780315

That fixture has no timing, so all deltas arrive inside one flush window. To show timed streaming, the new test streams a proposed plan a few times a second instead of once per delta (CodexAdapterV2.test.ts) sends 100 deltas 20 ms apart:

provider eventsplan.updatedbytes
main (test fails)306101298,375
this PR18515,625

It also checks that the final plan has the full text and that only the last update has streaming: false. A live 5.3 s plan should take about 14 flushes, so roughly 45 events instead of 782.

  • vp test run on CodexAdapterV2.test.ts, CodexReplayFixtures.integration.test.ts, OrchestratorReplayFixtures.integration.test.ts, OrchestratorReplayFixtures.contract.test.ts: 311 passed.
  • Server tsc --noEmit clean. Scoped lint and format clean.

Not verified: a live Codex plan-mode run. Other providers already batch plan updates. Cursor, for example, commits 4 plan.updated events for the same fixture.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at 82f35c8

      Macroscope's review found this PR approvable — This is a focused Codex streaming performance fix that reduces redundant persistence writes while preserving final plan content, lifecycle state, and event shapes. Targeted replay coverage verifies coalesced updates and complete final output.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 7c060308-23d2-49b2-b283-2b61445401b1
      📥 Commits

      Reviewing files that changed from the base of the PR and between acb90279e2adad19a63586944543fe7346499467 and 82f35c811914d9078e369bce8965824f4d5e280e.

      📒 Files selected for processing: 2
      • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts

      Limit details: You’ve used all 10 included reviews currently available. Your 14 included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

      📝 Walkthrough

      Codex proposed-plan deltas are now coalesced before artifact updates are emitted. The adapter flushes buffered text at completion and turn finalization. A replay test checks update counts, final markdown, and streaming status.

      Changes: Codex Proposed-Plan Streaming

      Layer / File(s)Summary
      Coalesced plan projection
      apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
      The adapter uses a 400 ms flush interval and a coalesced text stream to build and emit proposed-plan artifacts. It removes the per-item string map.
      Plan stream lifecycle and replay validation
      apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
      Plan notifications append text to the coalescer. Plan completion and turn finalization flush buffered text. The replay test checks coalesced update counts, complete markdown, and final streaming status.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 82f35

      Recorded plan streaming retains the completed text, and no merge-blocking issue is established. A live plan-mode run remains unverified.

      Pre-merge checks: Passed 4
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the main change: Codex plan streaming no longer commits every token. It uses a concise conventional-commit format.
      Description checkPassedThe description explains the problem, fix, scope, measured impact, verification steps, and unverified live-run coverage. It references issue #18956 and provides focused test results. The headings diff…
      Linked Issues checkPassedIssue #18956 requires reducing repeated Codex item/plan/delta event commits while preserving plan completion behavior. The PR routes plan deltas through makeProviderTextDeltaCoalescer with a 400 m…
      Out of Scope Changes checkPassedThe changes are limited to Codex plan-delta coalescing and its adapter test. The coalescer integration, finalization handling, and test coverage directly support issue #18956. No unrelated source, con…
      ✨ 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

      Usage-based review receipt

      Note

      This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

      Comment `@coderabbitai help` to get the list of available commands.
    5. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)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 KiB+7 B (+0.1%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB+7 B (+0.6%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: acb9027 · PR result: 82f35c8 · 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.

Sign in to join this conversation.