Python: fixes to azure ai search init, samples#5021
Merged
Conversation
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Python Azure AI Search context provider initialization to be clearer and more type-safe, and aligns several samples/tests with the updated APIs (including embedding protocol typing and Foundry client usage).
Changes:
- Add explicit
__init__overloads and improved settings-resolution behavior forAzureAISearchContextProvider(semantic vs agentic; env vs explicit args). - Tighten embedding protocol typing to carry the options type through
GeneratedEmbeddings, and add a runtime protocol assertion in tests. - Refresh samples to use the corrected parameter names (
model,model_deployment_name) and updated client-name labels in the chat-client sample.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/context_providers/azure_ai_search/search_context_semantic.py | Fix Foundry client construction and parameter naming in the semantic Azure AI Search sample. |
| python/samples/02-agents/context_providers/azure_ai_search/search_context_agentic.py | Update agentic Azure AI Search sample to use model_deployment_name and correct Foundry client parameter naming. |
| python/samples/02-agents/compaction/tiktoken_tokenizer.py | Add a typing suppression for tiktoken import to reduce type-check noise in the sample. |
| python/samples/02-agents/chat_client/built_in_chat_clients.py | Rename sample “client_name” options and adjust defaults/invocation accordingly. |
| python/packages/openai/tests/openai/test_openai_embedding_client.py | Add a runtime SupportsGetEmbeddings protocol conformance assertion. |
| python/packages/core/agent_framework/_evaluation.py | Minor formatting cleanup in evaluation error handling/messages. |
| python/packages/core/agent_framework/_clients.py | Update SupportsGetEmbeddings protocol generics to propagate options typing via GeneratedEmbeddings. |
| python/packages/azure-ai-search/tests/test_aisearch_context_provider.py | Add regression tests to ensure explicit KB/index args override env-resolved values in agentic mode. |
| python/packages/azure-ai-search/agent_framework_azure_ai_search/_context_provider.py | Add overloads + improved settings resolution/validation for agentic vs semantic initialization. |
Comments suppressed due to low confidence (1)
python/packages/azure-ai-search/agent_framework_azure_ai_search/_context_provider.py:428
- The docstring says
credential"Accepts a TokenCredential, AsyncTokenCredential, or a callable token provider", but this provider passescredentialdirectly toSearchClient/SearchIndexClientand the type hints only allow Azure credential objects. A callable token provider would not satisfy the Azure SDK credential interface here. Update the docstring (or add an adapter) so callers aren't misled into passing unsupported credential types.
credential: Azure credential for managed identity authentication.
Accepts a TokenCredential, AsyncTokenCredential, or a callable token provider.
mode: Search mode - "semantic" or "agentic". Default: "semantic".
rogerbarreto
approved these changes
Apr 1, 2026
westey-m
approved these changes
Apr 1, 2026
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 and Context
Fixes the init of the AzureAISearch Context Provider, adding overloads to make it easier to grasp
Also fixes the embedding protocol so that typing checks work well.
Description
Contribution Checklist