Repository navigation
Python: Prefer injected MongoDB clients over connection settings - #9982
Open
ZedingZhang (ZedingZhang) wants to merge 1 commit into
Open
ZedingZhang (ZedingZhang) wants to merge 1 commit into
ZedingZhang (ZedingZhang) wants to merge 1 commit into
Conversation
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 17:37 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
marked this pull request as ready for review
November 2, 2026 17:37
ZedingZhang (ZedingZhang)
had a problem deploying
to
github-app-auth
November 2, 2026 17:37 — with
GitHub Actions
Error
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 17:38 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
November 2, 2026 17:39 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the injected MongoDB client and database-selection changes.
No open issues 🎉
What changed in this PR
This PR addresses #9952 by allowing MongoDB stores and collections to reuse an injected client despite redundant connection settings, while resolving the required database name independently.
Changes:
- Ignore URI, app-name, and
.envoptions for injected clients; resolve the database name from an explicit argument, thenMONGODB_DATABASE_NAME. - Extend tests for database precedence, ignored settings, skipped client creation, and caller-owned client cleanup.
- Update documentation to describe the injected-client behavior.
| File | Description |
|---|---|
python/packages/mongodb/tests/mongodb/test_settings.py |
Tests injected-client settings, database resolution, and ownership. |
python/packages/mongodb/README.md |
Documents database selection and ignored connection settings. |
python/packages/mongodb/agent_framework_mongodb/_vector_store.py |
Adds database-only settings resolution and updates constructor documentation. |
Review effort: Balanced
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
MongoDBStoreandMongoDBCollectionreject connection settings alongside an injectedasync_client, and require an explicit database name even whenMONGODB_DATABASE_NAMEis set. This prevents callers from reusing their configured client with shared connection configuration.Description & Review Guide
.envsettings. Resolve its database selector independently from an explicitdatabase_name, thenMONGODB_DATABASE_NAME. Update the constructor documentation and README, and extend the existing settings tests for both stores and collections.Related Issue
Fixes #9952. The issue has the
ready-for-implementationlabel; no competing open PR was found before submission.AI Assistance
AI assistance details: Codex assisted with investigation, implementation, tests, documentation, and this PR description. Codex executed the reported checks; I reviewed all 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.