fix: opencode run crashing, and show errored tool calls in output (#14206)

This commit is contained in:
Aiden Cline
2026-02-18 17:13:01 -06:00
committed by GitHub
parent 5fe237a3fd
commit 088eac9d4e
2 changed files with 22 additions and 6 deletions

View File

@@ -168,12 +168,17 @@ function websearch(info: ToolProps<typeof WebSearchTool>) {
} }
function task(info: ToolProps<typeof TaskTool>) { function task(info: ToolProps<typeof TaskTool>) {
const agent = Locale.titlecase(info.input.subagent_type) const input = info.part.state.input
const desc = info.input.description const status = info.part.state.status
const started = info.part.state.status === "running" 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` const name = desc ?? `${agent} Task`
inline({ inline({
icon: started ? "•" : "✓", icon,
title: name, title: name,
description: desc ? `${agent} Agent` : undefined, description: desc ? `${agent} Agent` : undefined,
}) })
@@ -451,9 +456,17 @@ export const RunCommand = cmd({
const part = event.properties.part const part = event.properties.part
if (part.sessionID !== sessionID) continue 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 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 ( if (

View File

@@ -104,6 +104,9 @@ export namespace UI {
} }
export function error(message: string) { export function error(message: string) {
if (message.startsWith("Error: ")) {
message = message.slice("Error: ".length)
}
println(Style.TEXT_DANGER_BOLD + "Error: " + Style.TEXT_NORMAL + message) println(Style.TEXT_DANGER_BOLD + "Error: " + Style.TEXT_NORMAL + message)
} }