Skip to content

[Bug]: Streaming assistant deltas rescan full thread activity history #4008

Description

@Chrrxs

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

  1. Open a long-running thread with substantial tool/activity history.
  2. Start a turn that streams assistant text.
  3. 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

T3Code.Slow.TPS.Issue.2026-07-15.100931.mp4

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is broken or behaving incorrectly.🚧 In Progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions