Skip to content

Python: fixes to azure ai search init, samples#5021

Merged
eavanvalkenburg merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:fix_ai_search_cp
Apr 1, 2026
Merged

Python: fixes to azure ai search init, samples#5021
eavanvalkenburg merged 1 commit into
microsoft:mainfrom
eavanvalkenburg:fix_ai_search_cp

Conversation

@eavanvalkenburg

Copy link
Copy Markdown
Member

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

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings April 1, 2026 07:55
@markwallace-microsoft

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/azure-ai-search/agent_framework_azure_ai_search
   _context_provider.py3571097%120–121, 539, 590–591, 714–715, 893–894, 941
packages/core/agent_framework
   _clients.py138794%324, 376, 532–535, 644
   _evaluation.py6277388%159, 167, 476, 478, 604, 607, 686–688, 693, 730–733, 789–790, 793, 799–801, 805, 838–840, 894, 929, 941–943, 948, 972–977, 1068, 1146–1147, 1149–1153, 1159, 1198, 1543, 1545, 1553, 1563, 1567, 1612, 1630–1631, 1702, 1708, 1723, 1727–1729, 1759, 1765–1769, 1801, 1832–1833, 1835, 1860–1861, 1866
TOTAL26744317188% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5295 20 💤 0 ❌ 0 🔥 1m 23s ⏱️

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.

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 for AzureAISearchContextProvider (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 passes credential directly to SearchClient/SearchIndexClient and 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".

Comment thread python/samples/02-agents/chat_client/built_in_chat_clients.py
Comment thread python/samples/02-agents/chat_client/built_in_chat_clients.py
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Apr 1, 2026
Merged via the queue into microsoft:main with commit 2a8c3e2 Apr 1, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants