-
Notifications
You must be signed in to change notification settings - Fork 2
bug(orchestration): "Plan failed. 0/N tasks failed" misleading message on scheduler deadlock #1879
Description
Summary
When a plan execution is interrupted mid-flight (e.g., stdin closes during piped testing, or agent shutdown while plan is running), the DagScheduler detects a deadlock: no running and no ready tasks, but graph is not complete. It transitions to GraphStatus::Failed.
The resulting user message is:
```
Plan failed. 0/5 tasks failed:
```
This is contradictory — the graph failed but 0 tasks are marked as `TaskStatus::Failed`. The deadlock was triggered by sub-agent cancellation (not task failure), which leaves tasks in a non-`Failed` state.
Root Cause
`scheduler.rs:396-404`: when deadlock detected, `graph.status = GraphStatus::Failed` but individual task statuses remain as they were (e.g., `Running` or `Pending` — never transitioned to `Failed`).
`mod.rs:1484-1496`: collects tasks with `TaskStatus::Failed` for the message → 0 matches → "0/N tasks failed".
Reproduction
- `/plan goal "find largest file in /tmp"`
- `/plan confirm`
- Send `/quit` while sub-agent is running
Result: `Plan failed. 0/5 tasks failed:`
Fix Options
- When scheduler deadlock fires, mark all non-completed tasks as `TaskStatus::Failed` with reason "scheduler deadlock — cancelled during execution"
- Or: emit a separate "Plan cancelled (N tasks did not run)" message for the deadlock path
- Or: add a `TaskStatus::Cancelled` variant and separate the cancelled vs failed count in the message
Severity
LOW — UX only, no data loss. Normal execution (plan runs to completion) is unaffected.