Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit 088eac9

Browse files
authored
fix: opencode run crashing, and show errored tool calls in output (anomalyco#14206)
1 parent 5fe237a commit 088eac9

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

packages/opencode/src/cli/cmd/run.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,17 @@ function websearch(info: ToolProps<typeof WebSearchTool>) {
168168
}
169169

170170
function task(info: ToolProps<typeof TaskTool>) {
171-
const agent = Locale.titlecase(info.input.subagent_type)
172-
const desc = info.input.description
173-
const started = info.part.state.status === "running"
171+
const input = info.part.state.input
172+
const status = info.part.state.status
173+
const subagent =
174+
typeof input.subagent_type === "string" && input.subagent_type.trim().length > 0 ? input.subagent_type : "unknown"
175+
const agent = Locale.titlecase(subagent)
176+
const desc =
177+
typeof input.description === "string" && input.description.trim().length > 0 ? input.description : undefined
178+
const icon = status === "error" ? "✗" : status === "running" ? "•" : "✓"
174179
const name = desc ?? `${agent} Task`
175180
inline({
176-
icon: started ? "•" : "✓",
181+
icon,
177182
title: name,
178183
description: desc ? `${agent} Agent` : undefined,
179184
})
@@ -451,9 +456,17 @@ export const RunCommand = cmd({
451456
const part = event.properties.part
452457
if (part.sessionID !== sessionID) continue
453458

454-
if (part.type === "tool" && part.state.status === "completed") {
459+
if (part.type === "tool" && (part.state.status === "completed" || part.state.status === "error")) {
455460
if (emit("tool_use", { part })) continue
456-
tool(part)
461+
if (part.state.status === "completed") {
462+
tool(part)
463+
continue
464+
}
465+
inline({
466+
icon: "✗",
467+
title: `${part.tool} failed`,
468+
})
469+
UI.error(part.state.error)
457470
}
458471

459472
if (

packages/opencode/src/cli/ui.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export namespace UI {
104104
}
105105

106106
export function error(message: string) {
107+
if (message.startsWith("Error: ")) {
108+
message = message.slice("Error: ".length)
109+
}
107110
println(Style.TEXT_DANGER_BOLD + "Error: " + Style.TEXT_NORMAL + message)
108111
}
109112

0 commit comments

Comments
 (0)