perf(server): Codex plan streaming no longer commits every token #19317
main fromrefs/pull/19317/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubCloses #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/completedcompletes 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:
| events | bytes | turn-item.updated | plan.updated | node.updated | |
|---|---|---|---|---|---|
main | 782 | 2,110,566 | 254 | 252 | 256 |
| this PR | 29 | 70,780 | 3 | 1 | 5 |
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 events | plan.updated | bytes | |
|---|---|---|---|
main (test fails) | 306 | 101 | 298,375 |
| this PR | 18 | 5 | 15,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 runonCodexAdapterV2.test.ts,CodexReplayFixtures.integration.test.ts,OrchestratorReplayFixtures.integration.test.ts,OrchestratorReplayFixtures.contract.test.ts: 311 passed.- Server
tsc --noEmitclean. 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelsmacroscope-review
Approvability#
Verdict: Approved at
82f35c8Macroscope'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).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.tsapps/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.tsThe 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.tsPlan 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:
4-
Passed checks: 4 passed-
Check name Status Explanation Title check The title clearly identifies the main change: Codex plan streaming no longer commits every token. It uses a concise conventional-commit format. Description check The description explains the problem, fix, scope, measured impact, verification steps, and unverified live-run coverage. It references issue #18956and provides focused test results. The headings diff…Linked Issues check Issue #18956requires reducing repeated Codexitem/plan/deltaevent commits while preserving plan completion behavior. The PR routes plan deltas throughmakeProviderTextDeltaCoalescerwith a 400 m…Out of Scope Changes check The 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#
- Mode: Continue automatically
- Reviewed files: 2
- Charged: $0.50
- View usage details
Comment `@coderabbitai help` to get the list of available commands.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.
-
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB +7 B (+0.1%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB +7 B (+0.6%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
acb9027· PR result:82f35c8· Source CI: successScenario 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.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes