Skip to content

[BUG] AutoRetriever fails with corrupted local Qdrant #3496

@hesamsheikh

Description

@hesamsheikh

Required prerequisites

What version of camel are you using?

0.2.70

System information

Python: 3.12.10 on darwin (macOS)
CAMEL: 0.2.70

Problem description

When using AutoRetriever with local Qdrant storage (StorageType.QDRANT), if the local storage becomes corrupted or was created with an incompatible version, the retriever throws a pydantic ValidationError and fails completely. This happens because _initialize_vector_storage() attempts to load the existing collection before the vector_count == 0 check and clear() call in run_vector_retriever(). The only workaround is to manually delete the local storage directory.

Reproducible example code

Reproducible Example

import os
import json
from pathlib import Path
from camel.retrievers import AutoRetriever
from camel.types import StorageType
from camel.embeddings import OpenAIEmbedding

# Step 1: Create a corrupted Qdrant storage directory
storage_path = "test_corrupted_storage"
collection_path = Path(storage_path) / "collection" / "test_collection"
collection_path.mkdir(parents=True, exist_ok=True)

# Write invalid config that will fail pydantic validation
invalid_config = {"vectors": {"size": 1536, "distance": "Cosine"}, "metadata": None}
with open(collection_path / "config.json", "w") as f:
    json.dump(invalid_config, f)

# Step 2: Try to use AutoRetriever - this will fail
retriever = AutoRetriever(
    vector_storage_local_path=storage_path,
    storage_type=StorageType.QDRANT,
    embedding_model=OpenAIEmbedding(),
)

# This raises ValidationError instead of recovering gracefully
retriever.run_vector_retriever(
    query="test query",
    contents=["Some test content to index"],
)

### Traceback

```pytb

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions