Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 6, 2026

Related GitHub Issue

Closes: #8102

Description

This PR attempts to address Issue #8102 where the embedding dimension setting was not consistently applied, causing a dimension mismatch (e.g., 1536 vs 1024) between collection creation and embedding generation.

Root Cause:
The code was prioritizing the model's built-in dimension over the user-configured dimension. When a user set a custom dimension (e.g., 1536), the collection was created with that dimension, but embeddings were generated using the model's default dimension (e.g., 1024), causing vector dimension errors.

Implementation:

  • Updated currentModelDimension getter in config-manager.ts to prioritize user-configured dimension as the single source of truth
  • Updated createVectorStore() in service-factory.ts to use user-configured dimension before falling back to model's built-in dimension
  • Updated tests to reflect the new expected behavior

Key design choice: User-configured dimension now takes priority because users may intentionally set specific dimensions for compatibility with existing indexes or for using models that support variable dimensions.

Feedback and guidance are welcome.

Test Procedure

  1. All existing tests pass (114 tests in the affected files)
  2. New test cases added to verify:
    • User-configured dimension takes priority over model's built-in dimension
    • Falls back to model's built-in dimension when no user dimension is configured
  3. Run tests: cd src && ./node_modules/.bin/vitest run services/code-index/__tests__/config-manager.spec.ts services/code-index/__tests__/service-factory.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is a re-attempt at fixing issue #8102. The previous PR #8106 was closed without being merged.

This fix addresses issue #8102 where the embedding dimension setting was not
consistently applied (1536 vs 1024 mismatch).

The root cause was that the code prioritized the model's built-in dimension
over the user-configured dimension. This caused a dimension mismatch when:
1. User set a custom dimension (e.g., 1536)
2. Collection was created with user dimension (1536)
3. But embeddings were generated using model default (e.g., 1024)

Changes:
- config-manager.ts: Updated currentModelDimension getter to prioritize
  user-configured dimension as the single source of truth
- service-factory.ts: Updated createVectorStore() to prioritize user-configured
  dimension when creating the vector store
- Updated tests to reflect the new expected behavior

The fix ensures that when a user explicitly sets an embedding dimension,
that dimension is used consistently across both collection creation and
embedding generation, preventing dimension mismatch errors.
@roomote
Copy link
Contributor Author

roomote bot commented Jan 6, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The changes correctly address issue #8102 by prioritizing user-configured embedding dimensions over model defaults. Both config-manager.ts and service-factory.ts now consistently use user configuration as the single source of truth, falling back to model profiles only when no user dimension is set. All 114 tests pass.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] File index dimension setting not consistently applied (1536 vs 1024)

3 participants