Repository navigation
perf(dashboard): patch sub-agent slot changes instead of re-sending the list - #22595
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. The diff changes how data gets to the dashboard: sub-agent counts now arrive as one-row slot patches, and the client fixes up its queued count from them. It adds and changes no control, label or string, so the missing screenshots and blind read leave no evidence gap. [UX-REVIEWED] 74552ac Description read[DESCRIPTION-READ] fd8090e80f49efa2b26570c96bf274b5c30db96026761074dd0ada6ecb5609ee That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The change reuses the existing Notes
[DESIGN-REVIEWED] 74552ac Description read[DESCRIPTION-READ] 7a14a4a79c8c506171311d566331a81bd3b25afc89cef9f3f2d601ad4f181619 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The change swaps one existing push for a narrower frame on the one hot path the Goal names. It reuses the existing What this change shipsInventory (5 items) — 5 justifiedIntent: stop a busy dashboard from re-sending every session row to every tab on each sub-agent spawn, finish or queue change. This is a FIX (perf, #22594).
[FIRST-PRINCIPLES-REVIEWED] 74552ac Description read[DESCRIPTION-READ] 48d7ea12bc10e5f3d09bd4c461718c0336958d26e390bf2e47fe0c90d4a1d626 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
8d8ceeb to
98234f4
Compare
|
self-added: no The hot paths still send the whole list; only the receiving side was widened.
|
|
self-added: no Item 1 (zero consumers) and Item 2 (symptom-level: full push remains).
|
98234f4 to
47f2e67
Compare
|
HOLD at 47f2e67. Two current-head AI concerns have no reply at this head.
The existing dispositions answer head 8d8ceeb, not this one. Everything else looks sound: the Opus and GPT lanes are clean and every check on this head is green. A new push will need another review. — crew-pr-reviewer (r116) |
47f2e67 to
5eeb2ae
Compare
|
self-added: no The diff cache now reflects what any frame last shipped, so a full frame followed by a revert no longer leaves a tab stale.
|
|
self-added: no Item 5 — the title no longer claims run-state patching that
|
6619b64 to
5fa9c81
Compare
|
Rebased once onto main for the #23264 Windows fix. |
|
HOLD at 5fa9c81. One lane note on this head has no reply. First Principles (Item 1) points out that The code looks sound to me: the counts are derived the same way as in — crew-pr-reviewer (r124) |
|
self-added: no Item 1 — fixed (description corrected):
|
|
self-added: no Design note (send only non-zero rows later) — kept as is in this PR, on purpose.
|
|
@iamwhatever re: your HOLD at 5fa9c817: addressed at the same head, with no push.
Could you re-review when you have a moment? |
5fa9c81 to
3d039e3
Compare
|
Rebased once onto main ( Local checks on the new head: 445 targeted backend tests, 712 frontend tests, tsc, eslint, mypy, isort, black, flake8, docs-lint and the comment-history gate all pass. The First Principles Item 1 fix (description), the Design note reply and the HOLD reply from the previous head still apply; the diff is unchanged. @iamwhatever, the re-review request stands. |
… instead of the whole list Busy dashboards gray out because one sub-agent tick re-sends every session's row. The sub-agent lifecycle path now sends a one-row slot_patch carrying only the two counters that moved. A full broadcast records what it shipped to each audience in its own cache, the client reconciles the queued count from a patch row, and the legacy/SSE audience is corrected from its own cache, so a patch and a full frame never disagree on what a tab last saw. Closes #22594
3d039e3 to
74552ac
Compare
|
Rebased once more onto main ( Local checks on the new head pass: 445 targeted backend tests, 712 frontend tests, tsc, full The earlier First Principles fix, Design reply and HOLD reply still apply. @iamwhatever, the re-review request stands. |
bolichen97
left a comment
There was a problem hiding this comment.
Approve. The debounced sub-agent lifecycle flush (_flush_slots_push) now calls a new stateless push_subagent_patch, which sends every live slot's subagents_running / subagents_queued as one slot_patch frame instead of re-broadcasting the whole slot list. Legacy and SSE consumers still get the full list, and onSlotPatch now reconciles the queued count from a patch row.
What I verified at the head: the patch rows come from the same slot set and the same derivation as serialize_slots (skips _slots_under_construction, uses running_agents_for(effective_session_key(s)) and _published_queued_by_slot), so a tab never gets an unknown row that would trigger a spurious fetchSlots(). The client sseSlotPatch applies arbitrary fields, so the two counts land with no reducer change. Specs are updated in the same commit. All checks are green, and every AI lane passed.
Duplicate check: no other open or merged PR adds push_subagent_patch. main still calls push_slots_update() in _flush_slots_push. #22594 has no other fix. #17872 is complementary, not overlapping.
🟡 Suggestion (non-blocking): #22594 also lists run-state fields (running, queue_depth, approval state), which this PR rules out of scope. Closes #22594 will auto-close it with that part open. Could you use Refs or file a follow-up issue for the run-state part?
AI-assisted review (Kiro), posted for bolichen.
Problem / Motivation
Goal: Stop a busy dashboard from re-sending the whole session list to every tab each time a sub-agent spawns, finishes, or its queued depth changes.
On a dashboard with many sessions or many open tabs — a conductor-of-conductors workload most of all — every sub-agent lifecycle event re-serializes and broadcasts the entire slot list over every WebSocket, just to refresh two counters (
subagents_running,subagents_queued). The large compressed frame stalls the gateway loop or freezes the browser decoding it, which users see as gray-outs, "clear cache and start over", and long sessions that appear to crash.Why it matters
Sub-agent churn is the highest-frequency slot change on an active fleet — a conductor driving many workers fires these events constantly — so the whole-list rebroadcast is a dominant source of the "KiroCrew becomes unusable on long/large sessions" reports. The frame grows with sessions × tabs; host CPU and memory are not the constraint, so adding hardware does not help.
Not a goal
running,queue_depth, approval state): their push sites coincide with a transcript append that needs a full frame, so there is no clean run-state-only caller to convert; left out deliberately.push_slots_update()call sites; this targets the proven-hot sub-agent lifecycle path only.What changed (motivation → approach → change)
Busy dashboards gray out because one sub-agent tick re-sends every session's row. The existing one-row
slot_patchframe already fixes that shape for metadata edits (pin, rename, mute, folder), but the sub-agent counts rode the whole-list path instead.The sub-agent lifecycle path now sends one patch row per slot, not the whole list: a new
push_subagent_patchindashboard/state_parts/slots_push.py(bound indashboard/state_parts/dashboard_state.py) recomputessubagents_running/subagents_queuedthe same way the full frame does, and ships every live slot's two counts in that single frame. It has one caller, the debounced lifecycle flush, so an idle fleet still sends nothing. The debounced push inslack/gateway_runtime/subagent_wiring.py(_flush_slots_push) calls it in place ofpush_slots_update(). A legacy or SSE consumer still gets the full list; patch-capable tabs get one small frame of count rows.The patch is deliberately stateless: every lifecycle flush re-states the counts of every live slot instead of diffing against a remembered last-sent value. A diff cache in
dashboard/state_parts/slots_push.pywould assume that a broadcast reached every consumer. Per-tab connect snapshots and a full SSE queue break that assumption, and a suppressed correction could leave a tab showing a finished sub-agent as running. Re-stating the counts is idempotent and corrects any tab on the next lifecycle event; a legacy/SSE consumer likewise gets the full list on every flush, so a dropped list is retried. On the client,onSlotPatchinwebsite/src/hooks/websocket/slotList.tsreconcilessubagents_queuedfrom a patch row carrying the depth, exactly asonSlotsdoes for a full frame; the reducer's doc comment inwebsite/src/store/chat/subagents.tssays a sub-agent patch row now reconciles the count.The owning specs are updated in the same commit (AGENTS.md requires it):
docs/system-specs/modules/subagent.mdanddocs/system-specs/modules/learn-cron-dashboard.md(theslot_patchsection) now describepush_subagent_patchre-stating every live slot's counts on each lifecycle flush, the legacy full-list fallback, and the client reconciling the queued count from a patch row.Backwards compatibility
Compatible: the full-list path is unchanged on the wire and still serves any consumer that cannot apply a
slot_patch. No frame type, field name, or wire shape is removed or renamed; the sub-agent path sends a narrower frame to tabs that advertised the capability, and the client reconciles the queued count from a patch the same way it already did from a full frame.Removes nothing: additive — one new push method, a narrower frame on one already-debounced path, and one client dispatch on patch rows that carry the depth; no path, field, or capability is taken away.
Tests
test/test_slot_patch_frames.py:TestSubagentPatchasserts every lifecycle flush re-states all live rows for both audiences (unchanged counts included) and that the whole list is never serialized for a patch-capable tab. Regressions cover both failure modes of a diff cache: a tab that connected mid-run gets thesubagents_running=Falsecorrection on completion, and a list dropped by a full SSE queue is re-sent on the next lifecycle flush. Both were proven load-bearing (red on the previous head, green after).website/src/test/useWebSocket.queuedReconcile.test.ts: aslot_patchcarrying the depth heals a missedsubagent_queuedframe; a metadataslot_patchrow without the depth leaves the count alone.test/test_slack_gateway_subagents.py: the debounced spawn/done and queued tests assert the lifecycle path callspush_subagent_patchand sends no fullpush_slots_update.test/test_state_parts_dashboard_state.py: the base-member signature table gainspush_subagent_patch.Manual verification
N/A — unit coverage is sufficient. The change is a server-side broadcast optimization plus a client reconcile with no rendered output of its own; the
slot_patchframe path and the queued-count reconcile are covered by the backend and vitest suites above.Related Issues
Closes #22594