Repository navigation
Python: Prefer injected Qdrant clients over connection settings - #9993
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits intoNov 3, 2026
Conversation
An injected AsyncQdrantClient now takes precedence over URL, API key, and .env options. Those settings are not read, and the caller keeps ownership even when managed_client is true. Fixes microsoft#9957 Co-authored-by: ZedingZhang <me@zedingzhang.com>
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 18:52 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
requested a review
from sophia-ramsey
as a code owner
November 2, 2026 18:52
Closed
2 tasks done
ZedingZhang (ZedingZhang)
requested a review
from Darren Cohen (dargilco)
as a code owner
November 2, 2026 18:52
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 18:52 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 18:53 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The constructor creates an SDK client before validating collection arguments, leaking the client when validation fails; initialization must be reordered and covered by a regression test.
1 open issue
What changed in this PR
This PR addresses #9957 by making injected Qdrant clients take precedence over connection settings and remain caller-owned in the Python connector.
Changes:
- Centralizes client resolution for stores and collections, bypassing connection settings for injected clients.
- Expands regression tests for settings precedence and ownership, and updates test cleanup.
- Documents the revised client lifecycle behavior.
| File | Description |
|---|---|
python/packages/qdrant/tests/qdrant/test_settings.py |
Tests ignored settings, factory bypass, and shared-client ownership. |
python/packages/qdrant/tests/qdrant/test_collection.py |
Updates ownership assertions and explicitly closes caller-owned test clients. |
python/packages/qdrant/tests/qdrant/conftest.py |
Adds explicit cleanup for the injected integration-test client. |
python/packages/qdrant/README.md |
Documents injected-client precedence and caller ownership. |
python/packages/qdrant/agent_framework_qdrant/_vector_store.py |
Adds shared client resolution and updates constructor documentation. |
Review effort: Balanced
QdrantCollection now runs base initialization before resolving a client, so invalid collection arguments raise without calling the SDK factory. Co-authored-by: ZedingZhang <me@zedingzhang.com>
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Nov 3, 2026
This branch was previously 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
QdrantStoreandQdrantCollectionraiseValueErrorwhen an injectedAsyncQdrantClientis supplied alongside URL, API-key, or.envoptions. They also honormanaged_client=Trueby closing that caller-supplied client. Applications cannot reuse a configured client together with shared constructor options, and cleanup can close a client the caller still owns.Description & Review Guide
.envloading for that client, and always leave it caller-owned, including whenmanaged_client=True. Update the constructor documentation, README, and the settings and ownership tests.load_settingsandAsyncQdrantClientare not called for an injected client, and confirm cleanup leaves that client open. The regression fails on the original implementation and passes with the fix.Related Issue
Fixes #9957. The issue has the
ready-for-implementationlabel; no competing open PR was found before submission.AI Assistance
AI assistance details: An AI coding assistant helped with investigation, implementation, tests, documentation, and this PR description. I review the submitted content and take responsibility for it.
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.