diff --git a/packages/api/src/tools/toolkits/web.spec.ts b/packages/api/src/tools/toolkits/web.spec.ts index e2edc0f1b4..007fabf752 100644 --- a/packages/api/src/tools/toolkits/web.spec.ts +++ b/packages/api/src/tools/toolkits/web.spec.ts @@ -14,6 +14,13 @@ describe('web search context', () => { expect(context).not.toContain('{{iso_datetime}}'); }); + it('guides the model to answer directly when a search is not warranted', () => { + const context = buildWebSearchContext(); + + expect(context).toContain('respond directly without searching'); + expect(context).toContain('current, real-time, or otherwise beyond your own knowledge'); + }); + it('builds dynamic context from the supplied conversation anchor', () => { const context = buildWebSearchDynamicContext('2024-01-02T03:04:05.000Z'); const secondContext = buildWebSearchDynamicContext('2024-01-02T03:04:05.000Z'); diff --git a/packages/api/src/tools/toolkits/web.ts b/packages/api/src/tools/toolkits/web.ts index d902cdae37..a1cdd1d413 100644 --- a/packages/api/src/tools/toolkits/web.ts +++ b/packages/api/src/tools/toolkits/web.ts @@ -3,7 +3,7 @@ import { Tools, replaceSpecialVars } from 'librechat-data-provider'; /** Builds the web search tool context with citation format instructions. */ export function buildWebSearchContext(): string { return `# \`${Tools.web_search}\`: -**Execute immediately without preface.** After search, provide a brief summary addressing the query directly, then structure your response with clear Markdown formatting (## headers, lists, tables). Cite sources properly, tailor tone to query type, and provide comprehensive details. +Use this tool when the user's request calls for it, whether directly, indirectly, or implicitly, or when answering requires information that is current, real-time, or otherwise beyond your own knowledge; for questions you can answer reliably on your own, respond directly without searching. When searching, execute immediately without preface, then provide a brief summary addressing the query directly, then structure your response with clear Markdown formatting (## headers, lists, tables). Cite sources properly, tailor tone to query type, and provide comprehensive details. Use the conversation date/time from the dynamic runtime context when recency matters.