Skip to content

An AI-powered search engine with a generative UI

fix(prompts): keep spec fences out of the worked answer example (#940)

Yoshiki Miura4a75829f1e5a
diff --git a/lib/agents/prompts/search-mode-prompts.ts b/lib/agents/prompts/search-mode-prompts.ts
index 454f523e..6ed0f7fc 100644
--- a/lib/agents/prompts/search-mode-prompts.ts
+++ b/lib/agents/prompts/search-mode-prompts.ts
@@ -1,5 +1,4 @@
import {
- EXAMPLE_IMAGE_SPEC_BLOCK,
getImageSpecPrompt,
getRelatedQuestionsSpecPrompt
} from '@/lib/render/prompt'
@@ -149,8 +148,6 @@ Example approach:
- **Key Point:** Direct answer with specific data/numbers when available [1](#EXAMPLE_TOOL_CALL_ID_1)
- **Detail:** Supporting information with concrete examples [2](#EXAMPLE_TOOL_CALL_ID_1)
-${EXAMPLE_IMAGE_SPEC_BLOCK}
-
### When Comparing (use table format)
| Feature | Option A | Option B |
|---------|----------|----------|
@@ -335,8 +332,6 @@ Flexible example:
- **Core Answer:** Direct response with evidence [1](#EXAMPLE_TOOL_CALL_ID_1)
- **Context:** Relevant supporting details
-${EXAMPLE_IMAGE_SPEC_BLOCK}
-
Conclude with a brief synthesis that ties together the main insights into a clear overall understanding.
${getImageSpecPrompt()}
diff --git a/lib/render/__tests__/prompt.test.ts b/lib/render/__tests__/prompt.test.ts
index dfe8509f..aed522dc 100644
--- a/lib/render/__tests__/prompt.test.ts
+++ b/lib/render/__tests__/prompt.test.ts
@@ -55,13 +55,23 @@ describe('render prompts', () => {
expect(getAdaptiveModePrompt()).toContain('result order within each search')
})
- test.each([getQuickModePrompt, getAdaptiveModePrompt])(
- 'includes the canonical image block in the worked example',
- getPrompt => {
+ test.each([
+ [getQuickModePrompt, 'Example approach:'],
+ [getAdaptiveModePrompt, 'Flexible example:']
+ ])(
+ 'keeps spec fences out of the worked answer example',
+ (getPrompt, marker) => {
const prompt = getPrompt()
+ const workedExample = prompt.slice(
+ prompt.indexOf(marker),
+ prompt.indexOf('INLINE IMAGE EMBEDDING:')
+ )
- expect(prompt).toContain(EXAMPLE_IMAGE_SPEC_BLOCK)
- expect(prompt.split(EXAMPLE_IMAGE_SPEC_BLOCK)).toHaveLength(3)
+ // The worked example shows a complete answer body. A spec fence inside
+ // it makes it a finished answer that ends without the related-questions
+ // block, which suppresses that block instead of teaching it.
+ expect(workedExample).not.toContain('```spec')
+ expect(prompt.split(EXAMPLE_IMAGE_SPEC_BLOCK)).toHaveLength(2)
}
)