You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: listActiveShellIndex scans every finished subagent thread, so shell reads slow down with history (3-8 s here) #37940
ProjectionStore.listActiveShellIndex reads every row of orchestration_v2_projection_threads that isn't deleted or archived, with nine json_extracts and six EXISTS subqueries per row. It backs the shell snapshot (app open, /api/orchestration/shell), t3_thread_list, agent awareness and startup. Subagent threads are never archived, not even when their root thread is, so on a long-lived server most of those rows are finished subagents and the read keeps getting slower.
Ours: 6,833 non-archived threads, 6,420 of them subagent threads. None of the subagent threads are archived, and 1,844 of them sit under a root that is. The database is 17.6 GB. On 0.1.10-nightly.20261115.4736, over one day, the query took p50 3.4 s and up to 7.9 s (35 calls), with its read transactions up to 10 s. In the same day 53 of 514 message.dispatch spans took over 1 s, against 6 of 145 the day before on 4669.
Steps to reproduce
Use a server for a few weeks with subagents (a few thousand subagent threads).
Open the app or call t3_thread_list.
Look at the ProjectionStore.listActiveShellIndex span: it scales with all non-archived threads, finished subagents included.
Where
apps/server/src/orchestration-v2/ProjectionStore.ts, listActiveShellIndex, unchanged on main ccf96b2. #36146 made the worktree and family reads from #36139 cheaper but not this full scan.
Expected
The cost shouldn't grow with history. Any of these would do it: leave settled subagent threads out of the scan (or archive a subagent thread with its root), or keep the flags the index needs in indexed columns instead of json_extract over payload_json.
Activity