Skip to content
Source
Sign inSign up
pingdotgg/t3code

Streaming a proposed plan commits 782 events (2.1 MB) for a 1.3 KB plan #18956

Closedbompus(GitHub profile, opens in a new tab) opened this issue 1 comment

What happened

While a Codex agent streams a proposed plan in plan mode, the server commits three events for every token delta, and two of them carry the whole plan written so far. A recorded 1,352-byte plan arrives as 251 deltas over 5.3 s. Run through the real orchestrator it produces 782 committed domain events totalling 2.1 MB, about 1,560 times the size of the plan, at roughly 150 events per second for the length of the stream. The same fixture on Cursor commits 142 events (605 KB). The cost grows with plan length, because each event repeats everything before it.

Diagnosis

  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts:4241-4270 (item/plan/delta) appends the delta to the accumulated markdown and emits node.updated, plan.updated and turn_item.updated every time. The plan and the turn item both hold the full markdown.
  • Assistant text and reasoning avoid this: makeAssistantStreamingFilter in apps/server/src/orchestration-v2/assistantStreaming.ts lets one update through per 400 ms and drops running assistant nodes. It only looks at assistant_message and reasoning items, so plan events skip it.
  • Event-log compaction does not remove them. ProjectionMaintenance.ts:239 says turn-item.updated is kept intact. In the Codex run those are 254 events and 821 KB.
  • This is the same kind of cost #5110 fixed for assistant text, on the plan path.

Measured with the repository's recorded transcript apps/server/src/orchestration-v2/testkit/fixtures/proposed_plan/codex_transcript.ndjson, replayed through runOrchestratorV2ProviderReplayScenario, counting result.domainEvents by type and JSON size:

ProviderTotal eventsturn-item.updatedplan.updatednode.updated
Codex782 (2,110,566 B)254 (821,265 B)252 (625,712 B)256 (618,451 B)
Cursor142 (605,209 B)47 (351,657 B)4 (23,242 B)61 (144,294 B)

Stored in a file-backed SQLite database (same replay, SqlitePersistence.layerFromPath), the Codex plan run writes 783 rows to orchestration_events holding 1,445,409 B of payload_json (turn-item.updated 603,609 B, plan.updated 411,512 B, node.updated 400,262 B). The database file ends at 4.9 MB, against 1.07 MB for a 36-event fixture (message_steering) that ran through the same migrations. The stored payload column (1.4 MB) is smaller than the 2.1 MB serialized domain events above; I did not check why, and the stored figure is the one that matters for disk. One short plan therefore leaves about 3.8 MB in the file before any compaction.

At the median commit time of 3.1 ms per event that I measured from a live server trace, 782 commits is about 2.4 s of write work inside a 5.3 s stream. I did not measure the web client's render cost per event; that needs a live Codex plan-mode run, which I did not have. These are counts of committed events and their serialized size.

Steps to reproduce

  1. Check out upstream/main at e9221e44da.
  2. In apps/server/src/orchestration-v2/testkit/OrchestratorReplayFixtures.integration.test.ts, run the proposed_plan fixture for the codex and cursor providers (as the existing runs %s/%s through OrchestratorV2 test does).
  3. Count result.domainEvents by type and sum JSON.stringify(event).length. Compare with the final plan size, 1,352 bytes for the Codex transcript.

Version

0.0.45 (commit e9221e44da, upstream/main on 2026-10-13)

Environment

Linux (WSL2), Node 26.11.1, replay fixtures only (in-memory and file-backed SQLite). No live Codex run.

Evidence

codex   782 events 2110566 B   turn-item.updated 254 821265 B | plan.updated 252 625712 B | node.updated 256 618451 B
cursor  142 events  605209 B   turn-item.updated  47 351657 B | node.updated  61 144294 B | plan.updated 4 23242 B
final plan (codex): 1352 B in 251 deltas over 5.27 s
sqlite (codex, file-backed): 783 rows, payload_json 1445409 B, file 4878336 B (36-event baseline fixture: 1073152 B)

#5110 (closed) is the same cost for assistant text and does not cover plan items; #13876 and #15033 do not touch the plan path. No open or closed issue about plan-delta throttling found.

Fix applied or workaround

None applied.

Filed by

claude (sonnet-5-5) in T3 Code. The plan-delta lead came from GPT-6 Astra (extra-high reasoning, Codex); the event counts above were run separately.

  1. bompus(GitHub profile, opens in a new tab) added labelsvia-triage

  2. I can open a pull request for this once triage confirms the direction. I have not written it yet. The change I would make is to throttle plan items the way assistant text already is (one update per 400 ms in makeAssistantStreamingFilter), so the plan and the turn item are committed a few times a second instead of on every delta, with the final plan always committed. I would measure the event count and stored size with the same replay before and after.

Sign in to join this conversation.