Repository navigation
fix: let a queued reset wait for a completion already in the tab queue - #36601
bolichen97 wants to merge 1 commit into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The wait, the notice settle and the What this change shipsInventory (6 items) — 5 justifiedIntent: when the agent or a person resets a conversation mid-turn, a sub-agent result already queued for the old conversation should not become the fresh conversation's first turn, and the old conversation's failure notices should not leak into it. FIX.
[FIRST-PRINCIPLES-REVIEWED] 87190fa Description read[DESCRIPTION-READ] 83803288dee05b6730843b2b629a24a92229a2fddadb6febebaf0d14f108a930 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix is a narrow change to Notes
[DESIGN-REVIEWED] 87190fa Description read[DESCRIPTION-READ] c3061aabd221a72de523f9eec5c7dd6b887bb32fb3579cce8cd9c61cf0ab8471 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 |
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: |
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.
Approve on e850cae. This change makes a conversation reset that was queued during a turn wait until a sub-agent completion already in the tab's queue has run in the conversation it was meant for. The reset then lands at the end of that completion's turn. Only the turn-end consumers wait. The background retry does not, so a held queue still gets its reset about five seconds after the turn ends. A landed reset now settles the failure notices meant for the dropped conversation instead of passing them to the fresh one. The user still sees those notices, because each one is already shown as a card in the tab. Every new guard has a test that fails without it. Waiting: one backend test shard lost its runner (an infrastructure failure, not a test failure), and the coverage gate failed closed because of that shard. Both need a rerun on this head. Decisive lines: src/kiro_crew/dashboard/chat_turn/session_reset.py:443, src/kiro_crew/dashboard/chat_turn/session_reset.py:516-519, src/kiro_crew/dashboard/chat_turn/queue_drain.py:743-829
|
[operator: bolichen97] CI is red here for an infrastructure reason, not a test failure.
The same shard fails the same way on I re-ran the two failed jobs once on this head instead of rebasing, so the approval pinned to e850cae stays valid. If the shard loses its runner again, the next pass rebases onto
|
|
[operator: bolichen97] Holding this head; a new commit is coming, so please do not re-run its failed jobs.
|
[operator: bolichen97] |
A conversation reset queued during a turn (the reset_conversation tool, or a /clear the dashboard answers itself) landed at the turn's end even when a sub-agent completion was already waiting in the tab's queue, so the hand-off then started the fresh conversation with the old one's result. Failure notices pending for the old conversation reached the fresh one's next prompt the same way. The end-of-turn and /clear consumes (own_turn) now leave the discard armed while the queue holds a completion, or a verbatim requeue of one; the hand-off drains it into the conversation it was queued for and the consume at that turn's end lands the reset. The armed-reset retry does not wait on it, so a held queue still gets its reset a few seconds later. A landed discard settles the tab's pending failure notices as a drain does. A /clear whose discard waits only on a queued completion marks it, and the plan is dropped where the discard lands, as a landed /clear drops it: the completion turn runs in the old conversation and can re-send that conversation's plan. The specs record the wait, the settle and the plan drop, and the #12069 pointers say the conversation-incarnation counter was declined there. Closes #35237 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased: main moved in docs/system-specs/modules/session.md, docs/system-specs/modules/subagent.md, src/kiro_crew/dashboard/chat_turn/session_reset.py, src/kiro_crew/dashboard/chat_turn/slash_commands.py, src/kiro_crew/dashboard/state_parts/chat_slot.py, src/kiro_crew/dashboard/state_parts/slot_session.py, test/test_state_parts_facade.py since this head went green (c22557c -> 88ce21a); CI re-running. The [operator: bolichen97] |
e850cae to
87190fa
Compare
|
self-added: no
[operator: bolichen97] |
|
[operator: bolichen97] CI is red here for an infrastructure reason, not a test failure.
Every other check on |
Problem / Motivation
Goal: A conversation reset queued during a turn lands only after a sub-agent completion already waiting in the tab's queue has run in the conversation it was queued for, and failure notices still pending when it lands are not handed to the fresh conversation.
When the agent resets its conversation during a turn while one of its sub-agent completions waits in the tab's queue, the reset lands at the turn's end and the queue hand-off then starts the fresh conversation with that completion. Failure notices pending for the old conversation are drained into the fresh conversation's next prompt.
Why it matters
When the agent resets its conversation mid-turn (the
reset_conversationtool, or a/clearthe dashboard answers itself) while one of its sub-agent completions waits in the tab's queue, the fresh conversation's first turn is that old run's result. The new conversation spends a turn, and its context, on work that belonged to the conversation that was just dropped, and failure notices for the old conversation reach the new one's next prompt the same way.Not a goal
What changed (motivation → approach → change)
A reset queued during a turn now waits for a sub-agent completion already in the tab's queue: the completion runs in the conversation it was queued for, then the reset lands. A landed reset also settles the tab's pending failure notices instead of leaving them for the fresh conversation's next prompt. A
/clearthat waits this way drops the checklist where the reset lands, so the fresh conversation does not rebuild the old plan.The queued reset already waited for attached sub-agent work (running children, store-queued rows, deliveries in flight), but not for a completion sitting in the tab's queue, so it landed at the turn's end and the queue hand-off gave that completion to the new conversation.
In
_consume_pending_reset's discard branch (the shape decided on #12069), theown_turnconsumes (the end-of-turn one and the dashboard-answered/clear) leave the discard armed while the queue holds aSUBAGENT_COMPLETION_KINDentry (the test the drain's user hold already makes) or a verbatim requeue of a completion turn (_REPLAYS_COMPLETION_KEY); one helper,_a_completion_is_queued, makes that test. The hand-off still drains system entries behind an armed discard, so the completion runs in the old conversation and the consume at that turn's end lands the reset. The armed-reset retry does not wait on a queued completion, so a held queue (sign-in, memory preparation, Pause all) still gets its reset a few seconds after the turn ends. A discard that lands settles the pending notices withsettle_drained_subagent_notices, the helper both notice drains use.A dashboard-answered
/clearwhose discard waits only on a queued completion (no children attached) marks it with one slot flag,_pending_discard_drops_plan, and the consume drops the plan (slot.set_todo(None)and itstodo_update) where that discard lands, as a/clearthat lands at once does. It cannot drop it at the/clear: the completion turn runs in the old conversation, whosetodo_listcan send its whole plan again. Its reply text and recorded outcome (queued) stay as they are. The hold giving the discard up clears the flag.session.mdrecords the wait, the plan drop, why the immediate route's 409 does not share the wait, and the settle; its two #12069 pointers and the two insubagent.mdsay the conversation-incarnation counter was declined there.Backwards compatibility
Compatible: a reset with no completion queued lands exactly as before; one with completions queued lands once those completions have run, and the route, the retry and the shared check are unchanged. A
/clearwaiting on a queued completion drops the plan where its reset lands, as a/clearthat lands at once does; a/cleardeferred for attached children or a busy session, and areset_conversationreset, keep the plan as before.Removes nothing: the change only defers a reset until the completions already queued have run, settles notices a landed reset used to leave for the next prompt, and drops a
/clear's plan where its reset lands; no key, path, record or function goes away.Tests
test/test_queued_reset_waits_for_queued_completion.py, driving the real_consume_pending_reset,_answer_slash_without_channeland_start_next_queued_turnagainst a dashboard slot:/clearwith a completion queued and no children attached recordsqueuedand keeps the plan shown; the completion runs in the old conversation and sends its plan again; its turn end lands the discard, drops the plan with onetodo_updateofNone, clears the flag and leavestodo_recovery_prompt()empty;/cleardeferred because children are attached, with or without a completion queued, keeps the plan, sends notodo_updateand sets no flag;reset_conversationdiscard keeps the plan when it lands.test/test_state_parts_facade.py: the fresh-slot default table lists_pending_discard_drops_plan: False.Proof: PROVEN test/test_queued_reset_waits_for_queued_completion.py::test_a_queued_completion_runs_in_the_old_conversation_before_the_reset_lands, test/test_queued_reset_waits_for_queued_completion.py::test_a_verbatim_requeue_of_a_completion_counts, test/test_queued_reset_waits_for_queued_completion.py::test_a_held_queue_does_not_strand_the_reset, test/test_queued_reset_waits_for_queued_completion.py::test_a_landed_reset_settles_the_pending_failure_notices, test/test_queued_reset_waits_for_queued_completion.py::test_a_clear_waiting_on_a_queued_completion_drops_the_plan_where_it_lands (head cc19139186c6)
Determinism: the file ran 20 times at
-n0(10 passed each, 0 failures) and 10 times at-n 4 --dist loadgroup --max-worker-restart=2withtest_queue_hold_gate.pyandtest_slot_running_readers.py(66 passed each); the 64 node ids of this file andtest_queue_hold_gate.pyran once in a shuffled order (seed 20083,-n0): 64 passed. No sleeps, ports or real clock; every await is bounded by the existing turn-end helpers.test_flake_pattern_ratchet.pypasses (68), the repository semgrep rules (1.78.0) find nothing on the diff, andscripts/local-gate.pypassed 13,804 related backend tests.Manual verification
How it was verified, on Linux (Ubuntu 24.04, kernel 7.0, Python 3.12): the trigger is a model calling
reset_conversation, or a person sending/clear, while a sub-agent completion waits in the tab's queue, which cannot be timed deterministically by hand, so the reproduction drives the real end-of-turn consume,/clearanswer and hand-off on a dashboard slot. Before the fix it recorded:and, for a
/clearbehind a queued completion whose turn sends the old plan again, the plan still set after the discard landed:After the fix (smoke):
The completion runs while the discard is still armed (the old conversation), the reset lands at that turn's end, and the fresh conversation starts with no plan; with nothing queued,
/clearlands at once. The nearby suites (test_queue_hold_gate.py,test_dashboard_chat.py,test_dashboard_chat_refusal.py,test_chat_runner_coverage_pending.py,test_slot_running_readers.py,test_mate_thread_wakes.py,test_chat_runner_composition_contract.py,test_chat_runner_base_surface.py,test_slash_command_redaction_records.py,test_slash_command_no_channel.py,test_state_parts_facade.py,test_todo_pill_resync.py,test_todo_list_surface.py) pass file by file.Related Issues
Closes #35237
Sibling sweep
Swept: git grep -n "_consume_pending_reset(" -- src
Sibling: src/kiro_crew/dashboard/chat_turn/session_reset.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/slash_commands.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/queue_cycle.py:773 -- not affected -- the end-of-turn consume passes own_turn, so the new wait applies to it as it stands
Sibling: src/kiro_crew/dashboard/chat_turn/eager_spawn.py:655 -- not affected -- it never consumes a discard (no allow_discard)
Sibling: src/kiro_crew/dashboard/chat_turn/turn_admission.py:932 -- not affected -- it never consumes a discard (no allow_discard)
Sibling: src/kiro_crew/dashboard/chat_api/slot_repair.py -- not affected -- the immediate reset route keeps its 409 on attached children only, by decision
Swept: git grep -n "set_todo(None)" -- src
Sibling: src/kiro_crew/dashboard/chat_turn/session_events.py:241 -- not affected -- kiro's native /clear drops the plan on its own clear status and queues no discard
Swept: git grep -n "_pending_discard_conversation_key = " -- src
Sibling: src/kiro_crew/dashboard/state_parts/slot_session.py:384 -- changed here
Sibling: src/kiro_crew/dashboard/session_directive_apply_slot.py:225 -- not affected -- it arms a discard; only the dashboard-answered /clear sets the flag
Sibling: src/kiro_crew/dashboard/state_parts/chat_slot.py -- changed here
Pattern harvest
Not generalizable: the wait is specific to a deferred discard racing the tab's own queue; its kind test mirrors the one the drain's user hold already makes.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement