Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(search): doctor suggests EmbeddingGemma's query task prompt (PR #6062, query half)
garrytan68c27ef227ec
diff --git a/docs/guides/search-modes.md b/docs/guides/search-modes.mdindex 58d3a5d9d8..9e29cc4f55 100644--- a/docs/guides/search-modes.md+++ b/docs/guides/search-modes.md@@ -242,7 +242,7 @@ their operator before continuing a real setup.## Query instruction prefix-Instruction-style embedding models (Qwen3-Embedding, e5, BGE v1.5, nomic-embed)+Instruction-style embedding models (Qwen3-Embedding, e5, BGE v1.5, nomic-embed, EmbeddingGemma)expect a query instruction in front of each search query and none in front ofdocuments. GBrain sends no instruction unless you set one for the brain;nothing is guessed from the model id at query time. `gbrain doctor` reports@@ -256,6 +256,7 @@ you can run as printed.| e5 | `query: ` || BGE v1.5 | `Represent this sentence for searching relevant passages: ` || nomic-embed | `search_query: ` |+| EmbeddingGemma | `task: search result \| query: ` |**Set.** Quote the value so trailing spaces and newlines survive the shell;a newline needs ANSI-C quoting:@@ -277,8 +278,10 @@ bytes, and `gbrain doctor` stops reporting `embedding_query_prefix`.**Unset.** `gbrain config unset embedding_query_prefix` restores bare queryembeddings on the next query.-nomic-embed also expects `search_document: ` in front of documents. GBrain does-not prefix documents, so on nomic the query prefix is a partial fix (#3783).+nomic-embed also expects `search_document: ` in front of documents, and+EmbeddingGemma's card formats documents as `title: {title} | text: {text}`.+GBrain does not prefix or format documents, so on those models the query prefix+is a partial fix (#3783, #5215).## Choosing a lookup verb (search vs query vs get)diff --git a/src/core/search/query-prefix.ts b/src/core/search/query-prefix.tsindex 1cca6ed58a..9b43704159 100644--- a/src/core/search/query-prefix.ts+++ b/src/core/search/query-prefix.ts@@ -27,6 +27,9 @@ const QUERY_PREFIX_FAMILIES: ReadonlyArray<{ family: string; pattern: RegExp; va{ family: 'e5', pattern: /(^|[/:_-])(multilingual-)?e5([-_.]|$)/, value: 'query: ' },{ family: 'BGE', pattern: /(^|[/:_-])bge-(?!m3)/, value: 'Represent this sentence for searching relevant passages: ' },{ family: 'nomic-embed', pattern: /nomic-embed/, value: 'search_query: ' },+ // PR #6062 (query half, @xorets): the model card's retrieval task prompt; the document-side `title: … | text: …`+ // formatting is a per-model document transform and stays a tracked feature, not a prefix.+ { family: 'EmbeddingGemma', pattern: /embeddinggemma/, value: 'task: search result | query: ' },];export function suggestedQueryPrefix(embeddingModel: string): { family: string; value: string } | null {diff --git a/test/embedding-query-prefix.test.ts b/test/embedding-query-prefix.test.tsindex f0b8bd78a4..c6287c3697 100644--- a/test/embedding-query-prefix.test.ts+++ b/test/embedding-query-prefix.test.ts@@ -157,6 +157,9 @@ describe('doctor advisory', () => {expect(suggestedQueryPrefix('openai-compatible:intfloat/multilingual-e5-large')?.value).toBe('query: ');expect(suggestedQueryPrefix('openai-compatible:BAAI/bge-large-en-v1.5')?.family).toBe('BGE');expect(suggestedQueryPrefix('ollama:nomic-embed-text')?.value).toBe('search_query: ');+ // PR #6062 (query half, @xorets): EmbeddingGemma's model card asks for the task prompt in front of each query.+ expect(suggestedQueryPrefix('ollama:embeddinggemma:300m')).toEqual({ family: 'EmbeddingGemma', value: 'task: search result | query: ' });+ expect(suggestedQueryPrefix('openai-compatible:google/embeddinggemma-300m')?.family).toBe('EmbeddingGemma');expect(suggestedQueryPrefix('openai:text-embedding-3-large')).toBeNull();expect(suggestedQueryPrefix('openai-compatible:BAAI/bge-m3')).toBeNull();});