Repository navigation
Python: Prefer injected Cosmos vector store clients over connection settings - #9996
Open
Sumedh Aerram (sumedh-aerram) wants to merge 4 commits into
Open
Sumedh Aerram (sumedh-aerram) wants to merge 4 commits into
Sumedh Aerram (sumedh-aerram) wants to merge 4 commits into
Conversation
Sumedh Aerram (sumedh-aerram)
temporarily deployed
to
github-app-auth
November 2, 2026 21:46 — with
GitHub Actions
Inactive
Sumedh Aerram (sumedh-aerram)
requested review from
Darren Cohen (dargilco),
Jose Alvarez (jpalvarezl) and
sophia-ramsey
as code owners
November 2, 2026 21:46
Sumedh Aerram (sumedh-aerram)
temporarily deployed
to
github-app-auth
November 2, 2026 21:46 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Collection-name lookup misses non-decorated registered models, and injected Cosmos clients can still create databases despite the option being documented as ignored.
2 open issues
What changed in this PR
Updates the Python Cosmos vector-store connector to prefer caller-injected SDK clients over connection settings, addressing #9955 while preserving caller ownership.
Changes:
- Accepts redundant connection settings when a client or proxy is injected.
- Adds environment fallback for resource names and explicit-name conflict checks for database proxies.
- Expands tests for settings precedence, injected-client lifetime, and unchanged owned-client behavior.
| File | Description |
|---|---|
python/packages/azure-cosmos/tests/azure_cosmos/test_vector_store.py |
Adds coverage for injection, name resolution, conflicts, and client ownership. |
python/packages/azure-cosmos/agent_framework_azure_cosmos/_vector_store.py |
Relaxes injection restrictions and resolves remaining resource names independently. |
Review effort: Balanced
Sumedh Aerram (sumedh-aerram)
temporarily deployed
to
github-app-auth
November 2, 2026 21:53 — with
GitHub Actions
Inactive
Sumedh Aerram (sumedh-aerram)
temporarily deployed
to
github-app-auth
November 2, 2026 21:55 — with
GitHub Actions
Inactive
Sumedh Aerram (sumedh-aerram)
temporarily deployed
to
github-app-auth
November 2, 2026 21:56 — with
GitHub Actions
Inactive
Sumedh Aerram (sumedh-aerram)
deployed
to
github-app-auth
November 3, 2026 21:17 — with
GitHub Actions
Active
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation & Context
CosmosStoreandCosmosCollectionraise when a caller injects aCosmosClient,DatabaseProxy, orContainerProxytogether with endpoint, credential, key, or.envoptions, even though those settings only matter when the connector creates its own client. An account-levelCosmosClientalso required an explicitdatabase_nameand could not read it from the environment.Description & Review Guide
.envoptions, which are ignored instead of rejected.create_databaseis ignored for injected database and container proxies (previously rejected); with an injected account client it still creates the database on first use, as before. Resource names the injected object does not provide resolve as explicit argument >AZURE_COSMOS_DATABASE_NAME> a focused error for the database (account client), and explicit argument > the model's registered collection name >AZURE_COSMOS_CONTAINER_NAME> a focused error for the container (account or database client). An explicit name that conflicts with an injected proxy's id still raises (collection_nameforcontainer_client, and now alsodatabase_namefordatabase_client)._resolve_resource_name, which reads only the process environment because.envoptions are ignored when a client is injected, the conflict checks for explicit names against an injected proxy's id, and the registered-definition lookup through core's_VECTOR_MODEL_REGISTRY(core has no public accessor; happy to switch if you prefer another approach).Tests cover each acceptance case in the issue: injected account, database, and container clients bypassing explicit settings and missing or undecodable
.envfiles; explicit > environment > error name resolution; mismatched and matching explicit names; registered (undecorated) models keeping their collection name; injected clients staying open after close; and unchanged owned-client settings resolution and close. The new acceptance tests failed againstmain(18 failures) and pass with the change. Locally (macOS, Python 3.13):azure-cosmospackage tests 228 passed, 3 integration tests skipped;ruff format/ruff check,poe pyright -P azure-cosmos, andpoe mypy -P azure-cosmospass.Related Issue
Fixes #9955
No other open PR references this issue.
AI Assistance
AI assistance details: implementation, tests, review, and this PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.