feat(chat): add @Skill/@MCP mentions with scoped agent runtime

Wire per-turn @mentions for skills, MCP services, tags, and files through
QA handlers into agent config, runtime_context/must_use user blocks, and
tool registration. Fix tag-only scopes dropping KB tools, refresh suggested
questions on mention changes, and strengthen MCP must_use so @selected
services are invoked before local KB search.
This commit is contained in:
wizardchen
2026-06-29 16:01:58 +08:00
committed by lyingbug
parent 40f217c228
commit 049f85139d
44 changed files with 1814 additions and 378 deletions
+2 -1
View File
@@ -512,7 +512,7 @@ func (t *KnowledgeSearchTool) concurrentSearchByTargets(
var fullKBIDs []string
var knowledgeTargets []*types.SearchTarget
for _, st := range targets {
if st.Type == types.SearchTargetTypeKnowledgeBase {
if st.Type == types.SearchTargetTypeKnowledgeBase && len(st.TagIDs) == 0 {
fullKBIDs = append(fullKBIDs, st.KnowledgeBaseID)
} else {
knowledgeTargets = append(knowledgeTargets, st)
@@ -566,6 +566,7 @@ func (t *KnowledgeSearchTool) concurrentSearchByTargets(
VectorThreshold: vectorThreshold,
KeywordThreshold: keywordThreshold,
KnowledgeIDs: st.KnowledgeIDs,
TagIDs: st.TagIDs,
}
kbResults, err := t.knowledgeBaseService.HybridSearch(ctx, st.KnowledgeBaseID, searchParams)
if err != nil {
+25
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"sort"
"strings"
"time"
@@ -520,6 +521,30 @@ func RegisterMCPTools(
return nil
}
// MCPToolNamesByServiceID returns registered MCP tool names grouped by service ID.
func MCPToolNamesByServiceID(registry *ToolRegistry) map[string][]string {
if registry == nil {
return nil
}
out := make(map[string][]string)
for _, name := range registry.ListTools() {
tool, err := registry.GetTool(name)
if err != nil {
continue
}
mcpTool, ok := tool.(*MCPTool)
if !ok || mcpTool.service == nil {
continue
}
sid := mcpTool.service.ID
out[sid] = append(out[sid], name)
}
for sid := range out {
sort.Strings(out[sid])
}
return out
}
// GetMCPToolsInfo returns information about available MCP tools
func GetMCPToolsInfo(
ctx context.Context,