Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat(agent): improve content filtering in streaming event handling
wizardchenb9dde2abe82c
diff --git a/internal/agent/think.go b/internal/agent/think.goindex f82446e02..a0cd114bd 100644--- a/internal/agent/think.go+++ b/internal/agent/think.go@@ -3,6 +3,7 @@ package agentimport ("context""fmt"+ "strings""time"agenttools "github.com/Tencent/WeKnora/internal/agent/tools"@@ -177,6 +178,16 @@ func (e *AgentEngine) streamThinkingToEventBus(if content == "" {return}+ // Suppress whitespace-only content emitted before the real answer has+ // started. OpenAI-compatible models frequently prepend a stray newline+ // (e.g. "\n\n") to the plain content channel in the same chunk where+ // they request tool calls. Routing that to the final-answer area leaks+ // spurious empty "answer" events interleaved with tool_call events.+ // Once genuine answer text has streamed (answerStreamed), preserve all+ // whitespace so the answer's own formatting stays intact.+ if !answerStreamed && strings.TrimSpace(content) == "" {+ return+ }closeThinking()answerStreamed = trueemittedEventTypes["final_answer_chunk"]++