Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Refine agent tool confirmation handling

Daniel428e0d29b603
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index b9ffb7dd80..be23c8abb9 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -488,7 +488,7 @@
"agentExample1": "البحث عن ملاحظات الاجتماعات الأخيرة",
"agentExample2": "إنشاء مذكرة يومية جديدة",
"agentExample3": "البحث عن ملاحظات متعلقة بالمشروع",
- "agentConfirmDesc": "عملية تغيير <em>{category}</em>",
+ "agentConfirmDesc": "سينفذ الوكيل عملية <em>{category}</em>",
"agentCatBlock": "كتلة",
"agentCatDoc": "مستند",
"agentCatNotebook": "دفتر",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 1a803690a5..7790120c87 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -488,7 +488,7 @@
"agentExample1": "Durchsuche meine letzten Besprechungsnotizen",
"agentExample2": "Erstelle ein neues Tagebuch",
"agentExample3": "Finde Notizen zum Projekt",
- "agentConfirmDesc": "Änderungsvorgang <em>{category}</em>",
+ "agentConfirmDesc": "Der Agent führt einen Vorgang vom Typ <em>{category}</em> aus",
"agentCatBlock": "Block",
"agentCatDoc": "Dokument",
"agentCatNotebook": "Notizbuch",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 9aebb752b4..9938464ac7 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -488,7 +488,7 @@
"agentExample1": "Search my recent meeting notes",
"agentExample2": "Create a new daily journal",
"agentExample3": "Find notes related to the project",
- "agentConfirmDesc": "<em>{category}</em> change operation",
+ "agentConfirmDesc": "The agent will execute a <em>{category}</em> operation",
"agentCatBlock": "block",
"agentCatDoc": "document",
"agentCatNotebook": "notebook",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 3a23d0249e..15ed6975db 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -488,7 +488,7 @@
"agentExample1": "Buscar mis notas de reuniones recientes",
"agentExample2": "Crear un nuevo diario",
"agentExample3": "Buscar notas del proyecto",
- "agentConfirmDesc": "Operación de cambio <em>{category}</em>",
+ "agentConfirmDesc": "El agente ejecutará una operación de tipo <em>{category}</em>",
"agentCatBlock": "bloque",
"agentCatDoc": "documento",
"agentCatNotebook": "libreta",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 5d14843aaf..b8840431e7 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -488,7 +488,7 @@
"agentExample1": "Rechercher mes notes de réunion récentes",
"agentExample2": "Créer un nouveau journal",
"agentExample3": "Rechercher des notes sur le projet",
- "agentConfirmDesc": "Opération de modification <em>{category}</em>",
+ "agentConfirmDesc": "L’agent va exécuter une opération de type <em>{category}</em>",
"agentCatBlock": "bloc",
"agentCatDoc": "document",
"agentCatNotebook": "carnet",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 8da0f3d690..ad94f0c42c 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -488,7 +488,7 @@
"agentExample1": "חפש את הערות הפגישות האחרונות שלי",
"agentExample2": "צור יומן חדש",
"agentExample3": "מצא הערות הקשורות לפרויקט",
- "agentConfirmDesc": "פעולת שינוי <em>{category}</em>",
+ "agentConfirmDesc": "הסוכן יבצע פעולה מסוג <em>{category}</em>",
"agentCatBlock": "בלוק",
"agentCatDoc": "מסמך",
"agentCatNotebook": "מחברת",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 90c79af9aa..e78208bcce 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -488,7 +488,7 @@
"agentExample1": "मेरी हाल की बैठक के नोट्स खोजें",
"agentExample2": "एक नई डायरी बनाएं",
"agentExample3": "परियोजना से संबंधित नोट्स खोजें",
- "agentConfirmDesc": "एजेंट <em>{category}</em> परिवर्तन संचालन निष्पादित करेगा",
+ "agentConfirmDesc": "एजेंट <em>{category}</em> कार्रवाई निष्पादित करेगा",
"agentCatBlock": "ब्लॉक",
"agentCatDoc": "दस्तावेज़",
"agentCatNotebook": "नोटबुक",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 4501bf60d6..5fbc7237e0 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -488,7 +488,7 @@
"agentExample1": "Cari catatan rapat terbaru saya",
"agentExample2": "Buat jurnal harian baru",
"agentExample3": "Temukan catatan terkait proyek",
- "agentConfirmDesc": "Agen akan melakukan operasi perubahan <em>{category}</em>",
+ "agentConfirmDesc": "Agen akan menjalankan operasi <em>{category}</em>",
"agentCatBlock": "blok",
"agentCatDoc": "dokumen",
"agentCatNotebook": "buku catatan",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index aee863aa7b..8963b5d511 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -488,7 +488,7 @@
"agentExample1": "Cerca i miei appunti delle riunioni recenti",
"agentExample2": "Crea un nuovo diario",
"agentExample3": "Trova appunti sul progetto",
- "agentConfirmDesc": "Operazione di modifica <em>{category}</em>",
+ "agentConfirmDesc": "L’agente eseguirà un’operazione di tipo <em>{category}</em>",
"agentCatBlock": "blocco",
"agentCatDoc": "documento",
"agentCatNotebook": "taccuino",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index d6b42bd88d..d66f8e9014 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -488,7 +488,7 @@
"agentExample1": "最近の会議メモを検索",
"agentExample2": "新しい日記を作成",
"agentExample3": "プロジェクト関連のノートを検索",
- "agentConfirmDesc": "<em>{category}</em>変更操作を実行します",
+ "agentConfirmDesc": "<em>{category}</em>操作を実行します",
"agentCatBlock": "ブロック",
"agentCatDoc": "ドキュメント",
"agentCatNotebook": "ノートブック",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index 436466e3b0..7acc998f0f 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -488,7 +488,7 @@
"agentExample1": "최근 회의록 검색",
"agentExample2": "새 일기 작성",
"agentExample3": "프로젝트 관련 노트 찾기",
- "agentConfirmDesc": "<em>{category}</em> 변경 작업을 실행합니다",
+ "agentConfirmDesc": "<em>{category}</em> 작업을 실행합니다",
"agentCatBlock": "블록",
"agentCatDoc": "문서",
"agentCatNotebook": "노트북",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 6ec2d4e9a5..a0622d879e 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -488,7 +488,7 @@
"agentExample1": "Doorzoek mijn recente vergadernotities",
"agentExample2": "Maak een nieuw dagboek",
"agentExample3": "Vind notities over het project",
- "agentConfirmDesc": "Wijzigingsoperatie <em>{category}</em>",
+ "agentConfirmDesc": "De agent voert een bewerking van het type <em>{category}</em> uit",
"agentCatBlock": "blok",
"agentCatDoc": "Document",
"agentCatNotebook": "notitieboek",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 30b26051ed..812de6e76f 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -488,7 +488,7 @@
"agentExample1": "Wyszukaj moje ostatnie notatki ze spotkań",
"agentExample2": "Utwórz nowy dziennik",
"agentExample3": "Znajdź notatki związane z projektem",
- "agentConfirmDesc": "Operacja zmiany <em>{category}</em>",
+ "agentConfirmDesc": "Agent wykona operację typu <em>{category}</em>",
"agentCatBlock": "blok",
"agentCatDoc": "dokument",
"agentCatNotebook": "notatnik",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 51891688a4..7e6f525613 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -488,7 +488,7 @@
"agentExample1": "Pesquisar minhas anotações de reuniões recentes",
"agentExample2": "Criar um novo diário",
"agentExample3": "Encontrar notas do projeto",
- "agentConfirmDesc": "Operação de alteração <em>{category}</em>",
+ "agentConfirmDesc": "O agente executará uma operação do tipo <em>{category}</em>",
"agentCatBlock": "bloco",
"agentCatDoc": "documento",
"agentCatNotebook": "caderno",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 93aa6f5039..cbb60a584c 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -488,7 +488,7 @@
"agentExample1": "Найти мои недавние заметки о встречах",
"agentExample2": "Создать новый дневник",
"agentExample3": "Найти заметки по проекту",
- "agentConfirmDesc": "Операция изменения <em>{category}</em>",
+ "agentConfirmDesc": "Агент выполнит операцию типа <em>{category}</em>",
"agentCatBlock": "блок",
"agentCatDoc": "документ",
"agentCatNotebook": "блокнот",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index 7f0354a811..9127caa544 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -488,7 +488,7 @@
"agentExample1": "Vyhľadať moje nedávne poznámky zo stretnutí",
"agentExample2": "Vytvoriť nový denník",
"agentExample3": "Nájsť poznámky k projektu",
- "agentConfirmDesc": "Operácia zmeny <em>{category}</em>",
+ "agentConfirmDesc": "Agent vykoná operáciu typu <em>{category}</em>",
"agentCatBlock": "blok",
"agentCatDoc": "dokument",
"agentCatNotebook": "poznámkový blok",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index e59fd6f303..7cdb0e3291 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -488,7 +488,7 @@
"agentExample1": "ค้นหาบันทึกการประชุมล่าสุดของฉัน",
"agentExample2": "สร้างบันทึกประจำวันใหม่",
"agentExample3": "ค้นหาบันทึกที่เกี่ยวข้องกับโครงการ",
- "agentConfirmDesc": "การดำเนินการเปลี่ยนแปลง <em>{category}</em>",
+ "agentConfirmDesc": "เอเจนต์จะดำเนินการประเภท <em>{category}</em>",
"agentCatBlock": "บล็อก",
"agentCatDoc": "เอกสาร",
"agentCatNotebook": "สมุดบันทึก",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index 3a37e7f6a2..2398c5e727 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -488,7 +488,7 @@
"agentExample1": "Son toplantı notlarımı ara",
"agentExample2": "Yeni bir günlük oluştur",
"agentExample3": "Projeyle ilgili notları bul",
- "agentConfirmDesc": "<em>{category}</em> değişiklik işlemi",
+ "agentConfirmDesc": "Ajan <em>{category}</em> işlemini gerçekleştirecek",
"agentCatBlock": "blok",
"agentCatDoc": "belge",
"agentCatNotebook": "defter",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 8f4d65a36e..13a1fc6612 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -488,7 +488,7 @@
"agentExample1": "Знайти мої нещодавні нотатки про зустрічі",
"agentExample2": "Створити новий щоденник",
"agentExample3": "Знайти нотатки про проєкт",
- "agentConfirmDesc": "Операція зміни <em>{category}</em>",
+ "agentConfirmDesc": "Агент виконає операцію типу <em>{category}</em>",
"agentCatBlock": "блок",
"agentCatDoc": "документ",
"agentCatNotebook": "блокнот",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index cd4f8bc1ea..f356c5f099 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -488,7 +488,7 @@
"agentExample1": "搜索最近的会议记录",
"agentExample2": "帮我写一篇日记",
"agentExample3": "整理一下项目相关的笔记",
- "agentConfirmDesc": "智能体将执行<em>{category}</em>变更操作",
+ "agentConfirmDesc": "智能体将执行<em>{category}</em>操作",
"agentCatBlock": "内容块",
"agentCatDoc": "文档",
"agentCatNotebook": "笔记本",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index cd6b502fb5..96f55ee2ff 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -488,7 +488,7 @@
"agentExample1": "搜尋最近的會議記錄",
"agentExample2": "幫我寫一篇日記",
"agentExample3": "整理一下项目相关的笔记",
- "agentConfirmDesc": "智能體將執行<em>{category}</em>變更操作",
+ "agentConfirmDesc": "智能體將執行<em>{category}</em>操作",
"agentCatBlock": "內容區塊",
"agentCatDoc": "文檔",
"agentCatNotebook": "筆記本",
diff --git a/app/src/layout/dock/agent/AgentChat.ts b/app/src/layout/dock/agent/AgentChat.ts
index ebe76acb85..b9d178561b 100644
--- a/app/src/layout/dock/agent/AgentChat.ts
+++ b/app/src/layout/dock/agent/AgentChat.ts
@@ -3926,7 +3926,7 @@ export class AgentChat extends Model {
"repo": L.agentCatRepo, "history": L.agentCatHistory,
"sync": L.agentCatSync, "database": L.agentCatDatabase,
};
- return m[name] || L.agentCatDefault;
+ return m[name] || name || L.agentCatDefault;
}
private formatMessageTime(ts: number): string {
diff --git a/kernel/agent/agent.go b/kernel/agent/agent.go
index 0b01d897a5..f77259d1bc 100644
--- a/kernel/agent/agent.go
+++ b/kernel/agent/agent.go
@@ -1340,6 +1340,15 @@ var safeWholeTools = map[string]bool{
"search": true, "sql": true,
}
+var safeNativeToolActions = map[string]map[string]bool{
+ "export": {
+ "html": true, "preview": true,
+ },
+ "frontend": {
+ "open_setting": true, "focus_block": true, "open_document": true, "open_search": true,
+ },
+}
+
func needsConfirm(toolName string, action string, alwaysAllow map[string]bool) bool {
if alwaysAllow["*"] {
return false
@@ -1356,6 +1365,9 @@ func needsConfirm(toolName string, action string, alwaysAllow map[string]bool) b
// 可能在外部服务中产生写入。仅工具明确声明只读时免确认,未知能力按写操作处理。
return !tool.ReadOnlyHint
}
+ if safeNativeToolActions[toolName][action] {
+ return false
+ }
if toolName == "http_request" && action == "" {
action = "get"
}
@@ -1385,6 +1397,9 @@ func needsLocalSnapshot(toolName, action string) bool {
if toolName == "http_request" && action == "" {
action = "get"
}
+ if safeNativeToolActions[toolName][action] {
+ return false
+ }
actionSafe := safeActions[action]
if toolName == "import" && action == "md" {
actionSafe = false
diff --git a/kernel/agent/tools_test.go b/kernel/agent/tools_test.go
index 076164abfa..09486321b2 100644
--- a/kernel/agent/tools_test.go
+++ b/kernel/agent/tools_test.go
@@ -291,6 +291,25 @@ func TestQueryToolActionEffects(t *testing.T) {
}
}
+func TestNativeReadOnlyToolActions(t *testing.T) {
+ for _, action := range []string{"open_setting", "focus_block", "open_document", "open_search"} {
+ if needsConfirm("frontend", action, nil) || needsLocalSnapshot("frontend", action) {
+ t.Errorf("built-in frontend action %q must not require confirmation or create a snapshot", action)
+ }
+ }
+ if !needsConfirm("frontend", "plugin__example__write", nil) {
+ t.Fatal("plugin frontend actions with unknown effects must require confirmation")
+ }
+ for _, action := range []string{"html", "preview"} {
+ if needsConfirm("export", action, nil) || needsLocalSnapshot("export", action) {
+ t.Errorf("read-only export action %q must not require confirmation or create a snapshot", action)
+ }
+ }
+ if !needsConfirm("export", "docx", nil) || !needsLocalSnapshot("export", "docx") {
+ t.Fatal("file-producing export actions must retain confirmation and snapshot protection")
+ }
+}
+
func TestConfirmSessionAcceptsResponseOnce(t *testing.T) {
const confirmID = "test-confirm"
ch := make(chan confirmResult, 1)