Skip to content

perf(server,client-runtime): [NBR] cut running thread cold-open wire bytes by 74% and compact snapshots/history pages - #48472

Open
t3dotgg wants to merge 1 commit into
nbr/stream-deltasfrom
nbr/thread-snap-opt
Open

t3dotgg wants to merge 1 commit into
nbr/stream-deltasfrom
nbr/thread-snap-opt

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Dec 3, 2026

Copy link
Copy Markdown
Member

Opening a thread with an active long turn sends hundreds of kilobytes of off-window historical messages (~196 KB on longTurnRunningColdOpen), ~55-field providerSession.capabilities objects (when clients read only a small subset), redundant visibleTurnItems local wrappers (~18–24 KB on 150-row opens), full server-internal refs (nativeItemRef, nativeThreadRef, nativeConversationHeadRef, nativeTurnRef, claudeDeliveredAppContext), unstripped checkpoint item file lists, unbounded subagent previews, and un-deduped history pages.

Stacked cleanly on #48441 (nbr/stream-deltas), this adds opt-in compactWire (cw: 1) encoding, off-window active-run message pruning, and history-page body deduplication transparently across web, desktop, and mobile (client-runtime), keeping legacy clients and servers 100% compatible:

  • Compact wire codec (withRecordIdTable + cw: 1): Unwraps local visibleTurnItems rows to bare turn items (while still interning all IDs), omits null/default fields and redundant timestamps, and compacts providerSessions[].capabilities to non-default client-read flags.
  • Off-window active-run message pruning (ProjectionStore): Prunes completed off-window assistant messages on running turns while preserving visible-window messages, streaming messages, active/queued user prompts, latest run replies, delegatedCompletion, workflowScript, and provider-native subagent prompts.
  • Server-internal wire stripping (WireProjection): Strips server-only native refs/metadata (retaining all client-inspected refs), blanks unused checkpoint turn-item files arrays (keeping filesTotal and projection.checkpoints[].files), and bounds subagent preview strings to UI display limits.
  • History & launch compaction: Enables dedupeBodies=1, compactIds=1, and compactWire=1 on history pages, getThreadProjection, and launchThread.

Measured transferBudgetV2 Wire Reductions

Scenario Metric Before (main) After (nbr/thread-snap-opt) Reduction
long turn running, cold open HTTP gzip wire 51,138 B 13,150 B -74.3%
long turn running, cold open HTTP decoded 288,442 B 72,813 B -74.8%
long turn finished, cold open HTTP gzip wire 59,583 B 46,529 B -21.9%
long turn finished, cold open HTTP decoded 390,641 B 263,591 B -32.5%
stale todo list cold open HTTP gzip wire 9,128 B 5,511 B -39.6%
stale todo list cold open HTTP decoded 75,142 B 42,609 B -43.3%
reconnect, thread (snapshot) WS wire 3,600 B 2,823 B -21.6%

Verification

  • vp run check:changed: pass (format, lint, knip, graphql, typecheck across 39 packages, 19 test files / 308 tests including orchestrationV2CompactWire.test.ts, orchestrationV2DedupedBodies.test.ts, threadHistoryPaging.test.ts, WireProjection.test.ts, http.test.ts, boundedThreadSnapshotHttp.test.ts, threadHistoryHttp.test.ts, commands.test.ts, and transferBudgetV2.integration.test.ts).

Created with Gemini 4 Neon in Antigravity.

…f-window running messages, and dedupe history pages
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Dec 3, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 441ea8f

Macroscope's review found this PR approvable — Compacts thread snapshots, history pages and live updates while retaining legacy transport support and detail retrieval. The changes affect wire representations rather than stored data or provider execution, with no obvious material risk requiring human review.

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

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire — 5.0 KiB — 6.8 KiB ✅
Codex Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅
Codex Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Codex Live turn WebSocket decoded — 21.5 KiB — 24.4 KiB ✅
Codex Live turn messages — 1 — 8 ✅
Claude Total thread wire — 5.0 KiB — 6.8 KiB ✅
Claude Thread snapshot wire — 3.8 KiB — 4.9 KiB ✅
Claude Live turn WebSocket wire — 1.2 KiB — 2.0 KiB ✅
Claude Live turn WebSocket decoded — 21.9 KiB — 24.4 KiB ✅
Claude Live turn messages — 1 — 8 ✅

Other scenarios

No main baseline exists yet for these 64 scenario measurements.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded — 10.5 KiB — 12.7 KiB ✅
Codex short turn resume WebSocket messages — 2 — 2 ✅
Codex long turn running, cold open HTTP decoded — 71.1 KiB — 302.7 KiB ✅
Codex long turn running, cold open rows — 75 — 75 ✅
Codex long turn running, history page HTTP decoded — 68.1 KiB — 107.4 KiB ✅
Codex long turn running, history page rows — 75 — 75 ✅
Codex long turn finished, cold open HTTP decoded — 257.4 KiB — 410.2 KiB ✅
Codex long turn finished, cold open rows — 151 — 151 ✅
Codex long turn finished, socket cold open WebSocket decoded — 257.5 KiB — 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages — 2 — 2 ✅
Codex long turn finished, socket cold open rows — 151 — 151 ✅
Codex long turn finished, work page HTTP decoded — 58.7 KiB — 200.2 KiB ✅
Codex long turn finished, work page rows — 75 — 150 ✅
Codex idle thread resume WebSocket decoded — 65 B — 200 B ✅
Codex idle thread resume WebSocket messages — 1 — 1 ✅
Codex fleet shell snapshot HTTP decoded — 42.4 KiB — 53.7 KiB ✅
Codex fleet shell snapshot rows — 27 — 27 ✅
Codex fleet shell subscribe WebSocket decoded — 65 B — 200 B ✅
Codex fleet shell subscribe WebSocket messages — 1 — 1 ✅
Codex fleet shell resume check HTTP decoded — 18 B — 100 B ✅
Codex fleet shell resume check rows — 0 — 0 ✅
Codex stale shell reload HTTP decoded — 42.4 KiB — 53.7 KiB ✅
Codex stale shell reload rows — 27 — 27 ✅
Codex stale shell resume WebSocket decoded — 140 B — 400 B ✅
Codex stale shell resume WebSocket messages — 2 — 2 ✅
Codex stale todo list cold open HTTP decoded — 41.1 KiB — 83.0 KiB ✅
Codex stale todo list cold open rows — 75 — 75 ✅
Codex stale todo list cold open nodes — 2 — 4 ✅
Codex stale todo list cold open subagents — 2 — 4 ✅
Codex stale todo list cold open plans — 1 — 2 ✅
Codex stale todo list cold open providerTurns — 1 — 2 ✅
Codex stale todo list cold open checkpoints — 1 — 2 ✅
Claude short turn resume WebSocket decoded — 10.6 KiB — 12.7 KiB ✅
Claude short turn resume WebSocket messages — 2 — 2 ✅
Claude long turn running, cold open HTTP decoded — 71.7 KiB — 302.7 KiB ✅
Claude long turn running, cold open rows — 75 — 75 ✅
Claude long turn running, history page HTTP decoded — 68.6 KiB — 107.4 KiB ✅
Claude long turn running, history page rows — 75 — 75 ✅
Claude long turn finished, cold open HTTP decoded — 259.2 KiB — 410.2 KiB ✅
Claude long turn finished, cold open rows — 151 — 151 ✅
Claude long turn finished, socket cold open WebSocket decoded — 259.3 KiB — 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages — 2 — 2 ✅
Claude long turn finished, socket cold open rows — 151 — 151 ✅
Claude long turn finished, work page HTTP decoded — 59.2 KiB — 200.2 KiB ✅
Claude long turn finished, work page rows — 75 — 150 ✅
Claude idle thread resume WebSocket decoded — 66 B — 200 B ✅
Claude idle thread resume WebSocket messages — 1 — 1 ✅
Claude fleet shell snapshot HTTP decoded — 43.0 KiB — 53.7 KiB ✅
Claude fleet shell snapshot rows — 27 — 27 ✅
Claude fleet shell subscribe WebSocket decoded — 66 B — 200 B ✅
Claude fleet shell subscribe WebSocket messages — 1 — 1 ✅
Claude fleet shell resume check HTTP decoded — 18 B — 100 B ✅
Claude fleet shell resume check rows — 0 — 0 ✅
Claude stale shell reload HTTP decoded — 43.0 KiB — 53.7 KiB ✅
Claude stale shell reload rows — 27 — 27 ✅
Claude stale shell resume WebSocket decoded — 140 B — 400 B ✅
Claude stale shell resume WebSocket messages — 2 — 2 ✅
Claude stale todo list cold open HTTP decoded — 41.6 KiB — 83.0 KiB ✅
Claude stale todo list cold open rows — 75 — 75 ✅
Claude stale todo list cold open nodes — 2 — 4 ✅
Claude stale todo list cold open subagents — 2 — 4 ✅
Claude stale todo list cold open plans — 1 — 2 ✅
Claude stale todo list cold open providerTurns — 1 — 2 ✅
Claude stale todo list cold open checkpoints — 1 — 2 ✅

Baseline: unavailable · PR result: 441ea8f · 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant