core: fix crash when message attachments array is undefined

Prevents runtime errors by ensuring undefined attachments are converted to an empty array before spreading into the message parts. This fixes scenarios where tool responses without attachments would cause the session processor to fail.
This commit is contained in:
Dax Raad 2026-04-27 16:46:19 -04:00
parent b46b09450a
commit f5abbfabbf

View file

@ -386,12 +386,12 @@ export const layer: Layer.Layer<
type: "text",
text: value.output.output,
},
...value.output.attachments?.map((item: MessageV2.FilePart) => ({
...(value.output.attachments?.map((item: MessageV2.FilePart) => ({
type: "file",
uri: item.url,
mime: item.mime,
name: item.filename,
})),
})) ?? []),
],
provider: {
executed: toolCall?.part.metadata?.providerExecuted === true,