Skip to content

[BREAKING] Python: Honor injected Azure AI Search clients over settings - #10001

Open
lsmlhi_25 (FOWEPJF255) wants to merge 2 commits into
microsoft:mainfrom
FOWEPJF255:FOWEPJF255/issue-9956-azure-search-injected-client
Open

lsmlhi_25 (FOWEPJF255) wants to merge 2 commits into
microsoft:mainfrom
FOWEPJF255:FOWEPJF255/issue-9956-azure-search-injected-client

Conversation

@FOWEPJF255

Copy link
Copy Markdown
Contributor

Motivation & Context

An application that injects a working Azure AI Search SDK client cannot currently pass an endpoint, credential, API key, or settings-file option to the store or collection constructor: construction raises before the supplied client is used. Passing managed_client=True can also cause the connector to close that caller-owned client. This blocks dependency-injected retrieval setups that carry ambient connection configuration.

Description & Review Guide

  • What are the major changes? Supplied clients now take precedence over client-creation settings. Store and collection cleanup always leaves injected clients open, while clients created by the connector are still closed. Focused regression tests cover explicit overrides, settings bypass, and both client lifecycles; the connector documentation reflects the behavior.
  • What is the impact of these changes? Previously rejected combinations now construct successfully. managed_client=True remains accepted for compatibility but no longer transfers ownership of an injected client, so callers relying on that cleanup must close their client themselves.
  • What do you want reviewers to focus on? Please check that the connector still closes a search client it creates from an injected index client, without closing the injected index client.

Related Issue

Fixes #9956

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Issue analysis, implementation, regression tests, connector documentation, and this description were materially assisted by an AI coding assistant. The change was reviewed against the source and verified with the package's non-integration tests, Ruff, and Pyright.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. This PR intentionally changes the experimental connector's ownership behavior; the title carries [BREAKING] for review.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 01:47
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Nov 3, 2026
@agent-framework-automation agent-framework-automation Bot added the breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible label Nov 3, 2026
@FOWEPJF255
lsmlhi_25 (FOWEPJF255) marked this pull request as ready for review November 3, 2026 01:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the injected-client precedence and ownership changes.

No open issues 🎉

What changed in this PR

This PR addresses #9956 by making injected Azure AI Search clients take precedence over connection settings and remain caller-owned. This intentionally breaks cleanup behavior for callers that previously used managed_client=True to transfer ownership.

Changes:

  • Accept connection and settings-file arguments alongside injected clients without resolving those settings.
  • Preserve cleanup of connector-created clients, including search clients derived from an injected index client.
  • Update regression tests and documentation to reflect the precedence and ownership rules.
File Description
python/​packages/​azure-ai-search/​tests/​test_vector_store.py Updates ownership assertions and tests injected-client precedence over explicit settings.
python/​packages/​azure-ai-search/​README.md Documents caller ownership even with managed_client=True.
python/​packages/​azure-ai-search/​AGENTS.md Aligns connector guidance with settings bypass and ownership behavior.
python/​packages/​azure-ai-search/​agent_framework_azure_ai_search/​_vector_store.py Removes settings conflicts and limits cleanup ownership to connector-created clients.

Review effort: Balanced

@FOWEPJF255

Copy link
Copy Markdown
Contributor Author

The merge gate identified type narrowing errors in the new precedence test. I split the store and collection assertions into their respective branches and pushed dd1e9fd. The 20 targeted cases, Ruff, and all five azure-ai-search test typing checkers pass locally; CI is rerunning.

This branch was successfully deployed

1 active deployment
github-app-auth — dd1e9fdc Deployed Nov 4, 2026 by FOWEPJF255 via add_label #27080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Azure AI Search injected clients do not take precedence over connection settings

2 participants