[PR #13422] fix(opencode): propagate subagent errors to parent session #14660

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

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

State: open
Merged: No


What does this PR do?

Fixes #13395

When a subagent's LLM call fails (e.g. bad model ID → AI_APICallError), the error gets logged but SessionPrompt.prompt() still returns normally with the error stashed on the assistant message. The task tool in task.ts only looks at text parts from the result, so it returns an empty <task_result> to the parent — which then hangs waiting for useful output that'll never come.

Added a check after prompt() returns: if the assistant message has an error, throw it so the parent gets a proper failed tool result and can report or recover.

How did you verify your code works?

Traced the full call chain from TaskTool.executeSessionPrompt.promptloopSessionProcessor.process to confirm the error path. The processor catches LLM errors and sets assistantMessage.error but doesn't throw, so prompt() returns normally. bun typecheck and bun turbo test (936 tests) pass clean.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13422 **State:** open **Merged:** No --- ### What does this PR do? Fixes #13395 When a subagent's LLM call fails (e.g. bad model ID → `AI_APICallError`), the error gets logged but `SessionPrompt.prompt()` still returns normally with the error stashed on the assistant message. The task tool in `task.ts` only looks at text parts from the result, so it returns an empty `<task_result>` to the parent — which then hangs waiting for useful output that'll never come. Added a check after `prompt()` returns: if the assistant message has an error, throw it so the parent gets a proper failed tool result and can report or recover. ### How did you verify your code works? Traced the full call chain from `TaskTool.execute` → `SessionPrompt.prompt` → `loop` → `SessionProcessor.process` to confirm the error path. The processor catches LLM errors and sets `assistantMessage.error` but doesn't throw, so `prompt()` returns normally. `bun typecheck` and `bun turbo test` (936 tests) pass clean.
yindo added the pull-request label 2026-02-16 18:19:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14660