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
Revert "fix: preserve agent system prompt for greetings"
lyingbug4369d156e13b
diff --git a/internal/application/service/chat_pipeline/query_understand.go b/internal/application/service/chat_pipeline/query_understand.goindex 3b9ff1b02..f4022da2c 100644--- a/internal/application/service/chat_pipeline/query_understand.go+++ b/internal/application/service/chat_pipeline/query_understand.go@@ -470,18 +470,14 @@ func mergeImageDescAndOCR(desc, ocr string) (string, bool) {// applyIntentPromptOverride resolves the system-prompt override for the current// non-retrieval intent. Agent-level overrides take precedence; otherwise the-// tenant/global IntentSystemPrompts map is consulted. When a custom agent-// system prompt is already applied, global intent prompts must not replace it.-// Whitespace-only agent overrides are treated as unset. Returns true when a-// non-empty override was applied.+// tenant/global IntentSystemPrompts map is consulted. Whitespace-only agent+// overrides are treated as unset and fall through to the global default. Returns+// true when a non-empty override was applied.func applyIntentPromptOverride(chatManage *types.ChatManage, globalPrompts map[string]string) bool {intentKey := string(chatManage.Intent)if raw, ok := chatManage.IntentPromptOverrides[intentKey]; ok && strings.TrimSpace(raw) != "" {chatManage.SystemPromptOverride = raw}- if chatManage.AgentSystemPromptApplied {- return chatManage.SystemPromptOverride != ""- }if chatManage.SystemPromptOverride == "" {if prompt, ok := globalPrompts[intentKey]; ok {chatManage.SystemPromptOverride = promptdiff --git a/internal/application/service/chat_pipeline/query_understand_test.go b/internal/application/service/chat_pipeline/query_understand_test.goindex 61f97f668..e63a0a427 100644--- a/internal/application/service/chat_pipeline/query_understand_test.go+++ b/internal/application/service/chat_pipeline/query_understand_test.go@@ -59,23 +59,6 @@ func TestApplyIntentPromptOverride_BlankAgentFallsBackToGlobal(t *testing.T) {}}-func TestApplyIntentPromptOverride_CustomAgentSystemPromptSkipsGlobalFallback(t *testing.T) {- cm := &types.ChatManage{- PipelineRequest: types.PipelineRequest{- AgentSystemPromptApplied: true,- },- PipelineState: types.PipelineState{Intent: types.IntentGreeting},- }- global := map[string]string{"greeting": "global prompt"}-- if applyIntentPromptOverride(cm, global) {- t.Fatal("expected applied=false")- }- if cm.SystemPromptOverride != "" {- t.Errorf("override should remain empty, got %q", cm.SystemPromptOverride)- }-}-func TestApplyIntentPromptOverride_NoOverrideAndNoGlobal(t *testing.T) {cm := &types.ChatManage{PipelineState: types.PipelineState{Intent: types.IntentChitchat},diff --git a/internal/application/service/session_qa_helpers.go b/internal/application/service/session_qa_helpers.goindex 2d0b1a195..d75de4691 100644--- a/internal/application/service/session_qa_helpers.go+++ b/internal/application/service/session_qa_helpers.go@@ -117,7 +117,6 @@ func (s *sessionService) applyAgentOverridesToChatManage(// Override summary config fieldsif customAgent.Config.SystemPrompt != "" {cm.SummaryConfig.Prompt = customAgent.Config.SystemPrompt- cm.AgentSystemPromptApplied = truelogger.Infof(ctx, "Using custom agent's system_prompt")}if customAgent.Config.ContextTemplate != "" {diff --git a/internal/application/service/session_qa_helpers_test.go b/internal/application/service/session_qa_helpers_test.godeleted file mode 100644index f165022f7..000000000--- a/internal/application/service/session_qa_helpers_test.go+++ /dev/null@@ -1,25 +0,0 @@-package service--import (- "context"- "testing"-- "github.com/Tencent/WeKnora/internal/types"-)--func TestApplyAgentOverridesToChatManageMarksCustomSystemPrompt(t *testing.T) {- s := &sessionService{}- cm := &types.ChatManage{}- agent := &types.CustomAgent{- Config: types.CustomAgentConfig{SystemPrompt: "You are Xiaochi."},- }-- s.applyAgentOverridesToChatManage(context.Background(), agent, cm)-- if cm.SummaryConfig.Prompt != "You are Xiaochi." {- t.Errorf("prompt: got %q", cm.SummaryConfig.Prompt)- }- if !cm.AgentSystemPromptApplied {- t.Fatal("expected custom agent system prompt to be marked as applied")- }-}diff --git a/internal/types/chat_manage.go b/internal/types/chat_manage.goindex a00ede148..7b8c48209 100644--- a/internal/types/chat_manage.go+++ b/internal/types/chat_manage.go@@ -62,9 +62,6 @@ type PipelineRequest struct {// IntentPromptOverrides holds agent-level intent prompt overrides for the// query-understanding stage. Empty values fall back to tenant/global defaults.IntentPromptOverrides map[string]string `json:"-"`- // AgentSystemPromptApplied is true when SummaryConfig.Prompt was supplied- // by a custom agent. Global intent prompts must not replace that prompt.- AgentSystemPromptApplied bool `json:"-"`// Misc request-scoped configTenantID uint64 `json:"-"`@@ -229,7 +226,6 @@ func (c *ChatManage) Clone() *ChatManage {WebFetchTopN: c.WebFetchTopN,Language: c.Language,IntentPromptOverrides: maps.Clone(c.IntentPromptOverrides),- AgentSystemPromptApplied: c.AgentSystemPromptApplied,},PipelineState: PipelineState{RewriteQuery: c.RewriteQuery,