Skip to content

fix(automation): persist cancelled scheduled runs - #580

Open
gopi1949 wants to merge 1 commit into
andrewyng:mainfrom
gopi1949:fix/scheduler-cancelled-runs
Open

fix(automation): persist cancelled scheduled runs#580
gopi1949 wants to merge 1 commit into
andrewyng:mainfrom
gopi1949:fix/scheduler-cancelled-runs

Conversation

@gopi1949

Copy link
Copy Markdown

Problem

Scheduler shutdown raises asyncio.CancelledError, which bypasses except Exception. Because a TaskRun is persisted as running before execution begins, cancellation could leave that record stuck as running forever.

Fix

  • Cover startup broadcast and execution with the same cancellation/finalization scope.
  • Interrupt active engine/tool work, mark the existing run as error, set finished_at, persist it, and re-raise so an incomplete schedule is not advanced.
  • If execution already completed and only completion notification is cancelled, preserve ok and return normally so the scheduler advances instead of replaying side effects after restart.

Tests

Regression coverage now exercises cancellation during:

  • engine execution
  • the startup broadcast before engine creation
  • completion notification after successful execution

Six focused scheduler/automation tests pass. The full backend suite on Windows reports 1840 passed, 21 failed, and 4 skipped; the 21 failures are the existing Windows baseline and this change adds no new failures.

Finalize the existing run record when scheduler shutdown cancels execution, interrupt active engine work, and preserve completed work when only its notification is cancelled.

Co-authored-by: Copilot <223556219+Copilot@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