From 088eac9d4eaba040e7e19084fd82cbb2e32ce6ed Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:13:01 -0600 Subject: [PATCH] fix: opencode run crashing, and show errored tool calls in output (#14206) --- packages/opencode/src/cli/cmd/run.ts | 25 +++++++++++++++++++------ packages/opencode/src/cli/ui.ts | 3 +++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/opencode/src/cli/cmd/run.ts b/packages/opencode/src/cli/cmd/run.ts index bf63eabf8..f3781f1ab 100644 --- a/packages/opencode/src/cli/cmd/run.ts +++ b/packages/opencode/src/cli/cmd/run.ts @@ -168,12 +168,17 @@ function websearch(info: ToolProps) { } function task(info: ToolProps) { - const agent = Locale.titlecase(info.input.subagent_type) - const desc = info.input.description - const started = info.part.state.status === "running" + const input = info.part.state.input + const status = info.part.state.status + const subagent = + typeof input.subagent_type === "string" && input.subagent_type.trim().length > 0 ? input.subagent_type : "unknown" + const agent = Locale.titlecase(subagent) + const desc = + typeof input.description === "string" && input.description.trim().length > 0 ? input.description : undefined + const icon = status === "error" ? "✗" : status === "running" ? "•" : "✓" const name = desc ?? `${agent} Task` inline({ - icon: started ? "•" : "✓", + icon, title: name, description: desc ? `${agent} Agent` : undefined, }) @@ -451,9 +456,17 @@ export const RunCommand = cmd({ const part = event.properties.part if (part.sessionID !== sessionID) continue - if (part.type === "tool" && part.state.status === "completed") { + if (part.type === "tool" && (part.state.status === "completed" || part.state.status === "error")) { if (emit("tool_use", { part })) continue - tool(part) + if (part.state.status === "completed") { + tool(part) + continue + } + inline({ + icon: "✗", + title: `${part.tool} failed`, + }) + UI.error(part.state.error) } if ( diff --git a/packages/opencode/src/cli/ui.ts b/packages/opencode/src/cli/ui.ts index 9df1f4ac5..f242a77f6 100644 --- a/packages/opencode/src/cli/ui.ts +++ b/packages/opencode/src/cli/ui.ts @@ -104,6 +104,9 @@ export namespace UI { } export function error(message: string) { + if (message.startsWith("Error: ")) { + message = message.slice("Error: ".length) + } println(Style.TEXT_DANGER_BOLD + "Error: " + Style.TEXT_NORMAL + message) }