Python: Fix tool normalization and provider sample consolidation#3953
Merged
eavanvalkenburg merged 5 commits intomicrosoft:mainfrom Feb 16, 2026
Merged
Python: Fix tool normalization and provider sample consolidation#3953eavanvalkenburg merged 5 commits intomicrosoft:mainfrom
eavanvalkenburg merged 5 commits intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores callable/single-tool normalization and unset tool-choice handling, consolidates chat client samples, migrates Bedrock to the agent_framework.amazon namespace, and updates context provider samples to use AzureOpenAIResponsesClient with Foundry project endpoint setup.
Changes:
- Restored tool normalization to accept single tools, callables, and sequences via unified
normalize_tools()function, fixing issues #3936, #3946, and #3577 - Changed
validate_tool_mode()to returnNonewhen tool_choice is unset (instead of{'mode': 'none'}), allowing clients to omit the parameter - Migrated Bedrock to lazy-import
agent_framework.amazonnamespace, promoted incore[all], and relocated sample toproviders/amazon/ - Consolidated chat client samples into single
built_in_chat_clients.pywith factory pattern supporting OpenAI, Azure, Anthropic, Ollama, and Bedrock - Updated all context provider samples (Redis, Mem0, Azure AI Search, simple) to use AzureOpenAIResponsesClient with Foundry project endpoints
Reviewed changes
Copilot reviewed 45 out of 47 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Added ToolTypes and normalize_tools() to handle single tools, callables, and sequences uniformly; supports tools passed via kwargs |
python/packages/core/agent_framework/_types.py |
Updated validate_tool_mode() to return None when unset; updated tool type annotations to use ToolTypes |
python/packages/core/agent_framework/_agents.py |
Updated Agent tool parameter types to use ToolTypes; simplified tool normalization logic |
python/packages/core/agent_framework/_clients.py |
Updated as_agent() tool parameter types to use ToolTypes |
python/packages/core/agent_framework/openai/_chat_client.py |
Updated _prepare_tools_for_openai() to use normalize_tools() |
python/packages/core/agent_framework/openai/_assistants_client.py |
Updated to use normalize_tools(); added null check for tool_mode before setting tool_choice |
python/packages/core/agent_framework/openai/_assistant_provider.py |
Updated tool type annotations to use ToolTypes; filter out MCP tools before passing to assistant API |
python/packages/core/agent_framework/amazon/__init__.py |
New lazy-import module for Bedrock package via agent_framework.amazon namespace |
python/packages/core/pyproject.toml |
Added agent-framework-bedrock to all extra |
python/uv.lock |
Promoted Bedrock in dependency resolution |
python/packages/bedrock/agent_framework_bedrock/_chat_client.py |
Updated import path in docstring to agent_framework.amazon |
python/packages/bedrock/README.md |
Updated sample reference to new location under providers/amazon/ |
python/packages/bedrock/AGENTS.md |
Updated import path examples to agent_framework.amazon |
python/packages/bedrock/samples/bedrock_sample.py |
Deleted (moved to samples/02-agents/providers/amazon/) |
python/samples/02-agents/providers/amazon/bedrock_chat_client.py |
New consolidated Bedrock sample with tool usage |
python/samples/02-agents/providers/amazon/README.md |
New README documenting Bedrock sample and environment variables |
python/samples/02-agents/providers/README.md |
Added Bedrock provider entry to overview |
python/samples/02-agents/chat_client/built_in_chat_clients.py |
New consolidated sample supporting 11 client types via factory pattern |
python/samples/02-agents/chat_client/README.md |
Updated to document consolidated sample approach |
python/samples/02-agents/chat_client/*.py (deleted) |
Removed individual client samples (openai_, azure_, azure_ai_*) in favor of consolidated approach |
python/samples/02-agents/context_providers/simple_context_provider.py |
Updated to use AzureOpenAIResponsesClient with Foundry endpoints; improved state management |
python/samples/02-agents/context_providers/redis/*.py |
Updated all Redis samples to use AzureOpenAIResponsesClient and added source_id parameter |
python/samples/02-agents/context_providers/redis/README.md |
Updated environment variable documentation for Foundry setup |
python/samples/02-agents/context_providers/mem0/*.py |
Added source_id parameter to all Mem0ContextProvider instances |
python/samples/02-agents/context_providers/azure_ai_search/*.py |
Added source_id parameter to AzureAISearchContextProvider (fixes #3945) |
python/samples/02-agents/response_stream.py |
Fixed ChatResponse construction to use messages list instead of text/role |
python/samples/02-agents/typed_options.py |
Moved model_id to client constructor instead of options dict |
python/samples/01-get-started/README.md |
Updated to use Azure Foundry environment variables |
python/samples/01-get-started/01_hello_agent.py |
Added note about XML tags in samples |
python/packages/core/tests/openai/test_openai_chat_client.py |
Added test for single FunctionTool normalization |
python/packages/core/tests/openai/test_openai_assistants_client.py |
Added tests for tool_choice handling and single tool normalization |
python/packages/core/tests/core/test_types.py |
Updated test for validate_tool_mode(None) to expect None instead of {'mode': 'none'} |
python/packages/core/tests/core/test_function_invocation_logic.py |
Added test for tools passed via kwargs |
python/samples/02-agents/context_providers/simple_context_provider.py
Outdated
Show resolved
Hide resolved
43f6f7a to
21215da
Compare
markwallace-microsoft
approved these changes
Feb 16, 2026
- restore callable/single-tool normalization paths and unset tool-choice behavior\n- consolidate and expand chat/provider samples (OpenAI/Azure/Anthropic/Ollama/Bedrock)\n- migrate Bedrock lazy import surface to agent_framework.amazon and move provider samples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5af8e28 to
46274d7
Compare
SergeyMenshykh
approved these changes
Feb 16, 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.
Summary
This PR addresses tool-normalization regressions and consolidates provider samples.
Core/runtime fixes
Sample consolidation and provider coverage
samples/02-agents/chat_client/*built-in samples intobuilt_in_chat_clients.py.custom_chat_client.pyand adds a local custom options type in that sample.Bedrock promotion and provider-sample move
agent-framework-core[all].agent_framework.amazon.samples/02-agents/providers/amazon/and updates related docs.Context-provider sample updates
AzureOpenAIResponsesClientwith Foundryproject_endpoint+deployment_namesetup where applicable.Fixes #3577
Fixes #3946
Fixes #3945
Fixes #3936