[BUG] OpenAI-compatible embedding model alias breaks embedder construction
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
Research direction
Start in crewai/rag/embeddings/factory.py and trace how build_embedder passes provider configuration into the OpenAI and OpenRouter embedding functions. Check the provider model definitions and existing regression tests for alias handling and precedence when both keys are present. Done means construction succeeds for model alone and with both keys, while model_name retains precedence; run the focused offline factory tests.
Written by the indexing model from the issue text.
Description
Description
model is accepted as a backward-compatible alias for model_name by the OpenAI and OpenRouter embedding providers. However, constructing the actual embedding function with that alias raises:
TypeError: OpenAIEmbeddingFunction.__init__() got an unexpected keyword argument 'model'
Both alias-only configuration and configuration containing both keys fail. Configuration containing only model_name succeeds. This affects dictionary specifications and provider instances passed to build_embedder.
Reproduction
From a development checkout with core dependencies installed:
from crewai.rag.embeddings.factory import build_embedder
build_embedder({
"provider": "openai", # also reproducible with "openrouter"
"config": {
"api_key": "offline-test-key",
"model": "text-embedding-3-small",
},
})
This only constructs the embedding function; it does not call an embedding API or require a real key.
Expected behavior
Consume the model alias before building the embedding function, retaining model_name as the canonical key. If both keys are supplied, preserve the existing documented/tested precedence of model_name.
Evidence and scope
Verified against main 90266d5257055e05fabeced6d848eda8d0280cbf (CrewAI 1.15.33), Python 3.12.7, Pydantic 2.12.5 and ChromaDB 1.5.9 on Windows. Twelve offline regression cases use the real factory and OpenAIEmbeddingFunction: eight alias cases fail with the TypeError above, and four canonical-key controls pass on the unchanged implementation. After the local fix, all twelve pass.
The providers copy model into model_name, but leave model in Pydantic's allowed extra fields. build_embedder_from_provider then expands provider.model_dump() into the downstream constructor, which does not accept model.
This problem was previously mentioned as an out-of-scope observation in #7978. That PR's changed files do not include either of these provider implementations. Searches of related issues, PRs in all states, and the provider's recent commit history did not identify a separate fix at the time of this check. A focused local fix and regression tests are prepared.
AI disclosure
Prepared with OpenAI Codex for investigation, implementation and local validation. This is an AI-generated contribution under CONTRIBUTING.md; please apply llm-generated if the creating account cannot apply repository labels.
- Dominant language
- Python
- Stars
- 60.1k
- Forks
- 8.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 184
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crewAIInc/crewAI
-
[FEATURE] Add api_base_url to TavilySearchTool and TavilyExtractorToolPossibly taken @jayfeng7 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
crewAIInc/crewAI#8635 · 1 comment ·
Maintainers usually reply within 1 day
-
crewai-community feature-request vendor-pitch
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
crewai-community vendor-pitch
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
vendor-pitch
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
crewAIInc/crewAI#8271 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG]: ensure_type_in_schemas incorrectly forces empty schemas {} to {"type": "object"} in anyOf/oneOfPossibly taken @sallyw02 claimed this 17 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
crewAIInc/crewAI#8073 · 4 comments ·
Maintainers usually reply within 1 day
All issues in crewAIInc/crewAI
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
aws-samples/sample-per-model-bedrock#639 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
awslabs/visual-asset-management-system#937 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
project-codeflare/codeflare-sdk#1195 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
pandas-dev/pandas-stubs#2051 ·
Maintainers usually reply within 1 day