[Bug] Subagent terminal command completion event lost — causes indefinite hang during Run All Tasks
Bug Description
When "Run All Tasks" dispatches a subagent (spec-task-execution) that runs a terminal command (e.g., npx vitest run), the terminal command completes successfully (output visible in terminal) but the completion signal is never propagated back to Kiro, causing the entire execution to hang indefinitely until manually aborted.
Environment
- Kiro Version: 0.12.333
- OS: macOS 26.5.1 (darwin, Apple Silicon)
- Node: v24.16.0
Steps to Reproduce
- Create a spec with multiple tasks (5+ parent tasks, 20+ sub-tasks)
- Use "Run All Tasks" which dispatches subagents via
invoke_sub_agent - The subagent runs a terminal command (e.g.,
npx vitest run <file>) - Observe: terminal output appears in the users terminal (tests pass), but Kiro never advances — hangs indefinitely
Evidence from Logs
From ~/Library/Application Support/Kiro/logs/<session>/window1/exthost/kiro.kiroAgent/Kiro Logs.log:
10:43:01.688 [SubAgentGraph] Invoking sub-agent: spec-task-execution
10:44:08.527 Request payload: 175528 chars, 24 history messages (subagent last LLM call)
10:44:13.680 [Terminal] Terminal created successfully {"terminalId":1}
10:44:13.682 [Terminal] Executing command {"terminalId":1,"command":"cd /Users/.../Tolaria && npx vitest run src/utils/noteListHelpers.test.ts"}
<<<< NO FURTHER LOG ENTRIES FOR TERMINAL 1 >>>>
<<<< 5+ MINUTES OF SILENCE >>>>
10:49:37.495 [command] kiroAgent.executions.abortActiveAgent (user manually aborts)
10:49:37.499 [Execution] Completed with abort
Key observation: Terminal 2 (used later in the same session) has complete lifecycle:
[Terminal] Terminal created → Executing command → execute terminal command done → Command execution completed
Terminal 1 is missing both execute terminal command done and Command execution completed events, despite the command actually finishing (user can see 34 tests passed in their terminal at 10:44:15).
Possible Root Cause
The subagent used cd /path && npx vitest run ... form instead of the cwd parameter. Terminal 2 (which works) always has "cwd":"/Users/..." in its logs. Terminal 1 does not. The cd && command composite form may cause Kiro terminal completion detection to fail.
Impact
- Blocks core workflow: Run All Tasks is the primary spec execution flow
- Data loss: After manual abort,
taskList/taskUpdatetools become unavailable — all progress context is lost - No workaround: User cannot control how the subagent constructs terminal commands
Expected Behavior
Terminal command completion should be detected and propagated back to the subagent regardless of whether cwd parameter or cd && form is used. If cd && is not supported, the subagent should be constrained to use cwd only.
🤖 Potential Duplicate Detected
This issue appears to be similar to:
- #6717: executeBash: Terminal hangs after successful command, agent receives "Signal was cancelled" (88% similar)
What happens next?
- ⏰ This issue will be automatically closed in 3 days
- 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
- 💬 Comment on the original issue if you have additional information
Why is this marked as duplicate? Both issues report terminal commands hanging after successful completion, where the agent never receives the completion signal. Issue #6717 describes 'executeBash' hanging after successful command with 'Signal was cancelled', while the new issue describes a terminal command completing successfully but the completion event never propagating back to Kiro, causing indefinite hang. Both share the same core problem: terminal command execution completes but the agent framework fails to detect/receive the completion signal.
Thank you for this exceptionally detailed report — the log analysis and root cause hypothesis are very helpful.
You're right that this is related to #6717 (terminal hangs after successful command). Your finding about the cd /path && command form vs the cwd parameter causing the completion detection to fail is new and actionable information that we'll incorporate into the investigation.
We're keeping this linked to #6717 for tracking. The core fix needs to ensure terminal completion detection works regardless of how the command is structured (composite cd && form should be handled the same as using the cwd parameter).
Thank you for your feedback! 🙏
The duplicate label has been removed and this issue has been sent back for maintainer review.
A maintainer will review this issue shortly.
Thanks for reporting this. The subagent terminal lifecycle and event handling have received several fixes in recent versions. Could you retest on the latest version (IDE 1.0.242) and let us know whether subagent terminal commands still hang on completion?
To update: download from kiro.dev.
This issue has been automatically closed due to inactivity. It has been 7 days since we requested additional information.
If you still need help with this issue, please feel free to reopen it or create a new issue with the requested details.