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.
This commit is contained in:
wizardchen
2026-05-08 19:09:58 +08:00
committed by lyingbug
parent d48638427f
commit 576671e64a
@@ -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