feat(agent): add intent prompt customization in agent editor

Allow per-intent system prompt overrides for non-retrieval intents in normal mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
helloandyzhang
2026-05-26 18:06:43 +08:00
committed by lyingbug
parent 09892ef763
commit e6a469631b
13 changed files with 322 additions and 29 deletions
@@ -187,8 +187,16 @@ func (p *PluginQueryUnderstand) OnEvent(ctx context.Context,
// --- Apply intent-specific system prompt override ---
if !chatManage.NeedsRetrieval() {
if prompt, ok := p.config.Conversation.IntentSystemPrompts[string(chatManage.Intent)]; ok {
chatManage.SystemPromptOverride = prompt
intentKey := string(chatManage.Intent)
if chatManage.IntentPromptOverrides != nil {
chatManage.SystemPromptOverride = strings.TrimSpace(chatManage.IntentPromptOverrides[intentKey])
}
if chatManage.SystemPromptOverride == "" {
if prompt, ok := p.config.Conversation.IntentSystemPrompts[intentKey]; ok {
chatManage.SystemPromptOverride = prompt
}
}
if chatManage.SystemPromptOverride != "" {
pipelineInfo(ctx, "QueryUnderstand", "prompt_override", map[string]interface{}{
"session_id": chatManage.SessionID,
"intent": chatManage.Intent,
@@ -210,6 +210,11 @@ func (s *sessionService) applyAgentOverridesToChatManage(
if cm.DataAnalysisEnabled {
logger.Infof(ctx, "Data analysis pipeline stage enabled by custom agent")
}
if len(customAgent.Config.IntentPrompts) > 0 {
cm.IntentPromptOverrides = customAgent.Config.IntentPrompts
logger.Infof(ctx, "Using custom agent's intent_prompts (%d overrides)", len(cm.IntentPromptOverrides))
}
}
// restrictMentionsToAgentScope filters user-provided @mention targets (KB IDs