diff --git a/packages/backend/server/src/plugins/copilot/session.ts b/packages/backend/server/src/plugins/copilot/session.ts index 604cffec5b..98482d88b4 100644 --- a/packages/backend/server/src/plugins/copilot/session.ts +++ b/packages/backend/server/src/plugins/copilot/session.ts @@ -149,7 +149,17 @@ export class ChatSession implements AsyncDisposable { normalizedParams, this.config.sessionId ); - finished[0].attachments = firstMessage.attachments; + + // attachments should be combined with the first user message + const firstUserMessage = + finished.find(m => m.role === 'user') || finished[0]; + firstUserMessage.attachments = [ + finished[0].attachments || [], + firstMessage.attachments || [], + ] + .flat() + .filter(v => !!v?.trim()); + return finished; }