Skip to content

bug(orchestration): "Plan failed. 0/N tasks failed" misleading message on scheduler deadlock #1879

@bug-ops

Description

@bug-ops

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

  1. `/plan goal "find largest file in /tmp"`
  2. `/plan confirm`
  3. Send `/quit` while sub-agent is running

Result: `Plan failed. 0/5 tasks failed:`

Fix Options

  1. When scheduler deadlock fires, mark all non-completed tasks as `TaskStatus::Failed` with reason "scheduler deadlock — cancelled during execution"
  2. Or: emit a separate "Plan cancelled (N tasks did not run)" message for the deadlock path
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions