From ade7f2b0569938b3280e708980e271ac2d3d193a Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Thu, 12 Feb 2026 23:50:13 +0800 Subject: [PATCH] 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 --- packages/core/src/agent/system-prompt/sections.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core/src/agent/system-prompt/sections.ts b/packages/core/src/agent/system-prompt/sections.ts index 6826aa7e0..99573cbd8 100644 --- a/packages/core/src/agent/system-prompt/sections.ts +++ b/packages/core/src/agent/system-prompt/sections.ts @@ -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.", + "", ); }