Skip to content

fix(tui): propagate error messages when subagent tasks crash#292

Merged
echobt merged 1 commit intomasterfrom
fix/subagent-crash-error-propagation
Jan 27, 2026
Merged

fix(tui): propagate error messages when subagent tasks crash#292
echobt merged 1 commit intomasterfrom
fix/subagent-crash-error-propagation

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 27, 2026

Summary

When a subagent (Task tool) terminates unexpectedly due to a panic or cancellation, the main agent now receives a proper error message instead of no response at all.

Problem

When a subagent is launched (e.g., 'task research'), it creates a todo list and starts working. However, if the subagent task crashes unexpectedly (panic, timeout, cancellation), the todo list disappears and no message is received by the main agent. This made it impossible to understand what went wrong.

Solution

Added check_crashed_tasks() method that:

  • Periodically checks for finished JoinHandles in running_tool_tasks (called on every tick)
  • Detects tasks that ended without sending Completed/Failed events
  • Extracts panic messages or cancellation status from the JoinHandle
  • Sends ToolEvent::Failed with descriptive error message back to main agent

Example Error Messages

  • Panic: Subagent panicked: <panic payload>
  • Cancelled: Subagent task was cancelled
  • Other: Subagent task failed: <error>

Testing

  • cargo check -p cortex-tui passes
  • cargo fmt -p cortex-tui -- --check passes

When a subagent (Task tool) terminates unexpectedly due to a panic or
cancellation, the main agent now receives a proper error message instead
of no response at all.

Added check_crashed_tasks() method that:
- Periodically checks for finished JoinHandles in running_tool_tasks
- Detects tasks that ended without sending Completed/Failed events
- Extracts panic messages or cancellation status from the JoinHandle
- Sends ToolEvent::Failed with descriptive error back to main agent

This fixes the issue where the todo list disappears and no message is
received by the main agent when a subagent encounters an unexpected error.
@blacksmith-sh
Copy link

blacksmith-sh bot commented Jan 27, 2026

Blacksmith Account Suspended

This Blacksmith account requires additional verification. Jobs targeting Blacksmith runners will not be picked up and will remain queued until they timeout.

Please contact Blacksmith Support for assistance.

@echobt echobt merged commit 8ba6676 into master Jan 27, 2026
2 of 3 checks passed
@echobt echobt deleted the fix/subagent-crash-error-propagation branch January 27, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants