feat: add routed online search providers

This commit is contained in:
云服务部-叶林立
2026-08-19 11:04:03 +08:00
parent bf8bb42a09
commit 5a85660b5d
12 changed files with 500 additions and 5 deletions
+28
View File
@@ -11,6 +11,10 @@ function hasTool(selectedTools: SelectedTools, name: string): boolean {
return selectedTools === undefined || selectedTools.includes(name);
}
function hasAnyTool(selectedTools: SelectedTools, names: string[]): boolean {
return names.some((name) => hasTool(selectedTools, name));
}
export function buildToolRoutingSection(selectedTools: SelectedTools): string {
const rules: string[] = [];
@@ -40,6 +44,30 @@ export function buildToolRoutingSection(selectedTools: SelectedTools): string {
);
}
const tavilyTools = ["tavily_web_search", "tavily_web_fetch"];
const exaTools = ["exa_web_search", "exa_web_fetch", "exa_web_search_advanced"];
const keenableTools = ["keenable_search", "keenable_fetch"];
if (hasAnyTool(selectedTools, [...tavilyTools, ...exaTools, ...keenableTools])) {
rules.push(
"- Choose one online search provider based on the task instead of querying Tavily, Exa, and Keenable by default; cross-check with another provider only when source quality or uncertainty warrants it.",
);
}
if (hasAnyTool(selectedTools, tavilyTools)) {
rules.push(
"- Use Tavily tools for broad discovery when keywords are uncertain, for news/recent/trending topics, or when many candidate sources are useful. Tavily results can mix official pages, blogs, forums, and secondary sources, so keep max_results modest, avoid raw content unless needed, and fetch only selected pages when depth matters.",
);
}
if (hasAnyTool(selectedTools, exaTools)) {
rules.push(
"- Use Exa tools when source precision matters: official or API documentation, release/version information, academic papers, research material, and high-quality fact confirmation. Use exa_web_fetch to continue reading selected pages; for exa_web_search_advanced, explicitly bound the result count and returned text length to prevent oversized responses.",
);
}
if (hasAnyTool(selectedTools, keenableTools)) {
rules.push(
"- Use Keenable tools for Chinese-language pages, policies and government notices, site-restricted search, and publication-date filtering. Prefer its compact search results and fetch only selected pages to keep returned content controlled; KEENABLE_API_KEY is optional but raises rate limits.",
);
}
if (hasTool(selectedTools, "ctx_execute") || hasTool(selectedTools, "ctx_execute_file")) {
rules.push(
"- Use Context Mode for logs, test/build output, generated data, large-file exploration/analysis/summarization, and any command whose output may be large or unpredictable. Prefer ctx_execute_file over read when deriving an answer from a large file inside the workspace, and print only the derived answer needed for the task.",