Python: [BREAKING] Replace Hosted*Tool classes with tool methods#3634
Open
giles17 wants to merge 12 commits intomicrosoft:mainfrom
Open
Python: [BREAKING] Replace Hosted*Tool classes with tool methods#3634giles17 wants to merge 12 commits intomicrosoft:mainfrom
giles17 wants to merge 12 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a breaking change that refactors hosted tool support from standalone Hosted*Tool classes to static factory methods on chat clients. This improves API discoverability by making tool support explicit per client type.
Changes:
- Removed
HostedCodeInterpreterTool,HostedWebSearchTool,HostedFileSearchTool,HostedImageGenerationTool, andHostedMCPToolclasses - Added static factory methods (
get_code_interpreter_tool(),get_web_search_tool(), etc.) to relevant client classes - Introduced protocol classes (
SupportsCodeInterpreterTool,SupportsWebSearchTool, etc.) for runtime checking of tool support - Updated all samples, tests, and documentation to use the new API
Reviewed changes
Copilot reviewed 119 out of 119 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/_clients.py |
Added tool support protocol definitions |
python/packages/core/agent_framework/openai/_chat_client.py |
Added get_web_search_tool() static method |
python/packages/core/agent_framework/openai/_assistants_client.py |
Added get_code_interpreter_tool() and get_file_search_tool() static methods |
python/packages/core/agent_framework/openai/_responses_client.py |
Added static methods for all hosted tools (code interpreter, web search, file search, image generation, MCP) |
python/packages/azure-ai/agent_framework_azure_ai/_client.py |
Added Azure-specific get_mcp_tool() implementation |
python/packages/anthropic/agent_framework_anthropic/_chat_client.py |
Added static methods for Anthropic-supported tools |
| Multiple sample files | Updated to use new static factory methods instead of Hosted*Tool classes |
| Multiple test files | Updated test assertions to check for dict-based tools instead of class instances |
python/packages/declarative/agent_framework_declarative/_loader.py |
Updated to create dict-based tools directly |
Member
Member
eavanvalkenburg
left a comment
There was a problem hiding this comment.
Couple of notes, overall I think we will have to move to remove some additional pieces of from tools and streamline things even more, I would expect only the functionTool to be handled in the each clients prepare code, everything else should already be setup correctly.
python/packages/anthropic/agent_framework_anthropic/_chat_client.py
Outdated
Show resolved
Hide resolved
python/packages/anthropic/agent_framework_anthropic/_chat_client.py
Outdated
Show resolved
Hide resolved
python/packages/azure-ai/agent_framework_azure_ai/_chat_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/openai/_responses_client.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/agents/anthropic/anthropic_skills.py
Outdated
Show resolved
Hide resolved
dmytrostruk
approved these changes
Feb 5, 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
This PR refactors hosted tool support from standalone
Hosted*Toolclasses to@staticmethodfactory methods on the chat clients that support them. This is a breaking change that improves API discoverability and makes tool support explicit per clientBreaking Changes
Removed classes:
HostedCodeInterpreterToolHostedWebSearchToolHostedImageGenerationToolHostedFileSearchToolHostedMCPToolMigration:
#3586
Description
Contribution Checklist