[Bug]: Streaming assistant deltas rescan full thread activity history #4008
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Open a long-running thread with substantial tool/activity history.
- Start a turn that streams assistant text.
- Observe text delivery becoming dramatically slower than a fresh thread.
Deterministic repro: project a streaming assistant thread.message-sent event against a thread whose activity history contains a decode sentinel. The event currently touches the sentinel through ProjectionThreadActivityRepository.listByThreadId, proving that every delta reads the full activity history.
Expected behavior#
Streaming assistant deltas should persist the message and update the thread timestamp without recomputing shell-summary fields that cannot change from assistant text.
Actual behavior#
Every streamed assistant delta calls refreshThreadShellSummary, which loads all messages, proposed plans, activities (including full tool payloads), and pending approvals.
On the affected thread, 25,834 activities contained about 254 MB of payloads. The provider emitted 55 deltas in 521 ms, while server-side assistant-delta projection took a median 819 ms per delta (p95 1,041 ms), making text visibly trickle.
This is distinct from #2761 (snapshot/WebSocket congestion) and #4005 (client cache writes).
Impact#
Major degradation or frequent failure
Version or commit#
main at ecb35f758
Environment#
Windows 11 with WSL2, T3 Code desktop/nightly, Node.js 24.16.0, Codex provider.
Logs or stack traces#
activities: 25,834
activity payloads: ~254 MB
assistant.delta projection: median 819 ms, p95 1,041 ms
provider output: 55 deltas / 251 chars in 521 ms
Screenshots, recordings, or supporting files#
https://github.com/user-attachments/assets/9e4adc7f-15aa-4913-9618-9f6c6ec09efc
Workaround#
Start a fresh thread. A local fix that skips the shell-summary refresh only for streaming assistant messages restored normal text delivery while preserving message projection and updatedAt.
juliusmarminge added labelsbug
juliusmarminge added labels🚧 In Progress
Confirmed a broader variant of this issue with assistant streaming disabled.
A long-lived thread containing tens of thousands of activities made each
thread.activity-appendeddispatch spend roughly two seconds inrefreshThreadShellSummary.ProviderRuntimeIngestionuses a single serialDrainableWorkerfor all provider events, so these slow events created cross-thread head-of-line blocking: an unrelated thread completed normally at the provider, but its response was not persisted and rendered by T3 Code for about seven minutes.This suggests the impact is not limited to assistant-delta streaming within the large thread. Routine activity events from one large thread can starve unrelated conversations globally.
The completion was not lost or corrupted; it became visible after the ingestion backlog drained. In addition to making shell-summary projection incremental, partitioning ingestion by thread or moving expensive projections off the global serial path may prevent the cross-thread failure mode.
Still reproducible on T3 Code 0.0.31 across two independent Windows installations.
Additional measurements and controlled cleanup A/B data are documented in #5110:
- one 10,545-character response produced 3,024 durable
thread.message-sentevents (median delta: 3 characters); - after cleanup, one database regrew from 282 KB to 218 MB and 93,943 events in approximately 25 hours;
- removing only T3 Code's internal history immediately restored responsive streaming;
PRAGMA quick_checkremainedok;- built-in thread deletion did not purge historical events, receipts, messages, or activities.
This supports #4008 while suggesting that the shell-summary rescan is one amplifier within a broader per-delta persistence, queueing, and retention problem.
- one 10,545-character response produced 3,024 durable
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Desktop repro data (macOS, packaged app) — matches this issue closely#
Environment
com.t3tools.t3code)127.0.0.1:3773enableAssistantStreaming: truein~/.t3/userdata/settings.jsonat capture timeLocal profile at capture (
~/.t3/userdata/state.sqlite)orchestration_eventsthread.message-sentthread.activity-appendedHeaviest threads (pre-trim)
User-visible symptom Grok Build turns start fine, then after a couple of tool-call rounds in the same thread the UI becomes dramatically slower (text trickle / long gaps between tool steps). Fresh threads feel normal; long agentic threads degrade mid-turn. This is not “Grok CLI is slow” — terminal Grok is fine; T3 falls over as history grows.
Why this looks like #4008
thread.message-sentdeltas (one event per stream chunk).thread.activity-appendedpayloads (activity payload mass ≫ message text mass).Server traces (supporting)
runProjectorForEvent+sql.executeduring agent turnsws.rpc.orchestration.subscribeThreadspans (minutes–hours class in duration fields)Cannot convert skills-reload to a BigInt/ model discovery timeout) — orthogonal, not the mid-turn regressionWorkaround that recovered the machine
.backup, then purge soft-deleted thread rows + wipe history on fat active threads (kept thread shells + provider session rows)enableAssistantStreaming: falseVACUUM→ DB 587 MB → 288 KBHappy to re-capture timing of assistant-delta projection (median/p95) on a synthetic thread if useful for a regression test. Cross-links: also matches client quadratic replay in #4596 and unbounded history hydration in #2761 / #3510.