← Back to Pull requests

fix(rag): give CustomEmbeddingFunction a name() for ChromaDB #9842

Open
unknown opened this pull request with 256 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 26, 2026 18:19 UTC
Author

Fixes #9841

Summary

Knowledge with a custom embedder (provider: "custom") crashed on the ChromaDB backend with AttributeError: '<cls>' object has no attribute 'name'. ChromaDB 1.x calls embedding_function.name() when it opens a collection. crewAI's other embedding functions define it (OpenAIEmbeddingFunction.name() is documented "for ChromaDB compatibility"; VoyageAI, IBM and Oracle do too), but CustomEmbeddingFunction did not, and because crewAI's EmbeddingFunction is its own Protocol it does not inherit ChromaDB's fallback. The default Qdrant backend never calls name(), so only users who opt in to ChromaDB were affected.

Changes

  • lib/crewai/src/crewai/rag/embeddings/providers/custom/embedding_callable.py: add a static name() returning "custom", the same shape as OpenAIEmbeddingFunction.name(). Subclasses can still override it.

  • lib/crewai/tests/knowledge/test_knowledge_storage_providers.py: add test_custom_embedder_save_and_search_roundtrip_on_chromadb, which saves and searches through a real local ChromaDB client (marked requires_chromadb). The existing ChromaDB test mocks create_client, so it never reached the code that calls name().
  • Verification

  • Against the base revision of embedding_callable.py (new test kept): test_knowledge_storage_providers.py -> 1 failed, 15 passed; the new test fails with the AttributeError from the issue.

  • With the fix: 16 passed.

  • Full lib/crewai/tests/: 7673 passed, 46 skipped, 4 xfailed (base 77237aec: 7672 passed, same skips and xfails).

  • ruff check lib/, ruff format --check lib/ and mypy lib/crewai/src/crewai/ pass; mypy also passes on the changed module with --python-version 3.10.

  • The issue's repro script now prints ok, and reopening the same ChromaDB store from a second process works.
  • AI assistance

    Prepared with Claude Code assistance; I reviewed and can explain every change. Per CONTRIBUTING.md, please apply the llm-generated label; external contributors can't add it with their permissions.

    Diff: 256 lines (+192 / -64) across 3 files Reviewer: 1AbdullahButt Review duration: 2207m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.44) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 256 lines diff across 3 files
    0.44
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #9842"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.1% (MEDIUM) · Higher = larger blast radius
    44.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.5% · Safe to merge
    23.5%