chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/agent/tools"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestBrowserSourcePromptFollowsExplicitTurnSelection(t *testing.T) {
|
||||
for _, custom := range []string{"", "Prefer knowledge-base search and Skills for research."} {
|
||||
engine := newTestEngine(t, &mockChat{})
|
||||
engine.systemPromptTemplate = custom
|
||||
require.NotContains(t, engine.buildSystemPrompt(t.Context()), "User-selected source for this turn")
|
||||
engine.config.LocalBrowserEnabled = true
|
||||
require.NotContains(
|
||||
t,
|
||||
engine.buildSystemPrompt(t.Context()),
|
||||
"User-selected source for this turn",
|
||||
"selection alone cannot advertise an unavailable tool",
|
||||
)
|
||||
engine.toolRegistry = tools.NewToolRegistry()
|
||||
engine.toolRegistry.RegisterTool(newCountingTool("local_browser"))
|
||||
prompt := engine.buildSystemPrompt(t.Context())
|
||||
require.Contains(t, prompt, "Use local_browser")
|
||||
require.Contains(t, prompt, "Other enabled tools remain available")
|
||||
require.Contains(t, prompt, "not merely permission to use it")
|
||||
require.NotContains(t, prompt, "tools are disabled")
|
||||
require.Contains(t, prompt, "Do not silently")
|
||||
engine.config.LocalBrowserEnabled = false
|
||||
engine.toolRegistry = tools.NewToolRegistry()
|
||||
require.NotContains(t, engine.buildSystemPrompt(t.Context()), "User-selected source for this turn")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user