Python: Feature/azure ai search agentic rag (search as separate package)#2328
Merged
eavanvalkenburg merged 28 commits intomicrosoft:mainfrom Nov 20, 2025
Merged
Conversation
- Add type annotation to DEFAULT_CONTEXT_PROMPT - Add type annotation to vectorizable_fields - Add union type annotation to vector_queries
- Rename DEFAULT_CONTEXT_PROMPT to _DEFAULT_SEARCH_CONTEXT_PROMPT to avoid conflict with base class Final variable - Update test to use new constant name - All core package tests passing (1123 passed)
…rag' into feature/azure-ai-search-agentic-rag
Addresses reviewer feedback from PR microsoft#1546 by isolating the beta dependency (azure-search-documents==11.7.0b2) into a new agent-framework-aisearch package. Changes: - Created new agent-framework-aisearch package with complete structure - Moved AzureAISearchContextProvider from core to aisearch package - Added AzureAISearchSettings class for environment variable auto-loading - Added support for direct API key string (auto-converts to AzureKeyCredential) - Added azure_openai_api_key parameter for Knowledge Base authentication - Updated embedding_function type to Callable[[str], Awaitable[list[float]]] - Moved Role import to top-level imports - Maintained lazy loading through agent_framework.azure module - Removed beta dependency from core package - Updated all tests to use new package location - All quality checks pass: ruff format/lint, pyright, mypy (0 errors) - All 21 unit tests pass with 59% coverage Semantic search mode verified working with both API key and managed identity authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Updated documentation to clarify that the top_k parameter only affects semantic search mode. In agentic mode, the server-side Knowledge Base determines retrieval based on query complexity and reasoning effort. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR successfully extracts Azure AI Search integration into a dedicated agent-framework-aisearch package, addressing enterprise adoption concerns around preview dependencies in the core framework. The change separates the beta azure-search-documents SDK from core while maintaining full backward compatibility through lazy loading.
Key changes include:
- New standalone package structure with comprehensive implementation and test coverage
- Lazy import mechanism enabling transparent backward compatibility for existing users
- Enhanced configuration options including Settings class for environment variable management and direct API key string support
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
python/uv.lock |
Added dependency entries for the new agent-framework-aisearch package and azure-search-documents==11.7.0b2 |
python/samples/getting_started/agents/azure_ai/azure_ai_with_search_context.py |
New comprehensive sample demonstrating both semantic (fast hybrid search) and agentic (Knowledge Base multi-hop reasoning) retrieval modes with proper credential handling and environment variable configuration |
python/samples/getting_started/agents/azure_ai/README.md |
Added documentation entry for the new search context sample |
python/packages/core/agent_framework/azure/__init__.py |
Extended lazy loading mechanism to include AzureAISearchContextProvider and AzureAISearchSettings for transparent backward compatibility |
python/packages/aisearch/tests/test_search_provider.py |
Comprehensive unit test suite covering initialization, semantic search, Knowledge Base setup, lifecycle management, message filtering, citations, and vector field auto-discovery |
python/packages/aisearch/tests/__init__.py |
Test package initialization file with copyright notice |
python/packages/aisearch/pyproject.toml |
Package configuration defining dependencies, build system, and tool settings aligned with monorepo structure |
python/packages/aisearch/agent_framework_aisearch/_search_provider.py |
Core implementation providing AzureAISearchContextProvider with semantic and agentic modes, auto-discovery of vector fields, and AzureAISearchSettings for configuration management |
python/packages/aisearch/agent_framework_aisearch/__init__.py |
Package initialization exposing public API with version metadata |
python/packages/aisearch/README.md |
Package documentation describing installation and usage with links to examples |
python/packages/aisearch/LICENSE |
MIT license file for the new package |
python/.env.example |
Added environment variable examples for Azure AI Search configuration |
… parameters Added support for configurable Knowledge Base behavior in agentic mode: - knowledge_base_output_mode: "extractive_data" (default) or "answer_synthesis" Some knowledge sources require answer_synthesis mode for proper functionality. - retrieval_reasoning_effort: "minimal" (default), "medium", or "low" Controls query planning complexity and multi-hop reasoning depth. These parameters give users fine-grained control over Knowledge Base behavior and enable support for knowledge sources that require answer synthesis. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/agents/azure_ai/azure_ai_with_search_context.py
Outdated
Show resolved
Hide resolved
Resolved conflict in python/samples/getting_started/agents/azure_ai/README.md by keeping both azure_ai_with_search_context.py and azure_ai_with_sharepoint.py entries.
Member
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/agents/azure_ai/azure_ai_with_search_context.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/agents/azure_ai/azure_ai_with_search_context_agentic.py
Show resolved
Hide resolved
Member
eavanvalkenburg
left a comment
There was a problem hiding this comment.
Really close, small things now!
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
python/packages/aisearch/agent_framework_aisearch/_search_provider.py
Outdated
Show resolved
Hide resolved
eavanvalkenburg
approved these changes
Nov 20, 2025
Member
eavanvalkenburg
left a comment
There was a problem hiding this comment.
Love it! Thanks Farzad!
moonbox3
approved these changes
Nov 20, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…ge) (microsoft#2328) * Python: Fix pyright errors and move search provider to core (microsoft#1546) * address pablo coments * update azure ai search pypi version to latest prev * init update * Fix MyPy type annotation errors in search provider - Add type annotation to DEFAULT_CONTEXT_PROMPT - Add type annotation to vectorizable_fields - Add union type annotation to vector_queries * Fix DEFAULT_CONTEXT_PROMPT MyPy error and update test - Rename DEFAULT_CONTEXT_PROMPT to _DEFAULT_SEARCH_CONTEXT_PROMPT to avoid conflict with base class Final variable - Update test to use new constant name - All core package tests passing (1123 passed) * Python: Move Azure AI Search to separate package per PR feedback Addresses reviewer feedback from PR microsoft#1546 by isolating the beta dependency (azure-search-documents==11.7.0b2) into a new agent-framework-aisearch package. Changes: - Created new agent-framework-aisearch package with complete structure - Moved AzureAISearchContextProvider from core to aisearch package - Added AzureAISearchSettings class for environment variable auto-loading - Added support for direct API key string (auto-converts to AzureKeyCredential) - Added azure_openai_api_key parameter for Knowledge Base authentication - Updated embedding_function type to Callable[[str], Awaitable[list[float]]] - Moved Role import to top-level imports - Maintained lazy loading through agent_framework.azure module - Removed beta dependency from core package - Updated all tests to use new package location - All quality checks pass: ruff format/lint, pyright, mypy (0 errors) - All 21 unit tests pass with 59% coverage Semantic search mode verified working with both API key and managed identity authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Python: Clarify top_k parameter only applies to semantic mode Updated documentation to clarify that the top_k parameter only affects semantic search mode. In agentic mode, the server-side Knowledge Base determines retrieval based on query complexity and reasoning effort. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Python: Add Knowledge Base output mode and retrieval reasoning effort parameters Added support for configurable Knowledge Base behavior in agentic mode: - knowledge_base_output_mode: "extractive_data" (default) or "answer_synthesis" Some knowledge sources require answer_synthesis mode for proper functionality. - retrieval_reasoning_effort: "minimal" (default), "medium", or "low" Controls query planning complexity and multi-hop reasoning depth. These parameters give users fine-grained control over Knowledge Base behavior and enable support for knowledge sources that require answer synthesis. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * effort and outputmode query params * Address PR review feedback for Azure AI Search context provider * comments eduward * ed latest comments --------- Co-authored-by: Farzad Sunavala <farzad.sunavala.enovate.ai> Co-authored-by: farzad528 <farzad528@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
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
This change is required to align with the Agent Framework design guidance that preview dependencies should not be included in the core package. The existing Azure AI Search integration relied on the beta SDK (
azure-search-documents==11.7.0b2), which created blockers for enterprise users who cannot consume preview libraries in production.By moving Azure AI Search integration into a dedicated
agent-framework-aisearchpackage, users gain explicit control over adopting preview features (pip install agent-framework-aisearch --pre) while keeping the core framework stable and compliant. This improves enterprise adoption, future-proofs the architecture, and maintains backward compatibility for existing users.This PR addresses all feedback from #1546 and resolves that issue.
Description
This PR introduces a new top-level package,
agent-framework-aisearch, and relocates all Azure AI Search–specific functionality out of the core package. Key changes include:python/packages/aisearch/containing theAzureAISearchContextProviderand related utilities.agent_framework.azureso existing imports continue to work without modification.AzureAISearchSettingsfor automatic environment variable loading; added support for direct API key strings; corrected type hints for the async embedding function.top_ksemantics, and improved parameter-level docstrings.No breaking changes. Existing users can continue importing via
agent_framework.azuretransparently.Contribution Checklist