Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
This repository was archived by the owner on May 15, 2026. It is now read-only.

Indexing fails after switching vector model dimensions due to dimension mismatch error #5616

Closed

Description

@hubeizys

App Version

3.23.7

API Provider

Google Gemini

Model Used

text-embedding-004

Roo Code Task Links (Optional)

No response

🔁 Steps to Reproduce

Description
When switching between vector models with different dimensions in Roo Code (e.g., first using a 2048-dimensional model to generate an index, then switching to Google Gemini’s 768-dimensional model), re-indexing fails. The Qdrant database logs repeatedly show the error: “Vector dimension error: expected dim: 2048, got 768”, preventing successful codebase indexing. This issue is consistently reproducible.

Steps to Reproduce

  • In Roo Code settings, select a high-dimensional vector model (e.g., 2048 dimensions) and complete codebase indexing (status becomes green “Indexed”).

  • Navigate to Roo Code’s “Codebase Indexing” configuration, switch to a model with a different dimension (e.g., Google Gemini, 768 dimensions), and click “Save and Start Indexing”.

  • Observe behavior: Indexing fails, status turns red “Error”, and Qdrant logs show the dimension mismatch error:

Failed to update shard ws-dac1ca8e499c3b3c:0 on peer 5413442089717253, error: Wrong input: Vector dimension error: expected dim: 2048, got 768

  • Repeated attempts to re-index (via “Save and Start Indexing”) do not resolve the error, and indexing remains unsuccessful.

💥 Outcome Summary

Indexing fails after switching vector model dimensions due to dimension mismatch error

📄 Relevant Logs or Errors (Optional)

Activity

  1. dosubot commented on Jul 12, 2025

    @dosubot

    This error happens because Qdrant requires all vectors in a collection to have the same dimension. When you switch embedding models in Roo Code (for example, from a 2048-dimensional model to Google Gemini’s 768-dimensional model), the existing Qdrant collection still expects vectors of the old dimension, so new vectors with a different dimension cause a hard failure. The Roo Code docs confirm that changing the embedding model’s dimension requires a full re-index, but they don’t specify whether Roo Code automatically resets or recreates the Qdrant collection when you switch models—so the old collection may persist and block re-indexing with the new dimension source.

    To resolve this, you’ll likely need to manually delete or reset the Qdrant collection before re-indexing with the new model. There’s no documented UI or CLI option in Roo Code for this, so you may need to use Qdrant’s management tools or API to drop the collection associated with your codebase, then trigger indexing again. If Roo Code adds automation for this in the future, it should be reflected in the docs, but for now, manual intervention is probably required.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about Roo-Code Share Dosu with your team

  2. hubeizys commented on Jul 12, 2025

    @hubeizys
    Author

    This error happens because Qdrant requires all vectors in a collection to have the same dimension. When you switch embedding models in Roo Code (for example, from a 2048-dimensional model to Google Gemini’s 768-dimensional model), the existing Qdrant collection still expects vectors of the old dimension, so new vectors with a different dimension cause a hard failure. The Roo Code docs confirm that changing the embedding model’s dimension requires a full re-index, but they don’t specify whether Roo Code automatically resets or recreates the Qdrant collection when you switch models—so the old collection may persist and block re-indexing with the new dimension source.

    To resolve this, you’ll likely need to manually delete or reset the Qdrant collection before re-indexing with the new model. There’s no documented UI or CLI option in Roo Code for this, so you may need to use Qdrant’s management tools or API to drop the collection associated with your codebase, then trigger indexing again. If Roo Code adds automation for this in the future, it should be reflected in the docs, but for now, manual intervention is probably required.

    To reply, just mention @dosu.

    How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

    Currently, clicking "reset" in the settings allows me to resolve this issue. However, performing a full reset of Roo Code is not a very ideal solution.

  3. roomote commented on Jul 12, 2025

    @roomote
    Contributor

    PR #5617 has been created to address this issue: #5617

  4. roomote commented on Jul 12, 2025

    @roomote
    Contributor

    Status Update

    The vector dimension mismatch issue has been successfully resolved in PR #5617.

    ✅ Solution Implemented

    The fix automatically detects when there's a vector dimension mismatch between the existing Qdrant collection and the new embedding model, then:

    1. Safely deletes the existing collection with the old dimensions
    2. Creates a new collection with the correct vector dimensions
    3. Preserves all functionality while handling the transition gracefully

    🔧 Technical Details

    • Root Cause: Qdrant requires all vectors in a collection to have the same dimension
    • Fix Location: src/services/code-index/vector-store/qdrant-client.ts lines 162-179
    • Behavior: When switching embedding models (e.g., 2048→768 dimensions), the system now automatically recreates the collection instead of failing

    🧪 Testing Status

    • ✅ All vector store unit tests pass (59/59)
    • ✅ All code-index integration tests pass (329/329)
    • ✅ Comprehensive test coverage for dimension mismatch scenarios added
    • ⚠️ One unrelated integration test is failing (MCP filesystem), but this is a pre-existing issue also affecting the main branch

    📋 Next Steps

    The PR is ready for review and merge. The failing integration test is unrelated to this fix and affects the entire repository, not just this PR.

    No more manual Qdrant collection deletion required! 🎉

  5. moved this from Triage to Issue [In Progress] in Roo Code Roadmapon Jul 14, 2025
  6. added
    Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.
    and removed
    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.
    on Jul 14, 2025
  7. moved this from Issue [In Progress] to Done in Roo Code Roadmapon Jul 14, 2025
  8. added a commit that references this issue on Jul 16, 2025
  9. bqback commented on Mar 31, 2026

    @bqback

    I am able to reproduce this with the latest qdrant version after manually adjusting the model size without changing any other indexing settings. Not only that, but completely wiping the volume still throws this message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions