[PR #13321] fix: robust subagent completion propagation #14612

Open
opened 2026-02-16 18:19:23 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13321

State: open
Merged: No


Summary

Fixes parent session hanging indefinitely when a subagent (Task tool) completes but SessionPrompt.prompt() never resolves. Fixes #9003, #10802, #11865, #6792.

Three targeted changes:

  1. await the prune() call (prompt.ts:653) — was fire-and-forget, racing with the immediately following MessageV2.stream() reads.
  2. Diagnostic logging (prompt.ts:305-312) — the loop exit condition silently continued when assistant finished but user message ID was newer. Now logs a warning so this case is visible.
  3. Event-driven recovery (task.ts) — subscribe to child MessageV2.Event.Updated; if the child reaches a terminal state (finish or error) but the prompt doesn't resolve within 3s, force-cancel to unblock the parent. Not a timeout — only fires with positive proof of completion.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13321 **State:** open **Merged:** No --- ## Summary Fixes parent session hanging indefinitely when a subagent (Task tool) completes but `SessionPrompt.prompt()` never resolves. Fixes #9003, #10802, #11865, #6792. Three targeted changes: 1. **`await` the `prune()` call** (`prompt.ts:653`) — was fire-and-forget, racing with the immediately following `MessageV2.stream()` reads. 2. **Diagnostic logging** (`prompt.ts:305-312`) — the loop exit condition silently continued when assistant finished but user message ID was newer. Now logs a warning so this case is visible. 3. **Event-driven recovery** (`task.ts`) — subscribe to child `MessageV2.Event.Updated`; if the child reaches a terminal state (finish or error) but the prompt doesn't resolve within 3s, force-cancel to unblock the parent. Not a timeout — only fires with positive proof of completion.
yindo added the pull-request label 2026-02-16 18:19:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14612