refactor(WebSearchTool): disable defer to keep search_images param visible
Browse filesWhy: ensuring LLM always sees the image search rules without deferred loading
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
src/tools/WebSearchTool/WebSearchTool.ts
CHANGED
|
@@ -170,7 +170,8 @@ function cleanSearchResult(result: any) {
|
|
| 170 |
export const WebSearchTool = buildTool({
|
| 171 |
name: WEB_SEARCH_TOOL_NAME,
|
| 172 |
description: 'Search the web — Tavily (when TAVILY_API_KEY is set) for general search, SearXNG for image search',
|
| 173 |
-
|
|
|
|
| 174 |
|
| 175 |
getToolUseSummary,
|
| 176 |
getActivityDescription(input) {
|
|
@@ -263,11 +264,11 @@ export const WebSearchTool = buildTool({
|
|
| 263 |
cleaned.length === 0
|
| 264 |
? [`No results for: ${input.query}`]
|
| 265 |
: [
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
|
| 272 |
const duration = (performance.now() - start) / 1000
|
| 273 |
|
|
@@ -324,4 +325,4 @@ export const WebSearchTool = buildTool({
|
|
| 324 |
content: [{ type: 'text', text }],
|
| 325 |
}
|
| 326 |
},
|
| 327 |
-
}) satisfies ToolDef<any, Output, WebSearchProgress>
|
|
|
|
| 170 |
export const WebSearchTool = buildTool({
|
| 171 |
name: WEB_SEARCH_TOOL_NAME,
|
| 172 |
description: 'Search the web — Tavily (when TAVILY_API_KEY is set) for general search, SearXNG for image search',
|
| 173 |
+
// 不 defer: 让 LLM 始终能看到 search_images 参数和图片搜索规则
|
| 174 |
+
shouldDefer: false,
|
| 175 |
|
| 176 |
getToolUseSummary,
|
| 177 |
getActivityDescription(input) {
|
|
|
|
| 264 |
cleaned.length === 0
|
| 265 |
? [`No results for: ${input.query}`]
|
| 266 |
: [
|
| 267 |
+
{
|
| 268 |
+
tool_use_id: 'search-1',
|
| 269 |
+
content: cleaned,
|
| 270 |
+
},
|
| 271 |
+
]
|
| 272 |
|
| 273 |
const duration = (performance.now() - start) / 1000
|
| 274 |
|
|
|
|
| 325 |
content: [{ type: 'text', text }],
|
| 326 |
}
|
| 327 |
},
|
| 328 |
+
}) satisfies ToolDef<any, Output, WebSearchProgress>
|