fix(scheduler): abort queued wake inject on cancel; purge goal-check on terminal cancel - #21
Draft
cursor[bot] wants to merge 1 commit into
Draft
Conversation
…on terminal cancel When cancel_session_tasks skipped a queued agent_wake inject at dispatch, the wake stayed staged and poll_due_wakes never retried it. Call _finalize_agent_wake_delivery(confirmed=False) on the dispatch skip path. Terminal cancel also flushed staged goal-check wakes from the pending queue after the user aborted the session. Purge goal-check wakes at cancel start so flush_pending_wakes cannot resurrect them. Co-authored-by: Yuxuan Liu <Osc-7@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
1. Queued
agent_wakeinject permanently lost on session cancelpoll_due_wakesnever retried because the wake stayedstaged=True._dispatch_loopskipped cancelled queued requests without calling_finalize_agent_wake_delivery(confirmed=False). Only_run_and_routehad the abort path.inject_turnenqueues +_mark_staged→ user cancels before dispatch dequeues → skip at dispatch with no abort → wake stuck staged forever.2. Terminal cancel flushed staged goal-check wakes
goal-checkwake infinally, restarting auto-continue right after abort.cancel_session_tasksdid not purge_PENDING_BY_SESSIONgoal-check entries;flush_pending_wakes_for_sessionstill delivered them when inflight hit zero.finallyflush delivers wake inject.Fix
_finalize_agent_wake_delivery(request, confirmed=False)when dispatch skips a cancelled queued request.cancel_pending_wakes(session_id, label="goal-check")at the start ofcancel_session_tasks.Validation
tests/test_kernel_runtime.py::test_cancel_dispatch_skip_aborts_agent_wake_deliverytests/test_kernel_runtime.py::test_terminal_cancel_does_not_flush_staged_goal_checktest_cancel_skip_aborts_agent_wake_deliverystill passes