feat(indexing): support 'auto' dimension with runtime detection fallback#11609
feat(indexing): support 'auto' dimension with runtime detection fallback#11609rrauenza wants to merge 2 commits into
Conversation
44a57fc to
f05ec41
Compare
f05ec41 to
c5880ee
Compare
| effectiveDimension = registryDimension | ||
| } else { | ||
| const detectionEmbedder = this.createEmbedder() | ||
| effectiveDimension = await this.detectEmbeddingDimension(detectionEmbedder) |
There was a problem hiding this comment.
WARNING: Runtime detection still does not cover baseline-backed worktrees
This fallback runs after CodeIndexManager._recreateServices() has already called createBaseline(factory), and createBaseline() still builds its vector store with no detected override. For an unknown custom model in a worktree session, initialization will still fail with Cannot determine vector dimension... before execution ever reaches this branch.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| effectiveDimension = await this.detectEmbeddingDimension(detectionEmbedder) | ||
| } | ||
|
|
||
| const embedder = this.createEmbedder(effectiveDimension) |
There was a problem hiding this comment.
WARNING: Detected dimensions are not applied to openai-compatible embeddings
effectiveDimension is passed into createEmbedder() here, but the openai-compatible branch above still constructs OpenAICompatibleEmbedder without its dimensions option. That means the vector store is created at the detected size while later embedding requests still use the endpoint's default size, which will trip a vector-length mismatch as soon as indexing starts for unknown custom models.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Files Reviewed (3 files)
Reviewed by gpt-5.4-20260305 · Input: 101.3K · Output: 12.3K · Cached: 594.2K Review guidance: REVIEW.md from base branch |
<I'm going to take this out of draft to see if it triggers CI - I haven't successfully pulled the plugin into my vscode yet.)
Issue
Fixes # #11500
Context
We can autodetect when unset the number of dimensions that an embedder has by passing in a sample embedding and seeing how many dimensions we get back.
Implementation
I decided not to add an enum of 'auto' for the dimensions type in the config. If you want that, let me know. The datatype remains
null | undefined | number. The null / undefined were already being treated as 'use default'.If
config.modelDimensionis not defined, we create a temporary embedder and do a query to get the dimensions. Then we explicitly pass that as an override intoCreateEmbedder. OtherwiseCreateEmbedderjust uses it's default,config.ModelDimension.Screenshots / Video
n/a
How to Test
Manual/local verification
Unit tests added - I don't have access to any of the api key'ed endpoints.
$ cd packages/kilo-indexing && bun test --timeout 30000 ./test/kilocode/indexing/service-factory.test.ts
bun test v1.3.13 (bf2e2cec)
test/kilocode/indexing/service-factory.test.ts:
✓ CodeIndexServiceFactory > creates an OpenAI-compatible embedder without an API key [1.43ms]
✓ CodeIndexServiceFactory > uses default LanceDB directory when config is unset [0.58ms]
✓ CodeIndexServiceFactory > uses explicit LanceDB directory when configured [0.11ms]
✓ CodeIndexServiceFactory > passes configured dimension to Ollama embed requests [3.62ms]
✓ CodeIndexServiceFactory > leaves Ollama dimensions unset when no override is configured [0.28ms]
✓ CodeIndexServiceFactory > passes configured dimension to OpenRouter embed requests [1.95ms]
✓ CodeIndexServiceFactory > creates vector store for OpenRouter Gemini embedding preview [0.13ms]
✓ CodeIndexServiceFactory > uses configured dimension before static model metadata for vector stores [0.09ms]
✓ CodeIndexServiceFactory > creates Kilo embedder with Cloud-provided model [1.56ms]
✓ CodeIndexServiceFactory > uses registry default for known model without explicit dimension [0.63ms]
✓ CodeIndexServiceFactory > uses explicit dimension over registry default [0.20ms]
✓ CodeIndexServiceFactory > detects dimension for unknown model without explicit dimension [0.49ms]
12 pass
0 fail
23 expect() calls
Ran 12 tests across 1 file. [373.00ms]
(I haven't figured out a way to get a self built plugin into vscode yet.)
Reviewer test steps
run unit tests (which will be in CI automatically for this PR, I believe)
Blocked checks and substitute verification
Checklist
Get in Touch