fix(agent): harden @mention scope and simplify must_use hints
Tighten per-turn @MCP/@Skill/@tag handling after review: enforce agent MCP/Skill whitelist, ignore mentions when selection mode is none, tag-scope grep_chunks, and simplified English must_use lines without tool dumps. Skip persisting scope envelopes to history rendered_content.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestResolvePerRequestMCPScope_SelectedIntersection(t *testing.T) {
|
||||
effective, mode := resolvePerRequestMCPScope(
|
||||
[]string{"mcp-b", "mcp-c"},
|
||||
[]string{"mcp-a", "mcp-b"},
|
||||
"selected",
|
||||
false,
|
||||
)
|
||||
assert.Equal(t, "selected", mode)
|
||||
assert.Equal(t, []string{"mcp-b"}, effective)
|
||||
}
|
||||
|
||||
func TestResolvePerRequestMCPScope_SelectedRejectsOutsidePreset(t *testing.T) {
|
||||
effective, mode := resolvePerRequestMCPScope(
|
||||
[]string{"mcp-x"},
|
||||
[]string{"mcp-a"},
|
||||
"selected",
|
||||
false,
|
||||
)
|
||||
assert.Empty(t, effective)
|
||||
assert.Equal(t, "selected", mode)
|
||||
}
|
||||
|
||||
func TestResolvePerRequestMCPScope_NoneRejectsMention(t *testing.T) {
|
||||
effective, mode := resolvePerRequestMCPScope(
|
||||
[]string{"mcp-iwiki"},
|
||||
nil,
|
||||
"none",
|
||||
false,
|
||||
)
|
||||
assert.Empty(t, effective)
|
||||
assert.Equal(t, "none", mode)
|
||||
}
|
||||
|
||||
func TestResolvePerRequestMCPScope_SharedAgentBlocksOutsidePreset(t *testing.T) {
|
||||
effective, mode := resolvePerRequestMCPScope(
|
||||
[]string{"mcp-x"},
|
||||
[]string{"mcp-a"},
|
||||
"all",
|
||||
true,
|
||||
)
|
||||
assert.Empty(t, effective)
|
||||
assert.Equal(t, "all", mode)
|
||||
}
|
||||
|
||||
func TestResolvePerRequestMCPScope_SharedAgentAllowsPreset(t *testing.T) {
|
||||
effective, mode := resolvePerRequestMCPScope(
|
||||
[]string{"mcp-a", "mcp-x"},
|
||||
[]string{"mcp-a", "mcp-b"},
|
||||
"all",
|
||||
true,
|
||||
)
|
||||
assert.Equal(t, "selected", mode)
|
||||
assert.Equal(t, []string{"mcp-a"}, effective)
|
||||
}
|
||||
Reference in New Issue
Block a user