Skip to content

Commit 1e21d04

Browse files
committed
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.
1 parent 1317849 commit 1e21d04

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/opencode/src/session/processor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ export const layer: Layer.Layer<
386386
type: "text",
387387
text: value.output.output,
388388
},
389-
...value.output.attachments?.map((item: MessageV2.FilePart) => ({
389+
...(value.output.attachments?.map((item: MessageV2.FilePart) => ({
390390
type: "file",
391391
uri: item.url,
392392
mime: item.mime,
393393
name: item.filename,
394-
})),
394+
})) ?? []),
395395
],
396396
provider: {
397397
executed: toolCall?.part.metadata?.providerExecuted === true,

0 commit comments

Comments
 (0)