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:
@@ -0,0 +1,37 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAgentHasKnowledgeScope_TagOnlySearchTargets(t *testing.T) {
|
||||
cfg := &types.AgentConfig{
|
||||
SearchTargets: types.SearchTargets{
|
||||
{
|
||||
Type: types.SearchTargetTypeKnowledgeBase,
|
||||
KnowledgeBaseID: "kb-1",
|
||||
TagIDs: []string{"tag-a"},
|
||||
},
|
||||
},
|
||||
}
|
||||
assert.True(t, agentHasKnowledgeScope(cfg))
|
||||
}
|
||||
|
||||
func TestAgentHasKnowledgeScope_Empty(t *testing.T) {
|
||||
assert.False(t, agentHasKnowledgeScope(&types.AgentConfig{}))
|
||||
assert.False(t, agentHasKnowledgeScope(nil))
|
||||
}
|
||||
|
||||
func TestKnowledgeBaseIDsForPrompt_FromSearchTargets(t *testing.T) {
|
||||
cfg := &types.AgentConfig{
|
||||
SearchTargets: types.SearchTargets{
|
||||
{KnowledgeBaseID: "kb-1", TagIDs: []string{"tag-a"}},
|
||||
{KnowledgeBaseID: "kb-1", TagIDs: []string{"tag-b"}},
|
||||
{KnowledgeBaseID: "kb-2", TagIDs: []string{"tag-c"}},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, []string{"kb-1", "kb-2"}, knowledgeBaseIDsForPrompt(cfg))
|
||||
}
|
||||
Reference in New Issue
Block a user