mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-19 02:18:25 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user