mini: fix shell tool output display (#37711)

This commit is contained in:
Simon Klee 2026-07-19 09:31:38 +02:00 committed by GitHub
commit cf6e5b3604
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 10 deletions

View file

@ -177,6 +177,12 @@ function text(v: unknown): string {
return typeof v === "string" ? v : ""
}
export function toolOutputText(name: string, content: ReadonlyArray<{ type: string; text?: string }>) {
// V2 shell content appends model-only status after the user-visible command output.
if (name === "shell") return content.find((item) => item.type === "text")?.text ?? ""
return content.flatMap((item) => (item.type === "text" && item.text ? [item.text] : [])).join("\n")
}
function num(v: unknown): number | undefined {
if (typeof v !== "number" || !Number.isFinite(v)) {
return undefined