diff --git a/electron/harness/tools/built-in/web-search.ts b/electron/harness/tools/built-in/web-search.ts index 6c17ed7..14f40b3 100644 --- a/electron/harness/tools/built-in/web-search.ts +++ b/electron/harness/tools/built-in/web-search.ts @@ -252,18 +252,18 @@ export class WebSearchTool implements IMetonaTool { // 读取 SearXNG 配置(提前读取,使工具参数默认值与配置一致) const searxngConfig = this.readSearXNGConfig(); - // max_results: 工具参数 > 配置面板 > 默认 30。取较大值保证配置面板的下限约束 + // max_results: 配置面板为下限,AI 参数不得低于配置值,上限 30 const argMaxResults = (args.max_results as number) ?? undefined; const cfgMaxResults = searxngConfig.max_results > 0 ? searxngConfig.max_results : undefined; - const maxResults = Math.min(30, Math.max(1, argMaxResults ?? cfgMaxResults ?? 30)); + const maxResults = Math.min(30, Math.max(1, argMaxResults ?? 30, cfgMaxResults ?? 0)); const timeRange = (args.time_range as string) ?? ''; const enhanceSnippets = (args.enhance_snippets as boolean) ?? true; - // fetch_top: 工具参数 > 配置面板 > 默认 5。取较大值保证配置面板的下限约束 + // fetch_top: 配置面板为下限,AI 参数不得低于配置值,上限 8 const argFetchTop = (args.fetch_top as number) ?? undefined; const cfgFetchCount = searxngConfig.fetch_count > 0 ? searxngConfig.fetch_count : undefined; - const fetchTop = Math.min(8, Math.max(3, argFetchTop ?? cfgFetchCount ?? 5)); + const fetchTop = Math.min(8, Math.max(3, argFetchTop ?? 5, cfgFetchCount ?? 0)); // 缓存检查(缓存 key 含 SearXNG 模式,避免切换后返回旧缓存) const cacheKey = `${searxngConfig.enabled ? 'searxng' : 'builtin'}:${normalizeUrl(query).toLowerCase()}`;