Background tasks report 'failed' with exit code 137 after manual KillShell termination

Resolved 💬 2 comments Opened Jan 22, 2026 by ArchitectVS7 Closed Feb 28, 2026

Description

When a background task is manually terminated using KillShell, the system later sends a task notification reporting the task as "failed with exit code 137". This is misleading since:

  1. Exit code 137 (128 + SIGKILL) is expected when a process is killed
  2. The task was intentionally terminated by the user/assistant
  3. The notification implies an unexpected failure rather than intentional termination

Steps to Reproduce

  1. Start a long-running command with run_in_background: true
  2. Use TaskOutput with a timeout to check on the task
  3. When TaskOutput times out (task still running), manually terminate with KillShell
  4. Observe that a task notification is sent reporting "failed with exit code 137"

Example Session

# Start background task
Bash: npm run test -- --run 2>&1
run_in_background: true
-> Command running in background with ID: bc5a96d

# Check output (times out because tests take a while)
TaskOutput: task_id: bc5a96d, timeout: 30000
-> retrieval_status: timeout, status: running

# Manually kill since we got the output we needed
KillShell: shell_id: bc5a96d
-> Successfully killed shell: bc5a96d

# Later, receive misleading notification:
<task-notification>
<task-id>bc5a96d</task-id>
<status>failed</status>
<summary>Background command "..." failed with exit code 137</summary>
</task-notification>

Expected Behavior

When a task is manually killed via KillShell, the notification should either:

  • Not be sent at all (since termination was intentional)
  • Report status as "terminated" or "killed" rather than "failed"
  • Include context that the task was manually stopped

Actual Behavior

The notification reports the task as "failed" with no indication that it was intentionally terminated, causing confusion about whether actual failures occurred.

Environment

  • Platform: Windows (win32)
  • Multiple occurrences observed in the same session

Impact

This creates noise and confusion during sessions where long-running tasks need to be monitored and occasionally terminated. Users may think tasks failed when they were actually successfully terminated.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗