Skip to content

fix(scheduler,remote): post-cancel user turns + attachment sync reopen - #20

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

fix(scheduler,remote): post-cancel user turns + attachment sync reopen#20
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-management-b8e6

Conversation

@cursor

@cursor cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes two critical correctness bugs found in recent scheduler/remote attachment changes.

Bug 1: Post-cancel user messages silently dropped

  • Impact: After cancel_session_tasks, if the user immediately sent a new message while the cancel drain flag was still set, dispatch skipped it with CancelledError — the session appeared dead until the flag cleared.
  • Root cause: Skip logic keyed only on _cancelled_sessions membership, with no distinction between pre-cancel queued turns and post-cancel new user submits.
  • Fix: Increment per-session cancel epoch on cancel; stamp enqueue_cancel_epoch on submit/inject; skip only when stamped epoch is older than current epoch (agent_wake/system inject semantics preserved).

Bug 2: Feishu attachment sync fails after worker reconnect

  • Impact: Remote workspace state survived Core TTL, but after worker reconnect file_blob_write returned SESSION_NOT_OPEN; attachments were not mirrored to .macchiato/inbox while the turn continued in remote mode.
  • Root cause: attachment_sync called file_blob_write directly without the reopen path used by bash_tool.
  • Fix: Retry via open_workspace on session-not-open errors.

Validation

  • tests/test_kernel_runtime.py (cancel epoch + post-cancel user turn)
  • tests/test_attachment_sync.py::test_sync_reopens_worker_session_on_not_open
Open in Web View Automation 

…hment sync

- Stamp cancel epoch on enqueue so user messages submitted after
  cancel_session_tasks are not skipped while the cancel drain flag lingers
- Retry file_blob_write via open_workspace when worker session is not open
  after reconnect (Feishu attachment sync to remote inbox)
- Add regression tests for both paths

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