Skip to content

fix(scheduler): deliver system injects through session cancel; defer bash job ack - #17

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-cb7a
Draft

fix(scheduler): deliver system injects through session cancel; defer bash job ack#17
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-cb7a

Conversation

@cursor

@cursor cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes three correctness bugs found in recent scheduler/notification changes.

Bugs fixed

1. Session cancel dropped subagent/bash notifications (significant breakage)

  • Impact: After cancel, flush_pending_subagent_lifecycle / flush_pending_for_session enqueued system injects while _cancelled_sessions was still set; dispatch skipped them and pending entries were already popped → notifications lost forever.
  • Root cause: Cancel skip logic treated all queued requests equally.
  • Fix: Exempt subagent, bash_job, and goal_start frontend injects from cancel skip (user turns still skipped; agent_wake still aborts for poll retry).

2. Bash job marked notified before delivery

  • Impact: deliver_via_inject called _mark_notified immediately after inject_turn enqueue; cancel/skip/crash before dispatch permanently dropped notifications.
  • Fix: Stage job on enqueue; confirm via _finalize_bash_job_delivery only after kernel runs the inject turn (mirrors agent_wake).

3. /skill context not checkpointed

  • Impact: load_skill_for_session injected tool pair into memory only; Core TTL evict lost loaded skill context.
  • Fix: Call agent._finalize_turn(None) after injection.

Validation

  • tests/test_kernel_runtime.py (cancel exempt + user skip)
  • tests/test_bash_job_notify_deliver.py (deferred mark)
  • tests/test_load_skill_slash.py (finalize turn)
  • test_cancel_skip_aborts_agent_wake_delivery still passes
Open in Web View Automation 

…bash job notify ack

- Exempt subagent/bash_job/goal_start injects from cancel skip so flush
  during cancel does not drop lifecycle notifications
- Defer bash job mark_notified until kernel confirms delivery (staged until
  _finalize_bash_job_delivery), matching agent_wake semantics
- Persist /skill load_skill context via _finalize_turn checkpoint flush

Co-authored-by: Yuxuan Liu <Osc-7@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant