diff --git a/src/main/tool-handlers.ts b/src/main/tool-handlers.ts index 0ea9d72..2b90d91 100644 --- a/src/main/tool-handlers.ts +++ b/src/main/tool-handlers.ts @@ -495,7 +495,7 @@ export async function handleWebSearch(params: { query: string; max_results?: num return { success: false, error: '搜索关键词不能为空' }; } - const maxResults = Math.min(params.max_results || 5, 10); + const maxResults = Math.min(params.max_results || 8, 10); sendLog('info', `🔍 web_search`, `"${query}" (${maxResults} 条)`); diff --git a/src/renderer/services/agent-engine.ts b/src/renderer/services/agent-engine.ts index 50478b5..26d5486 100644 --- a/src/renderer/services/agent-engine.ts +++ b/src/renderer/services/agent-engine.ts @@ -32,7 +32,8 @@ const TOOL_USAGE_GUIDE = `【工具使用规则】 2. 工具调用结果中的 path 字段是权威的文件路径,优先使用它。 3. 如果对话中从未出现过相关路径,应先用 search_files 或 list_directory 定位,不要凭空猜测路径。 4. 对同一文件的连续操作(读取→修改、读取→删除),路径必须一致。 -5. 当用户要求执行命令时,使用 run_command 工具执行。命令通过工作空间终端实时执行并显示,执行完成后将 stdout/stderr 结果告知用户。`; +5. 当用户要求执行命令时,使用 run_command 工具执行。命令通过工作空间终端实时执行并显示,执行完成后将 stdout/stderr 结果告知用户。 +6. 联网搜索联动:当用户询问需要最新信息的问题时(如版本号、新闻、价格等),先用 web_search 搜索,然后必须从搜索结果中选择最相关的 1-3 个 URL,用 web_fetch 抓取页面详细内容获取准确数据。不要仅凭搜索摘要回答——摘要往往不完整,必须抓取原文才能给出准确答案。`; export interface AgentCallbacks { onThinking: (text: string) => void; diff --git a/src/renderer/services/tool-registry.ts b/src/renderer/services/tool-registry.ts index 64b4f41..5cb2700 100644 --- a/src/renderer/services/tool-registry.ts +++ b/src/renderer/services/tool-registry.ts @@ -346,7 +346,7 @@ export const TOOL_DEFINITIONS: ToolDefinition[] = [ required: ['query'], properties: { query: { type: 'string', description: 'The search query. Be specific and concise for best results.' }, - max_results: { type: 'integer', description: 'Maximum number of results to return. Default: 5, max: 10.' } + max_results: { type: 'integer', description: 'Maximum number of results to return. Default: 8, max: 10.' } } } }