049f85139d
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.
38 lines
1010 B
Go
38 lines
1010 B
Go
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))
|
|
}
|