Repository navigation
fix(slack): voice reply, restart close and rss recycle fixes - #33670
Conversation
6b5fcb5 to
5ddcf2e
Compare
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: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: each of the three defects is fixed at its root cause with a narrow helper, and the take-away readers ( Notes
[DESIGN-REVIEWED] 0d27460 Description read[DESCRIPTION-READ] ba5148a012609999464ce42865468afa2ab59d838b602b81f59ade570e6a822e 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 |
UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)UX-level review of UX-Verdict: PASS cannot evaluate: missing a screenshot of the new " Evidence gaps
Notes
[UX-REVIEWED] 0d27460 Description read[DESCRIPTION-READ] 9c956deb51549c7049d3285ec297a7dee128134b02a5865e496d44feb293840a 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each defect traces to #33481. The restart bound is applied at the callers, which follows the caller-owns-the-cap design that Notes
What this change shipsInventory (9 items) — 8 justifiedIntent: Slack voice replies play on a default install, a restart cannot hang on closing sessions, and a chat over the RSS ceiling stops being recycled after every turn. FIX.
[FIRST-PRINCIPLES-REVIEWED] 0d27460 Description read[DESCRIPTION-READ] 3655a4781512428bdc23187f7bed5e4ca10adf1312f9ba4898c2ef51dfabb877 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: |
buluoray
left a comment
There was a problem hiding this comment.
Approving the re-review. The one blocking finding is fixed: the commands.py post_message ratchet baseline drops from 79 to 78, and its description no longer names the removed !voice text-only reply (test/test_slack_post_message_call_sites.py:106). The ratchet test passes, and it turns red again when the row is set back to 79. range-diff shows no other code change apart from a reworded comment in update_schedule.py.
|
Backend Tests (3.12, 3) is red on |
5ddcf2e to
cfb0c00
Compare
- Slack voice replies are spoken on the default transport path. With messaging.use_transport on (the default), handle_message_transport now speaks a finished answer through _reply_by_voice, the voice-memo signal survives the busy-session queue, and the owner's !voice on opts a thread in instead of answering that replies stay text. - Every in-process restart (Restart to Update, the dashboard restart and the Slack /kirocrew restart) closes sessions through close_sessions_for_restart, which leaves a close still running after 20 s (5 s for Slack) and goes on to the exec. A background task that outlived its cancel used to hold the restart forever on the old version; _restart_gateway also logs each step it starts. - The RSS watchdog holds a session after its third rebound in a row instead of recycling it after every turn, logs it once and tells the chat which setting (session.watchdog_rss_max_mb) is below the session's footprint. The hold lifts a day after the last recycle, and a held tree that doubles its footprint is still recycled.
cfb0c00 to
0d27460
Compare
buluoray
left a comment
There was a problem hiding this comment.
Re-approved at 0d27460 after the approval at cfb0c00. The new head is a rebase onto a main that added the leftover-memory watchdog inside the same RSS recycle loop. The PR's judge_rss_crossing hold now sits inside main's busy/leftover loop (src/kiro_crew/session_cleanup.py:808-823), the RssRecycle record follows main's _leftovers.end_after_recycle call (:917), and on_leftover_memory and on_rss_hold are both declared and wired (src/kiro_crew/session.py:937-942, src/kiro_crew/dashboard/state_parts/session_events.py:823, :856). The PR's own hunks are unchanged. 603 tests pass and the hold-guard mutation turns 5 tests red. GPT, Opus and Security Scope pass; backend and E2E lanes were still running when posted.
- Slack voice replies are spoken on the default transport path. With messaging.use_transport on (the default), handle_message_transport now speaks a finished answer through _reply_by_voice, the voice-memo signal survives the busy-session queue, and the owner's !voice on opts a thread in instead of answering that replies stay text. - Every in-process restart (Restart to Update, the dashboard restart and the Slack /kirocrew restart) closes sessions through close_sessions_for_restart, which leaves a close still running after 20 s (5 s for Slack) and goes on to the exec. A background task that outlived its cancel used to hold the restart forever on the old version; _restart_gateway also logs each step it starts. - The RSS watchdog holds a session after its third rebound in a row instead of recycling it after every turn, logs it once and tells the chat which setting (session.watchdog_rss_max_mb) is below the session's footprint. The hold lifts a day after the last recycle, and a held tree that doubles its footprint is still recycled. Backport note: slack/events.py takes the close_sessions_for_restart TYPE_CHECKING import without the code_channels slash import next to it on main (#21429, unreleased). The commands.py row of test_slack_post_message_call_sites.py goes from 78 to 77, since release already counted one call fewer than main. The session.md and voice-streaming.md conflicts are context only: the close_all row and the Slack reply row take the change from main, while the newer drain_active_turns wording and the WhatsApp reply row beside them on main stay out. Everything else applies as on main. (cherry picked from commit 72f6877)
Problem / Motivation
Goal: Slack voice replies are spoken on a default install, every restart reaches its exec even when closing sessions never finishes, and the RSS watchdog stops recycling a chat after every turn and tells the user which setting to raise.
This PR fixes three separate defects, reported together in #33481:
!voice onin a thread, or for a voice memo undervoice_reply.auto_reply_to_voice), the answer arrives as text only.messaging.use_transportis on by default, and only the native path speaks a reply. On the transport path the owner's!voice ongets a reply that answers stay text, and a voice memo that waits in the busy-session queue loses its voice flag./kirocrew restartall awaitSessionManager.close_all()before the exec or exit. A background task that keeps running after it is cancelled holds that await with no end: turn admission is already shut, and the old version keeps serving.session.watchdog_rss_max_mbon its own (a long history restored into it), every recycle is followed by another crossing. The user pays a cold start every turn, and the chat only says it was recycled.Why it matters
Not a goal
session_background.py(claude backend: the background runtime is recycled after every turn because its MCP servers alone exceed the 1536 MiB RSS ceiling #31900, PR fix(session): bound the background runtime's RSS growth, not its MCP servers #32030). This PR changes only the chat-session sweep insession_cleanup.py.session.watchdog_rss_max_mb, or the shutdown path's own budget (exit_path._shutdown, which the supervisor's SIGTERM-to-SIGKILL deadline already ends).What changed (motivation → approach → change)
Three fixes, one per defect: a Slack answer on a default install is spoken when voice replies are on, a restart goes on to its exec when closing sessions never finishes, and a chat whose fresh process is over the RSS ceiling stops being recycled after every turn and is told which setting to raise.
handle_messagecalled_reply_by_voicehandle_message_transportspeaks a finished answer through the same_reply_by_voice, in the newslack/transport_voice.pyclose_all()awaits its cancelled tasks with no deadline, andasyncio.wait_forwaits for a cancelled close to unwindclose_sessions_for_restart, in the newrestart_session_close.py, waits on the close as its own task: 20 s, or 5 s for Slack, then on to the exec or exitsession_rss_rebound.pyholds a session at its third rebound in a row, logs it once and tells the chat which setting to raiseVoice. The transport path speaks
SlackRenderer.delivered_text, the answer as Slack showed it, into the conversation it was posted to. It skips an unfinished or cancelled turn and never lets a speech failure mark the turn failed.had_voice_inputreaches the transport path from the immediate call, both busy-session queues and_dispatch_queued, so a queued voice memo is still answered in kind. On main, the transport path answers the owner's!voice onwith a note that replies stay text (voice_replies=Falseinslack/handler_runtime/commands.py), a stopgap for the missing voice reply. This PR removes that stopgap, so!voice onopts a thread in on both paths. Reviewers should look at this integration with main.Restart. The dashboard restart (
dashboard/handlers/updates_apply.py), the gateway's update restart (slack/gateway_runtime/update_schedule.py) and the Slack restart (slack/events_slash.py) all close sessions through the new helper. A close cut at its deadline is cancelled and left behind. A warning names the step, and the next start's orphan sweep reaps what it left. The dashboard restart logs each step as it starts, so a slow restart shows where it is.RESTART_SESSION_CLOSE_SECSlives ingateway_shutdown_budget.py.RSS.
session_cleanup.pykeeps oneRssRecyclerecord per key and askssession_rss_reboundto judge each crossing. The hold ends a day after the last recycle. A held session whose footprint doubles is recycled anyway.SessionManager.on_rss_hold(session.py) is the seam the dashboard (dashboard/state_parts/session_events.py) uses to post a warning notice into the tab. The notice namessession.watchdog_rss_max_mband its value, and says to raise Watchdog RSS Limit in Settings. The recycle notice of a rebound names the setting too.The owning specs and user docs describe the new behaviour (
config.md,learn-cron-dashboard.md,session.md,slack-gateway.md,voice-streaming.md,src/kiro_crew/docs/configuration.md,slack-integration.md). A comment insession_lifecycle_parts/fleet.pyand the notice list inwebsite/src/pages/chat/CompactionCard.tsxname the new pieces.Backwards compatibility
Compatible: no config key, API, record format or command is renamed or removed. The restart bound and the RSS hold only add an end to waits and loops that had none.
Reader: src/kiro_crew/slack/transport_dispatch.py:handle_message_transport -- chat -- it was the only caller passing
voice_replies=Falseto_route_bang_command, removed with the parameter;!voice onopts the thread in, pinned by test_slack_transport_bang_commands.py::test_voice_on_opts_the_thread_in_as_on_the_native_pathReader: src/kiro_crew/slack/handler_runtime/dispatch.py:_route_bang_command -- chat -- the native path never passed
voice_replies, so its!voicekeeps the default it always had; covered by the same bang-command testsReader: src/kiro_crew/session_cleanup.py:CleanupState.rss_recycled -- chat -- its values change from a
(time, rss)tuple toRssRecycle; every other reader (test_session_harness_background_work.py, test_session_idle_exempt_keys.py, test_session_terminated_reap.py) reads only its keys or emptiness, and test_session_rss.py reads.rssRSS_REBOUND_WINDOW_SECSmoves fromsession_cleanup.pytosession_rss_rebound.pywith the same value; its only reader was test_session_rss.py, which moves with it.Tests
The full backend and frontend suites run in CI. On a Linux DevSpace, at head
1a0e70fcfcon main94dfacdb2d, the changed test files (test_slack_events_coverage_route_flow.py,test_slack_transport_dispatch_turn_outcomes.py,test_slack_transport_bang_commands.py,test_slack_post_message_call_sites.py,test_restart_close_all_deadline.py(new),test_restart_command.py,test_dashboard_chat_compaction.py,test_session_rss.pyandtest_state_parts_session_events.py), together withtest_file_line_cap.py,test_slack_gateway.py(main changed it under this PR's Slack gateway files) and the ten other test files that referenceupdate_schedule.py, gave 866 passed, 0 failed. The black, isort, flake8, mypy (--platform linux), subprocess encoding, comment history, brand name, file line cap, harness parity and flake-pattern ratchet gates all exit 0.Rebased onto main after review; patch unchanged: head
cfb0c00510on main39aecc7296. git range-diff against5ddcf2ebc5differs only in one hunk's context lines: main added acode_channel_slashimport to the type-checking import block ofslack/events.py, and this PR'sclose_sessions_for_restartimport now follows it. On the DevSpace at this head, the changed test files with main'stest_slack_gateway_composition_contract.py,test_slack_code_channel_agent_surface.pyand its failures sibling gave 778 passed, 0 failed.test_review_repair_routing_skill.pygives 20 passed; with the earlier head's 16004-bytekirocrew-worktree-dev/SKILL.mdit fails its 16000-byte ceiling (exit 1), which is the Backend Tests red on5ddcf2ebc5that main's shorter copy clears. The black, isort, flake8, mypy, subprocess encoding, comment history, brand name, file line cap, harness parity and flake-pattern ratchet gates all exit 0.Rebased onto main after review; patch unchanged: head
0d274605beon main5ed49b39f7. git range-diff againstcfb0c00510changes only context lines, in the five files main's #33935 also changed at the RSS recycle site (session_cleanup.py,session.py,session_events.py,config.md,configuration.md). Both sides stay: main's leftover-process pass runs before this PR'sRssRecyclerecord, both session event handlers are wired, and main'swatchdog_end_leftovers_mid_turnrow follows this PR'swatchdog_rss_max_mbrow. On the DevSpace at this head, the changed test files with main'stest_session_leftovers.py,test_platform_compat_refactor_facade.pyand 13 session, RSS and config neighbours gave 1323 passed, 0 failed, andtest_the_scan_is_linear_not_quadratic(the Backend Tests red oncfb0c00510) passes. The black, isort, flake8, mypy (--platform linux), subprocess encoding, comment history, brand name, file line cap, harness parity and flake-pattern ratchet gates all exit 0.Two test files resolve the new modules inside the test that uses them instead of at module top, so a missing module fails one test rather than the whole file's collection.
test_slack_post_message_call_sites.pyholdsslack/handler_runtime/commands.pyat 78 directpost_messagecalls, one fewer than main, because this PR deletes the transport path's fixed!voicetext-only reply. It passes at the head (12 passed) and fails withcommands.pyas on main:79 direct call(s), baseline says 78 -- a new direct send path.What each test pins:
!voice on, a voice memo); an unfinished or cancelled turn speaks nothing; a speech failure does not mark the turn failed; a queued voice memo keeps its voice flag;!voice onopts the thread in on the transport path.Proof: PROVEN test/test_restart_close_all_deadline.py::test_a_restart_whose_session_close_never_finishes_still_ends[update], test/test_restart_close_all_deadline.py::test_a_restart_whose_session_close_never_finishes_still_ends[dashboard], test/test_restart_close_all_deadline.py::test_a_restart_whose_session_close_never_finishes_still_ends[slack], test/test_restart_close_all_deadline.py::test_the_dashboard_restart_logs_each_step_as_it_starts, test/test_session_rss.py::TestRssThresholdCheck::test_a_session_that_keeps_rebounding_is_held_and_the_chat_told_once[under-twice] (head 1a0e70fcfc63)
Manual verification
Each defect's user scenario was run end to end on a DevSpace. Each fix side exited 0 on the same patch at
2ad20f6dcaon main7b2eeb9f4b; the four main commits under1a0e70fcfcsince then change memory indexing, button focus in the UI and a Slack gateway shutdown test, none of this PR's files. Each base side exited 1 on main: voice and restart on63d560bd68, RSS (a 6 minute run) one623a4d11b. Atcfb0c00510on main39aecc7296each fix side exited 0 again: the restart reached the exec in 26.4 s (6.2 s without the stuck task) and left no process behind. At0d274605beon main5ed49b39f7, the RSS fix side exited 0 again (3 recycles and 2 rebounds, then held, with the chat namingsession.watchdog_rss_max_mb=120), and its base side on that main exited 1 (5 of 5 turns recycled, no notice naming the setting).messaging.use_transporton), the transport path posted the answer and uploadedvoice-reply.wav, as the native path does. On main the answer posts with no clip (synth_calls=0).POST /api/restartreached the exec in 26.5 s (6.1 s without the stuck task), and the new process came up ready. On main, 60.5 s after the call there is no exec and the old process still serves.session.watchdog_rss_max_mb=120, recycling stopped after 3 recycles and 2 rebounds, and the chat namedsession.watchdog_rss_max_mb=120. On main, 5 of 5 turns each ended in another recycle and no chat notice named the setting.Screenshots / video
Why no screenshot: the only frontend change is a comment line in
CompactionCard.tsx; the RSS hold notice is backend text drawn by the existing notice card.Related Issues
Fixes #33481
Sibling sweep
Swept: git grep -n "_reply_by_voice|synthesize_and_deliver" -- src/kiro_crew/
Sibling: src/kiro_crew/telegram/transport_dispatch.py -- not affected -- its transport path already speaks through synthesize_and_deliver
Sibling: src/kiro_crew/whatsapp/transport_dispatch.py -- not affected -- its transport path already speaks through synthesize_and_deliver
Swept: git grep -nE "(sessions|session_mgr).close_all(" -- src/kiro_crew/
Sibling: src/kiro_crew/slack/gateway_runtime/exit_path.py:344 -- not affected -- a shutdown is ended by the supervisor's SIGTERM-to-SIGKILL deadline, which no in-process restart has
Sibling: src/kiro_crew/cli_server.py:543 -- not affected -- the end of a foreground CLI run with no exec after it; the user can interrupt it
Sibling: src/kiro_crew/eval/runner.py:397 -- not affected -- an eval run's teardown, with no exec after it
Swept: git grep -n "rss_max_mb" -- src/kiro_crew/
Sibling: src/kiro_crew/session_background.py -- tracked in #31900
Sibling: src/kiro_crew/session_cleanup_spare.py -- not affected -- a warm-pool spare holds no conversation, so discarding one costs no chat a cold start
Pattern harvest
Rule candidate: semgrep
Pattern:
asyncio.wait_forused as the hard cap before an exec or exit; a cancelled callee that keeps running holds it past the timeout.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)