Repository navigation
fix: cancel a lost tool call at its own silence bound - #34763
Conversation
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: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The maintainer's decision entry records the new rule and the 90-minute window it replaces. Every bound is a Notes
[DESIGN-REVIEWED] 18571d0 Description read[DESCRIPTION-READ] ea1c59e034597d5cccf648cdc5fb087a3a2af2d41ddac41dfb583fef05b4e02f 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) — ✅ human override accepted@bolichen97 overrode this lane for |
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: |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 30% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR gives each non-shell tool call its own silence timer on kiro-cli and KAS. A call lost beside a busy sub-agent is cut at its bound (5 min for built-ins and url-declared MCP tools, 30 min for other MCP tools, 10 min for sub-agent calls) through the existing non-lethal tool-stall path, and handed back to the model as a timeout to retry on every surface the decision names. A timer runs only while the session can prove it would see the call's activity: unseen sub-agent routes, unknown frame kinds, pending asks, KAS hooks, concurrent readers and handles no keepalive reaches all fall back to the old oracle and hard-cap rules. Shells and introspect keep the old rules. The oracle-await guard change stops a co-tenant's frames from restarting the tool idle window without affecting the stale clock. The keepalive mark survives runtime start, fresh conversations and MCP re-injection, and the heartbeat route stays authenticated and session-scoped. Every new bound is a watchdog setting that is clamped to the turn ceiling and the hard cap, and 0 turns it off. A maintainer listed in MAINTAINERS.md recorded the product decision, and the rule it supersedes had no earlier entry. Tests drive the An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
bc33340 to
f1ed431
Compare
buluoray
left a comment
There was a problem hiding this comment.
Approve on f1ed431. Both GPT code findings and the SAST pid literal are fixed with tests that a mutation turns red, and the agent-session credits are gone from the decision entry; code is correct. Not mergeable yet: GPT keeps a fenced [BLOCK-MERGE] because the decision's Evidence (:46) still links no maintainer statement, and First Principles still BLOCKs on product shape. Both need Bolin (a decision comment on the PR linked in Evidence, then maintainer overrides). Decisive lines: src/kiro_crew/dashboard/handlers/sessions_parts/live_turn.py:489 (_HEARTBEAT_SUBAGENTS_MAX = SPAWN_BATCH_MEMBERS_MAX, 128 from core_agent_schemas.py:80), src/kiro_crew/dashboard/handlers/sessions_parts/live_turn.py:550 (a child with _prompt_hooks_running counts as moving now), test/test_acp_provider.py (runtime.pid = UNALLOCATABLE_PID), docs/decisions/2026-11-08-a-non-shell-tool-call-has-its-own-silence-timer.md:46 (Evidence still links no on-record artifact)
f1ed431 to
2a21bc2
Compare
2a21bc2 to
e609b70
Compare
e609b70 to
dfd1442
Compare
91b871d to
ae020be
Compare
ae020be to
fa7bf6e
Compare
fa7bf6e to
bdae157
Compare
|
Coverage Gate at bdae157 is main's red, not this PR's: the per-file floor fails on |
On a shared kiro-cli runtime a built-in file edit dispatched next to a subagent launch was auto-approved, never ran, and held its turn for 32 minutes. Two things kept the tool-stall watchdog from recovering it. A frame that lands while the watchdog awaits the liveness oracle voids that verdict, since its owner is not known until it is dequeued. The guard also set the session's own idle clock to now, so a co-tenant subagent's fanned-out roster frame threw away the idle collected so far and restarted the whole window. The guard now advances only the stale clock. The own clock moves for a frame proven to be this session's: one still queued is judged at dequeue, and one a concurrent _wait_for_response buffered is counted in _own_ingress_seq unless it is marked fanout_no_owner. The co-tenant's frames also kept the empty-queue arm from running at all, and a non-shell call matched no narrowing tag, so it waited the build-scale suspect window. Each non-shell call on kiro-cli and KAS now has its own silence timer, read on every pass of the dispatch loop: it starts at dispatch and only a frame attributable to that call restarts it. Built-ins and tools on a url-declared MCP server get 5 minutes, other MCP tools 30 minutes, sub-agent calls 10 minutes counted from the sub-agent's own frames. Kiro Crew's own long tools send an MCP progress heartbeat about every 30 s and a keepalive naming their call; a wait on a person (an approval, an MCP elicitation) holds its call until it is answered, and the answer restarts the timer. Shell calls keep the oracle rules and the hard cap stays the backstop. Every bound is a watchdog setting, and a decision entry records the rule this supersedes. A native sub-agent's calls send nothing while they run and no Kiro Crew watchdog times them, so any call one has open (a shell, a built-in, a Kiro Crew wait or ask_question, any other MCP call, its own sub-agent call) holds its parent's sub-agent call, and a heartbeat naming such a call counts only as that sub-agent's activity. Every KAS frame naming a subtask counts as its sub-agent's activity. kiro-cli streams a native sub-agent under its own session id, which the runtime routes to the parent only while the parent is the one session registered on it (AcpRuntime.routes_roster_children_to), so on a shared runtime the parent's sub-agent call loses its timer and waits for the oracle and the hard cap. A timer runs for a call only while the session can prove it would see that call's activity; where it cannot, the oracle and the hard cap judge the call. The runtime counts every frame that named a session and reached none (AcpRuntime.unrouted_child_frames), so a kiro-cli sub-agent call also loses its timer when its sub-agent's frame was dropped beside a co-tenant registered for less than one timer read, a window the route answer alone never sees. A frame of a kind the timer cannot read retires the timer of the call it names. Every call is paused while an ask naming no call waits or a KAS hook runs, since a hook can gate a call and names none, and no timer is read while a concurrent request reader holds the session's frames. The paused stretch is subtracted from every call's silence once, even where the consumer also holds an event meanwhile (it parks on the very ask that paused it, or on any event while a hook runs). A call on Kiro Crew's own servers proves it is alive by its heartbeat, which /api/session-keepalive hands to the provider the gateway's own registry holds under the session's key; that provider, an AcpProvider, forwards it to its live AcpSessionProvider. So such a call is timed only on a handle whose provider that registry published: the registry DashboardState holds marks each provider it publishes (kiro_crew.keepalive_route), and the mark reaches the handle across a runtime start, a fresh conversation and an MCP re-injection. kirocrew chat and kirocrew run hold their provider in their own process, and a sub-agent run on a shared handle, eval's own registry and an app's own runner hold theirs outside that registry, so there the oracle and the hard cap judge those calls, and every other call keeps its timer. kiro-cli dispatches introspect and never sends a result frame for it, and the model's next step can be another call with no text between or a sibling in the same batch, so introspect gets no timer: its _meta.kiro.toolName stamp names it on kiro-cli and the oracle and the hard cap judge it as before. Any other call's timer is retired by the model's own next text or thinking, since the model starts a new step only once its calls have returned. On expiry the turn takes the non-lethal tool-stall recovery naming the call, handed back to the model on the same session as a timeout error it may retry: the dashboard and a sub-agent run as their recovery prompt, and a messaging channel turn, the native Slack turn, an agent channel member's turn, the CLI chat, the task runner and stream_and_collect (cron and other background turns) inside the turn, at most STOP_RECOVERY_MAX_RETRIES times, with the turn's usage summed. The task planner, the plan refine, eval and the other callers that stream a prompt themselves still end on the stall; the decision entry records that cost.
bdae157 to
18571d0
Compare
|
/ai-review override first-principles 18571d0 owner-decision: agent: the maintainer decided this product shape: the per-call silence timers are ON by default (5/30/10 min), superseding the 90-minute suspect window, confirmed on 2026-11-10 21:10 PST in #34763 (comment) and recorded in the decisions entry this PR adds. |
Human judgment recorded@bolichen97 recorded a owner-decision release (class
This decision applies only to this commit. A new push requires a new judgment. |
Problem / Motivation
Goal: A tool call that is lost next to a sub-agent launch is cancelled at its own silence bound and handed back to the model, instead of holding the turn for half an hour.
On a shared kiro-cli runtime a built-in file edit dispatched next to a sub-agent launch can be auto-approved and never run. A co-tenant sub-agent's frames, which land while the tool-stall watchdog awaits the liveness oracle, restart the watchdog's whole idle window, and a non-shell call matches no narrowing tag, so it waits the build-scale suspect window. The reporter's turn hung for 32 minutes.
Why it matters
Anyone who runs sub-agents on the default kiro-cli backend can lose a turn to one dropped call, with no signal until the hard cap.
Not a goal
What changed (motivation → approach → change)
Symptom: the lost call is never recovered in time. Causes: a frame that lands during the oracle await resets the session's own idle clock, and the empty-queue arm never runs while a co-tenant talks. Change: the guard advances only the stale clock, and each non-shell call on kiro-cli and KAS gets its own silence timer (built-ins and url-declared MCP tools 5 min, other MCP tools 30 min, sub-agent calls 10 min from the sub-agent's own frames). On expiry the turn takes the non-lethal tool-stall recovery naming the call. A timer runs only while the session can prove it would see the call's activity, otherwise the oracle and the hard cap judge the call. Every bound is a watchdog setting; the decision entry
docs/decisions/records the rule it supersedes. The keepalive route reads the sub-agent model-wait window (watchdog.model_silent_probe_secs) from the session handle'sWatchdogSettingssnapshot (live_turn._model_think_window), never from config.json on the event loop.Backwards compatibility
Compatible: nothing that is accepted today is rejected; the timers only add a bound on calls that previously waited for the oracle and the hard cap, and every bound can be set to 0.
Removes nothing: no key, function, record or path is removed or renamed.
Tests
test_acp_tool_silence_visibility.py::test_a_spawn_beat_carries_its_childrens_activity_through_the_provider[quiet|moving]: throughprompt()on a realAcpProviderover a realAcpSessionProvider, aspawn_sub_agentsbeat naming quiet children is cut one sub-agent bound after their last activity, and with moving children the turn endsend_turn. Red against the mutants that drop or ignoreactivity_atinAcpProvider.note_tool_heartbeat.test_kas_mcp_live_reinject.py::...::test_a_handle_no_keepalive_reaches_stays_unrouted_across_the_swap: theFalsecarry row for MCP re-injection.test_a_kiro_crew_call_is_timed_only_where_its_keepalive_reaches[non-core-server-*]: a call onkirocrew-panel, a non-coreKIROCREW_BIN_MCP_SERVERSserver.The 18 changed test files and both ratchets: 1541 passed.
Rebased onto main after review (26e8b0c); patch unchanged by the rebase. Head 2a21bc2.
Review repairs at 2a21bc2: the heartbeat route reads every member of a wave (cap
SPAWN_BATCH_MEMBERS_MAX, was 64) and counts a sub-agent running its prompt hooks as moving now (test_tool_heartbeat_route.py, two new tests, red with thelive_turn.pyhunk reverted, 2 failed 9 passed; green with it). The recovery-marker parity tests takeTOOL_STALL_RECOVERY_PREFIXfromkiro_crew.timed_out_call; the facade mirror lists_join_continued.Lane run at 2a21bc2 (DevSpace): the changed test files plus
test_recovery_marker_parity,test_recovery_card_prefixes,test_recovery_card_parity,test_facade_mirror_guards,test_flake_pattern_ratchet: 1580 passed (exit 0);test_acp_provider, ratchet and heartbeat route again after the final edit: 182 passed.check_harness_parity,check_comment_history,check_brand_name,check_file_line_cap(0 FAIL), flake8, isort clean;mypy --platform linux src/kiro_crew: no issues.CI on the previous head caught
test_sessions_parts_facade.py::test_every_project_name_an_owner_serves_is_named_for_type_checkers(the newSPAWN_BATCH_MEMBERS_MAXimport inlive_turn.py); the facade now names it for type checkers, and that file plustest_facade_mirror_guards, the heartbeat route tests and the flake ratchet pass (159 passed), mypy--platform linuxclean.Manual verification repros re-run at this head: the clause-2 lost-edit repro and the co-tenant oracle-await repro both exit 0.
Rebased onto main after review; patch unchanged (head 91b871d; range-diff differs only in decisions README context and two context lines in
session_provider.py). Related tests re-run on a DevSpace at 91b871d:test_acp_tool_silence_timer,test_acp_tool_silence_visibility,test_acp_tool_stall_cotenant_await: 164 passed;scripts/docs-lint.shpasses.Rebased onto main after review (bb7048c); the four conflicts (decisions README rows,
browser.md, thesession_handle_dispatch.pydocstring, thewave.pyimports) keep both sides. Range-diff shows only those resolutions.Review repair at e174914a04 (Opus lane, no blocking call on the event loop): the keepalive route no longer calls
KiroCrewConfig.load()per beat.test_tool_heartbeat_route.py::test_a_wave_heartbeat_loads_no_config_on_the_event_loopdrives the realapi_session_keepalivewithsubagent_idsand fails if config is loaded;test_the_model_window_is_the_session_handles_watchdog_snapshotpins a 600 s handle window and the no-handle default. On a DevSpace: both pass at e174914a04 (exit 0), and with thelive_turn.pyandsessions.pyhunks reverted to the pre-repair head both fail (exit 1:assert 1 == 0load count;[('tc', None)]vs the stale stamp).User-scenario repros re-run at e174914a04 against base bb7048c: co-tenant oracle-await repro base exit 1, fix exit 0 (S1 and S2 cut at +3.03 s and +3.02 s); lost-edit repro base exit 1 (turn timeout at +14.8 s), fix exit 0 (edit cut at +3.01 s and handed back as a timeout error). flake8 and isort on the changed files,
check_black_formatting.py,check_comment_history.pyandcheck_brand_name.py: exit 0. The test files and gates run in GitHub CI.Rebased onto main after review; patch unchanged (e8283ce: the three main commits since bb7048c touch no file of this PR; range-diff
=).CI at ae020be caught
check_file_line_cap.py: main's feat(acp): share one agent process across dashboard chats, behind the chat_runtime_sharing preview #33855 tookacp/session_provider.pyto 1,989 lines and this change to 2,007.touch_activity,note_tool_heartbeatandmark_keepalive_routedmove whole intoacp/session_provider_keepalive.py, bound by name in the class body assession_provider_sharedis; the file is 1,981 lines. On a DevSpace at fa7bf6e:check_file_line_cap.py0 failures, the three members' tests intest_acp_session_provider.py(4 passed), both heartbeat-route repros and both user-scenario repros exit 0, flake8, isort,check_black_formatting.py,mypy --platform linuxon the two files,check_comment_history.py,check_brand_name.py,check_harness_parity.pyandscripts/docs-lint.shexit 0.Rebased onto main after review; patch unchanged (e1b079c; range-diff
=). CI at fa7bf6e failedtest_wait_discipline_ratchet.py::test_the_scan_matches_known_sitesandtest_updates_handlers_facade.py::test_every_name_served_from_outside_the_family_is_visible_to_type_checkers, both red on that base and fixed on main by test: give the boot apply sigterm test the 30 s wait ceiling #35625. On a DevSpace,pytest -n0 -p no:cacheprovideron those two node ids: exit 1 at fa7bf6e (2 failed:test_update_boot_apply.py:335 wait_for(10s),Right contains 1 more item), exit 0 at bdae157 (2 passed), exit 1 again at bdae157 with test: give the boot apply sigterm test the 30 s wait ceiling #35625 reverted (2 failed). User-scenario repros (repro-clause1.sh base|fix,repro-clause2.sh base|fix <worktree>) at bdae157 against base e1b079c: co-tenant oracle-await repro base exit 1 (S1 cut at +5.44 s, S2 to the turn timeout at +8.99 s), fix exit 0 (S1 and S2 cut at +3.02 s and +3.03 s); lost-edit repro base exit 1 (turn timeout at +14.8 s), fix exit 0 (Editing notes.mdcut at +3.01 s and handed back as a timeout error). Related tests at bdae157 (the changed test files plus the recovery-card parity, facade, flake and wait-discipline guards): 1736 passed;check_file_line_cap.py,check_harness_parity.pyandscripts/docs-lint.shexit 0.Rebased onto main after review; patch unchanged (105933a, head 18571d0; range-diff differs only in context lines of
mcp_shared_dispatch.pyandbrowser.pyfrom main's perf: list MCP tools before loading tool handlers #35293). That main carries test(updates): cover gateway_restart and update_boot_apply to the 80% floor #35725, the fix for the Coverage Gate per-file floor that fix(updates): never restart a running gateway; apply at the next start #35088 broke: CI run 43147401306 at bdae157 tested a merge into e1b079c, which lacks it. On a DevSpace at 16ee7bc0e4 against base 1bccaa1 (src/tree 8b6a0a0013 in both 16ee7bc0e4 and 18571d0; fix(desktop): keep the quit-time update apply across a second quit #35770, the one main commit between, changes only Electron files and a doc): the member reprotool-stall-window-reset-by-cotenant.sh base|fix(co-tenant oracle await) base exit 1 (S1 cut at +5.46 s, S2 to the turn timeout at +8.99 s), fix exit 0 (S1 and S2 cut at +3.04 s and +3.03 s);tool-stall-window-reset-by-cotenant-clause2.sh base|fix <worktree>(lost edit) base exit 1, fix exit 0. The real-runtimerepro.py clause1|clause2(two sessions each with a lost edit under a streaming co-tenant roster; one lost edit under a 60 s suspect window): base exit 1 (turn timeouts at +9.00 s and +15.00 s), fix exit 0 (Editing notes.mdcut at +3.06 s and +3.02 s and handed back as a tool stall). An import of the changed MCP and ACP modules andgenerate_config_baseline.py(no diff): exit 0. The test files and gates run in GitHub CI.Proof: not provable -- other: the new modules are imported at collection, so reverting every production hunk only errors at collection; red runs were taken by mutants instead
Manual verification
Both reported-failure repros, scaled windows with a real fake-kiro child over the real runtime reader: base exit 1, fix exit 0 (lost edit cut at +3.01 s, recovery prompt handed to the model).
Related Issues
N/A -- no public issue.
Sibling sweep
Swept: git grep -n "last_own_data_ts|note_tool_heartbeat" -- src/
Sibling: src/kiro_crew/providers/acp.py:1282 -- changed here -- the provider the registry holds now forwards the heartbeat
Sibling: src/kiro_crew/acp/session_provider_mcp_reinject.py:198 -- changed here -- the re-injection swap carries the keepalive mark
Pattern harvest
Not generalizable: a forwarding wrapper that silently dropped a keyword argument; each pin is a test through the public entry point.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.