fix(store): respect QMD_EMBED_MODEL env var in DEFAULT_EMBED_MODEL#348
Open
fix(store): respect QMD_EMBED_MODEL env var in DEFAULT_EMBED_MODEL#348
Conversation
store.ts hardcoded DEFAULT_EMBED_MODEL to "embeddinggemma", ignoring the QMD_EMBED_MODEL env var that llm.ts already respects. This caused formatQueryForEmbedding() to use the wrong prompt template during search when a custom embedding model (e.g. Qwen3-Embedding) was configured via the env var, because the hardcoded "embeddinggemma" string was passed as modelUri and isQwen3EmbeddingModel() returned false. Now store.ts reads process.env.QMD_EMBED_MODEL with "embeddinggemma" as fallback, consistent with llm.ts. Co-Authored-By: Oz <oz-agent@warp.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
QMD_EMBED_MODELis set to a custom embedding model (e.g. Qwen3-Embedding), search queries use the wrong prompt template, degrading search quality.This is because
store.tshardcodesDEFAULT_EMBED_MODEL = "embeddinggemma", and this value is passed through the call chain:In
formatQueryForEmbedding(llm.ts:38), sincemodelUriis"embeddinggemma"(truthy), it does not fall through toprocess.env.QMD_EMBED_MODEL. ThenisQwen3EmbeddingModel("embeddinggemma")returnsfalse, so the query is formatted with the embeddinggemma template (task: search result | query: ...) instead of the Qwen3 instruct template.This means documents are embedded with the correct Qwen3 format (because
llm.tsreads the env var), but queries use the wrong format — causing a mismatch that hurts search quality.Solution
Make
store.tsreadQMD_EMBED_MODELwith the same fallback pattern asllm.ts:Relation to #332
PR #332 fixes the display issue in
qmd.ts(showing the wrong model name duringqmd embed). This PR fixes the functional bug instore.tswhere search queries use the wrong prompt template. The two fixes are complementary.Fixes #328
Co-Authored-By: Oz oz-agent@warp.dev