An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Refine read-only agent query effects https://github.com/siyuan-note/siyuan/issues/18256
Daniel92672e05a679
diff --git a/kernel/agent/agent.go b/kernel/agent/agent.goindex 449d38f6db..06e90049f9 100644--- a/kernel/agent/agent.go+++ b/kernel/agent/agent.go@@ -1075,6 +1075,7 @@ var safeActions = map[string]bool{var safeWholeTools = map[string]bool{"question": true, "todo_write": true, "web_fetch": true, "web_search": true,+ "search": true, "sql": true,}func needsConfirm(toolName string, action string, alwaysAllow map[string]bool) bool {@@ -1096,8 +1097,11 @@ func needsConfirm(toolName string, action string, alwaysAllow map[string]bool) bif toolName == "http_request" && action == "" {action = "get"}+ if safeWholeTools[toolName] {+ return false+ }if action == "" {- return !safeWholeTools[toolName]+ return true}if toolName == "import" && action == "md" {return truediff --git a/kernel/agent/tools_test.go b/kernel/agent/tools_test.goindex ae1195b300..7b926efa9f 100644--- a/kernel/agent/tools_test.go+++ b/kernel/agent/tools_test.go@@ -162,19 +162,23 @@ func TestImageToolActionEffects(t *testing.T) {func TestQueryToolActionEffects(t *testing.T) {tests := []struct {- toolName string- action string+ toolName string+ action string+ needsConfirm bool}{{toolName: "sql", action: "query"},{toolName: "sql", action: ""},+ {toolName: "sql", action: "select"},{toolName: "search", action: "fulltext"},- {toolName: "search", action: "semantic"},+ {toolName: "search", action: "semantic", needsConfirm: true},{toolName: "search", action: "asset"},{toolName: "search", action: "getasset"},+ {toolName: "search", action: "unknown"},}for _, test := range tests {- if needsConfirm(test.toolName, test.action, nil) {- t.Errorf("read-only action %s::%s must not require confirmation", test.toolName, test.action)+ if actual := needsConfirm(test.toolName, test.action, nil); actual != test.needsConfirm {+ t.Errorf("unexpected confirmation decision for %s::%s: got %t, want %t",+ test.toolName, test.action, actual, test.needsConfirm)}if needsLocalSnapshot(test.toolName, test.action) {t.Errorf("read-only action %s::%s must not create a local snapshot", test.toolName, test.action)diff --git a/kernel/mcp/tools/search.go b/kernel/mcp/tools/search.goindex bed2321e32..74f901c45a 100644--- a/kernel/mcp/tools/search.go+++ b/kernel/mcp/tools/search.go@@ -47,7 +47,7 @@ var SearchTool = &Tool{EffectScope: EffectScopeLocal,ActionEffects: map[string]ToolEffects{"fulltext": {LocalRead: true},- "semantic": {LocalRead: true},+ "semantic": {LocalRead: true, DataEgress: true, ExternalCost: true},"asset": {LocalRead: true},"getasset": {LocalRead: true},},