Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Active turns repeatedly write the full thread cache #4005

ClosedChrrxs(GitHub profile, opens in a new tab) opened this issue 0 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open a thread with substantial tool/activity history.
  2. Start a turn and let updates pause for 500 ms.
  3. Observe EnvironmentCacheStore.saveThread receive the complete thread snapshot. Disposing the thread state writes it again.

A deterministic repro initializes makeEnvironmentThreadState with a running cached thread, advances TestClock by 500 ms, and observes saveThread.

Expected behavior

Do not encode or write full cache snapshots during an active turn. Persist once the session settles.

Actual behavior

Each quiet interval can encode and write the full retained thread, causing increasing allocation, garbage-collection, and UI latency as history grows.

Measured on one affected thread:

  • 8,342 activities / approximately 78 MiB of payload data
  • Cache encoding: 111 ms versus 1.16 ms for a fresh thread
  • Cache loading/parsing: 118 ms versus 1.3 ms for a fresh thread

Provider streaming remained comparable to a fresh session. This is distinct from #2761, which concerns remote WebSocket congestion.

Impact

Major degradation or frequent failure

Version or commit

main at ecb35f758

Environment

T3 Code desktop/nightly, Windows 11 with WSL2, Node.js 24.16.0, Codex provider.

Logs or stack traces

No exception is thrown. The failure is repeated full-history encoding and allocation pressure.

Screenshots, recordings, or supporting files

A deterministic regression test is included in the linked fix.

Workaround

Start a fresh thread before tool/activity history becomes large.

  1. Chrrxs(GitHub profile, opens in a new tab) changed the title

  2. juliusmarminge closed this

Sign in to join this conversation.