From 576671e64a6c12bce8038e47df2bb3f74de308ad Mon Sep 17 00:00:00 2001 From: wizardchen Date: Fri, 8 May 2026 19:06:13 +0800 Subject: [PATCH] fix: propagate user attachments to agent query in AgentQA Attachments uploaded from the UI were correctly parsed by the handler and set on QARequest.Attachments, but the Agent path dropped them before calling engine.Execute. Only the KnowledgeQA pipeline injected them via Attachments.BuildPrompt(), so in "smart reasoning" (Agent) mode the model never saw the uploaded file and answered as if no attachment existed. Append Attachments.BuildPrompt() to agentQuery alongside QuotedContext, mirroring chat_pipeline/into_chat_message.go. This keeps the engine signature unchanged and matches the existing KnowledgeQA behavior. --- internal/application/service/session_agent_qa.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/application/service/session_agent_qa.go b/internal/application/service/session_agent_qa.go index 4e8592aa5..6bdbf4f37 100644 --- a/internal/application/service/session_agent_qa.go +++ b/internal/application/service/session_agent_qa.go @@ -184,6 +184,13 @@ func (s *sessionService) AgentQA( if req.QuotedContext != "" { agentQuery += "\n\n" + req.QuotedContext } + // Inject attachment content (documents, audio transcripts, etc.) so the agent + // can see uploaded files. Mirrors the behavior of the KnowledgeQA pipeline + // (see chat_pipeline/into_chat_message.go). + if len(req.Attachments) > 0 { + agentQuery += req.Attachments.BuildPrompt() + logger.Infof(ctx, "Appended %d attachment(s) to agent query", len(req.Attachments)) + } // Execute agent with streaming (asynchronously) // Events will be emitted to EventBus and handled by the Handler layer