fix(server): stop routine events from rescanning thread history #8150
main fromrefs/pull/8150/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubAssistant messages and routine tool activity reload complete thread histories even when no thread summary can change. This slows both the default buffered mode and legacy streaming, and busy threads can delay other conversations.
Skip the summary refresh for assistant messages and routine activities. Keep existing refreshes for user messages, approvals, user input, plans, session changes, and reverts.
Thanks to @cheruvian for #5855, @dain for #7356, and @maria-rcks for #7486.
Fixes #4008.
Checks:
- vp test run apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
- vp run --filter t3 typecheck
- vp check apps/server/src/orchestration/Layers/ProjectionPipeline.ts apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
Model and harness: GPT-5.6 Sol in Codex.
Note
Medium Risk
Changes when derived projection_threads summary columns update; anything expecting fresh counts after assistant or routine tool activity may stay stale until a user message or allowlisted event.
Overview
Stops expensive thread shell summary refreshes on events that cannot change sidebar/summary fields (latestUserMessageAt, pending approval/input counts, actionable plans).
Adds shouldRefreshThreadShellSummary and uses it before refreshThreadShellSummary in the shared message/activity/plan handler. Assistant thread.message-sent events and most thread.activity-appended kinds (e.g. tool.updated) no longer trigger a full history rescan; user messages and allowlisted approval/user-input activity kinds still do. Session, revert, and proposed-plan paths are unchanged.
The projection pipeline test uses a projection_threads update trigger to assert assistant messages and routine tool activity each produce only the lightweight updatedAt upsert—not an extra summary refresh.
Note
Guard refreshThreadShellSummary call in applyProjectsProjection to skip routine events#
Introduces shouldRefreshThreadShellSummary to decide whether a given event warrants a thread shell summary refresh. It returns true for user messages and a specific set of activity kinds (approval.requested, approval.resolved, provider.approval.respond.failed, user-input.requested, user-input.resolved, provider.user-input.respond.failed), and false for assistant messages and other activity kinds.
- Replaces the unconditional
refreshThreadShellSummary(threadId)call in ProjectionPipeline.ts with a conditional call guarded by this function. The thread row upsert withupdatedAtstill runs on every event. - Adds a test in ProjectionPipeline.test.ts using a SQL trigger to count
projection_threadsupdates, verifying that a user message triggers one refresh and a subsequenttool.updatedactivity does not trigger an additional one.
- 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:S
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 13.4 KiB 13.3 KiB −100 B (−0.7%) 15.1 KiB ✅ Codex Thread snapshot wire 6.9 KiB 6.9 KiB −5 B (−0.1%) 7.3 KiB ✅ Codex Live turn WebSocket wire 6.5 KiB 6.5 KiB −95 B (−1.4%) 7.8 KiB ✅ Codex Live turn WebSocket decoded 55.0 KiB 55.6 KiB +602 B (+1.1%) 66.4 KiB ✅ Codex Live turn messages 16 11 −5 (−31.3%) 21 ✅ Claude Total thread wire 13.4 KiB 13.3 KiB −105 B (−0.8%) 15.1 KiB ✅ Claude Thread snapshot wire 6.9 KiB 6.9 KiB +6 B (+0.1%) 7.3 KiB ✅ Claude Live turn WebSocket wire 6.6 KiB 6.4 KiB −111 B (−1.7%) 7.8 KiB ✅ Claude Live turn WebSocket decoded 55.8 KiB 56.4 KiB +620 B (+1.1%) 66.4 KiB ✅ Claude Live turn messages 16 11 −5 (−31.3%) 21 ✅ Baseline:
9996038· PR result:ec7c00a· 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: 109.4 KiB
- Claude decoded thread snapshot: 110.1 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
Approvability#
A prior Macroscope approval was dismissed. Re-evaluating ec7c00a…
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
8db5e17a-95a7-445e-b284-86a46aab3afaYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share