Skip to content

An AI-powered search engine with a generative UI

Add source-direction guidance to search prompts (#881)

Yoshiki Miura20265261dd62
diff --git a/lib/agents/prompts/search-mode-prompts.ts b/lib/agents/prompts/search-mode-prompts.ts
index 2bb1e8d0..658036ac 100644
--- a/lib/agents/prompts/search-mode-prompts.ts
+++ b/lib/agents/prompts/search-mode-prompts.ts
@@ -9,6 +9,16 @@ import {
// Search mode system prompts
+function getSourceDirectionGuidance(): string {
+ return `Source direction (include/exclude domains):
+- When the user signals a source preference, pass it to the search tool via \`include_domains\` / \`exclude_domains\`:
+ - Specific site(s): "search reddit", "from x.com", "on github" → \`include_domains: ["reddit.com"]\`
+ - Authoritative-only: "official sources", "peer-reviewed", "primary sources" → include the relevant authoritative domains (e.g. \`["pubmed.ncbi.nlm.nih.gov","nature.com"]\` for medical, \`["worldbank.org","oecd.org"]\` for economic data)
+ - Avoid a source: "not pinterest", "exclude forums" → \`exclude_domains: ["pinterest.com"]\`
+- Only apply domain filters when the user's intent clearly points to a source. Do NOT invent restrictions for ordinary queries.
+- Fallback: if a domain-restricted search returns too few or no results, run one more search without the restriction before answering.`
+}
+
export function getQuickModePrompt(): string {
const hasGeneralProvider = isGeneralSearchProviderAvailable()
@@ -53,6 +63,8 @@ Search tool usage:
- Rely on the search results' content snippets for your answers
${hasGeneralProvider ? '- For video/image content, you can use type="general" with appropriate content_types' : '- Note: Video/image search requires a dedicated general search provider (not available)'}
+${getSourceDirectionGuidance()}
+
Search requirement (MANDATORY):
- If the user's message contains a URL, start directly with fetch tool - do NOT search first
- If the user's message is a question or asks for information/advice/comparison/explanation (not casual chit-chat like "hello", "thanks"), you MUST run at least one search before answering
@@ -229,6 +241,8 @@ Search tool usage - UNDERSTAND THE DIFFERENCE:
${getContentTypesGuidance()}
+${getSourceDirectionGuidance()}
+
Fetch tool usage:
- Use when you need deeper content analysis beyond search snippets
- Fetch the top 2-3 most relevant/recent URLs for comprehensive coverage