From 3eff8b5c3a0118dab5227e4d1cffec21eef124dd Mon Sep 17 00:00:00 2001 From: mlogclub Date: Sat, 2 May 2026 14:51:39 +0800 Subject: [PATCH] fix: simplify fallback reply handling in knowledge guard --- internal/ai/runtime/executor/knowledge_guard.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/ai/runtime/executor/knowledge_guard.go b/internal/ai/runtime/executor/knowledge_guard.go index 9c83de7..47140b6 100644 --- a/internal/ai/runtime/executor/knowledge_guard.go +++ b/internal/ai/runtime/executor/knowledge_guard.go @@ -8,6 +8,7 @@ import ( "cs-agent/internal/pkg/enums" "github.com/cloudwego/eino/schema" + "github.com/mlogclub/simple/common/strs" ) type knowledgeGuardDecision struct { @@ -53,14 +54,10 @@ func resolveKnowledgeFallbackReply(aiAgent models.AIAgent) string { func resolveKnowledgeHumanSupportFallback(aiAgent models.AIAgent) string { base := strings.TrimSpace(resolveKnowledgeFallbackReply(aiAgent)) - if base == "" { + if strs.IsBlank(base) { base = "当前知识库暂无明确信息。" } - suggestion := "建议你联系人工客服进一步确认。" - if strings.Contains(base, suggestion) { - return base - } - return strings.TrimSpace(base + " " + suggestion) + return base } func buildKnowledgeRuntimeInstruction(answerMode enums.KnowledgeAnswerMode, fallbackReply string) string {