From 5385995398957da31009b97c84835789938261f5 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Fri, 16 Jan 2026 10:52:58 -0600 Subject: [PATCH] fix test --- packages/opencode/src/session/message-v2.ts | 4 +++- packages/opencode/src/session/prompt.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/session/message-v2.ts b/packages/opencode/src/session/message-v2.ts index 8622a6a166..c9afb4906e 100644 --- a/packages/opencode/src/session/message-v2.ts +++ b/packages/opencode/src/session/message-v2.ts @@ -515,8 +515,10 @@ export namespace MessageV2 { state: "output-available", toolCallId: part.callID, input: part.state.input, + // For compacted results, use plain string so SDK serializes as text type + // For normal results, pass object so toModelOutput can convert attachments to media parts output: part.state.time.compacted - ? { output: "[Old tool result content cleared]", attachments: undefined } + ? "[Old tool result content cleared]" : { output: part.state.output, attachments: part.state.attachments }, callProviderMetadata: part.metadata, }) diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts index 663f5660f1..2b49561e66 100644 --- a/packages/opencode/src/session/prompt.ts +++ b/packages/opencode/src/session/prompt.ts @@ -716,7 +716,9 @@ export namespace SessionPrompt { ) return result }, - toModelOutput(result: { output: string; attachments?: MessageV2.FilePart[] }) { + toModelOutput(result: string | { output: string; attachments?: MessageV2.FilePart[] }) { + // Handle compacted results (plain string) + if (typeof result === "string") return { type: "text", value: result } if (!result.attachments?.length) return { type: "text", value: result.output } return { type: "content", @@ -814,7 +816,9 @@ export namespace SessionPrompt { content: result.content, // directly return content to preserve ordering when outputting to model } } - item.toModelOutput = (result: { output: string; attachments?: MessageV2.FilePart[] }) => { + item.toModelOutput = (result: string | { output: string; attachments?: MessageV2.FilePart[] }) => { + // Handle compacted results (plain string) + if (typeof result === "string") return { type: "text", value: result } if (!result.attachments?.length) return { type: "text", value: result.output } return { type: "content",