feat(scheduler): cancel sub-agents on channel close and shutdown signal#1692
Merged
feat(scheduler): cancel sub-agents on channel close and shutdown signal#1692
Conversation
In run_scheduler_loop(), the Ok(None)|Err(_) and shutdown_signal() branches now call scheduler.cancel_all() and forward the returned Cancel actions to SubagentManager::cancel(), preventing orphaned sub-agent tasks from consuming resources after the scheduler loop exits. Also adds tracing::warn! with sub-agent count in both abnormal exit branches, and adds the missing defensive GraphStatus::Canceled fallback to the /plan cancel branch (identified in code review). Closes #1613
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.
Summary
run_scheduler_loop(), both abnormal exit branches (Ok(None)|Err(_)channel close andshutdown_signal()) now callscheduler.cancel_all()and forward the returnedCancelactions toSubagentManager::cancel(), preventing orphaned sub-agent tasks from consuming resources after the loop exitstracing::warn!(sub_agents = n, ...)in both branches to log abnormal exits with the count of cancelled sub-agentsGraphStatus::Canceledfallback to the/plan cancelbranch (parity with existingcancel_tokenbranch)match result { Ok(Some(msg)) => ... Ok(None)|Err(_) => ... }toif let ... elseto satisfyclippy::single_match_elseandclippy::redundant_elseTest plan
cargo +nightly fmt --checkpassescargo clippy --workspace --features full -- -D warningspassescargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins— 5288 passed, 12 skippedCloses #1613