From 3226a0a3fe3977b33cece06ac356e45f5a46dab1 Mon Sep 17 00:00:00 2001 From: Wu Yue Date: Tue, 8 Jul 2025 17:46:13 +0800 Subject: [PATCH] fix(core): ai tool calling explanation (#13097) Close [AI-293](https://linear.app/affine-design/issue/AI-293) ## Summary by CodeRabbit * **New Features** * Tool call cards for website reading now display the specific URL being accessed. * Tool call cards for web searches now display the search query being used. * **Style** * Updated tool call instructions to prevent explanations of operations before execution. --- .../backend/server/src/plugins/copilot/prompt/prompts.ts | 1 + .../core/src/blocksuite/ai/components/ai-tools/web-crawl.ts | 2 +- .../src/blocksuite/ai/components/ai-tools/web-search.ts | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/backend/server/src/plugins/copilot/prompt/prompts.ts b/packages/backend/server/src/plugins/copilot/prompt/prompts.ts index 7607aaff3b..debf812c4b 100644 --- a/packages/backend/server/src/plugins/copilot/prompt/prompts.ts +++ b/packages/backend/server/src/plugins/copilot/prompt/prompts.ts @@ -1675,6 +1675,7 @@ This sentence contains information from the first source[^1]. This sentence refe Before starting Tool calling, you need to follow: +- DO NOT explain what operation you will perform. - DO NOT embed a tool call mid-sentence. - When searching for unknown information or keyword, prioritize searching the user's workspace. - Depending on the complexity of the question and the information returned by the search tools, you can call different tools multiple times to search. diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-crawl.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-crawl.ts index f75960e8a1..93e62d5318 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-crawl.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-crawl.ts @@ -46,7 +46,7 @@ export class WebCrawlTool extends WithDisposable(ShadowlessElement) { renderToolCall() { return html` `; diff --git a/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-search.ts b/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-search.ts index 7307cff202..184f768b90 100644 --- a/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-search.ts +++ b/packages/frontend/core/src/blocksuite/ai/components/ai-tools/web-search.ts @@ -12,14 +12,14 @@ interface WebSearchToolCall { type: 'tool-call'; toolCallId: string; toolName: string; - args: { url: string }; + args: { query: string }; } interface WebSearchToolResult { type: 'tool-result'; toolCallId: string; toolName: string; - args: { url: string }; + args: { query: string }; result: | Array<{ title: string; @@ -46,7 +46,7 @@ export class WebSearchTool extends WithDisposable(ShadowlessElement) { renderToolCall() { return html` `;