feat(agent): add search-then-fetch guidance to web tools system prompt (#150)

Guide the LLM to evaluate snippet quality after web_search and
follow up with web_fetch on the most relevant URLs when deeper
content is needed for accurate answers.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang
2026-02-12 23:50:13 +08:00
committed by GitHub
parent a986456e72
commit ade7f2b056

View File

@@ -340,6 +340,13 @@ export function buildConditionalToolSections(
"Prefer web_search for discovery and web_fetch for specific URLs.",
"Web usage is conditional, not mandatory: call web tools when they materially improve evidence quality.",
"",
"### Search-then-Fetch",
"After web_search, evaluate whether the snippets contain enough detail to answer accurately.",
"If not, use web_fetch on the 1-3 most relevant URLs to get full content before answering.",
"Always fetch when the user asks for detailed explanations, comparisons, or analysis;",
"when snippets are vague or contradictory; or when the question requires specific data points.",
"Skip fetch when the answer is a simple fact clearly stated in the snippet or the user only wants a quick overview.",
"",
);
}