Context
The run_scheduler_loop() tokio::select! introduced in #1603 has two branches that break out of the loop without canceling running sub-agents:
Ok(None) | Err(_) — channel closed
shutdown_signal() fired
Both exit with GraphStatus::Failed but do not call scheduler.cancel_all() or forward Cancel actions to subagent_manager. Sub-agents spawned as tokio tasks will continue running until they complete naturally or timeout, wasting resources.
Impact
Low for MVP — graceful shutdown already handles process exit, and channel close is uncommon during plan execution. However, long-running sub-agent tasks (multi-step tool loops) could consume significant resources after the scheduler loop exits.
Acceptance criteria
In the channel-close and shutdown branches of run_scheduler_loop():
- Call
scheduler.cancel_all() and process the returned Cancel actions via subagent_manager.cancel()
- Add a log warning indicating abnormal exit with sub-agent count
Labels
enhancement, robustness
Context
The
run_scheduler_loop()tokio::select!introduced in #1603 has two branches that break out of the loop without canceling running sub-agents:Ok(None) | Err(_)— channel closedshutdown_signal()firedBoth exit with
GraphStatus::Failedbut do not callscheduler.cancel_all()or forwardCancelactions tosubagent_manager. Sub-agents spawned as tokio tasks will continue running until they complete naturally or timeout, wasting resources.Impact
Low for MVP — graceful shutdown already handles process exit, and channel close is uncommon during plan execution. However, long-running sub-agent tasks (multi-step tool loops) could consume significant resources after the scheduler loop exits.
Acceptance criteria
In the channel-close and shutdown branches of
run_scheduler_loop():scheduler.cancel_all()and process the returnedCancelactions viasubagent_manager.cancel()Labels
enhancement, robustness