This commit is contained in:
Aiden Cline
2026-01-16 10:52:58 -06:00
parent 232e531091
commit 5385995398
2 changed files with 9 additions and 3 deletions

View File

@@ -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,
})

View File

@@ -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",