From 125e0a059b77950c6a550f339f1b0675620eeb7c Mon Sep 17 00:00:00 2001 From: sangyinghao Date: Fri, 13 Feb 2026 12:02:43 +0800 Subject: [PATCH] fix(opencode): propagate subagent errors to parent session When a subagent's LLM call fails (e.g. invalid model ID), the error was logged but never returned to the parent agent. The parent session would hang indefinitely waiting for a response that would never come. Now the task tool checks the subagent's assistant message for errors after prompt() returns and throws so the parent receives a proper failed tool result. Closes #13395 --- packages/opencode/src/tool/task.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/opencode/src/tool/task.ts b/packages/opencode/src/tool/task.ts index 8c8cf827aba..51922ec1e0c 100644 --- a/packages/opencode/src/tool/task.ts +++ b/packages/opencode/src/tool/task.ts @@ -142,6 +142,9 @@ export const TaskTool = Tool.define("task", async (ctx) => { parts: promptParts, }) + if (result.info.role === "assistant" && result.info.error) + throw new Error(`Subagent error: ${result.info.error.data.message}`) + const text = result.parts.findLast((x) => x.type === "text")?.text ?? "" const output = [