Python: [BREAKING] changed AIFunction to FunctionTool and @ai_function to @tool#3413
Python: [BREAKING] changed AIFunction to FunctionTool and @ai_function to @tool#3413eavanvalkenburg merged 12 commits intomicrosoft:mainfrom
Conversation
0cdd264 to
1d841e2
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements a breaking change that renames AIFunction to FunctionTool and the @ai_function decorator to @tool. The changes are comprehensive and consistent across the entire codebase.
Changes:
- Renamed
AIFunctionclass toFunctionToolthroughout the codebase - Renamed
@ai_functiondecorator to@tool - Updated serialization type identifier from
"ai_function"to"function_tool" - Added default type parameters to the generic
FunctionTool[ArgsT, ReturnT]usingTypeVarWithDefaults - Fixed deepcopy issue with tools containing HTTP clients (addresses issue #3247)
- Updated all samples, tests, documentation, and package code consistently
Reviewed changes
Copilot reviewed 108 out of 109 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Core rename from AIFunction to FunctionTool, added TypeVar defaults, updated type identifier |
python/packages/core/agent_framework/_agents.py |
Fixed deepcopy issue by shallow copying tools to avoid copying HTTP clients |
python/packages/core/agent_framework/_types.py |
Updated normalize_tools and validate_tools functions, proper variable naming to avoid shadowing |
python/packages/core/agent_framework/_serialization.py |
Updated documentation examples to use new naming |
| Various client implementations | Updated all pattern matches and type checks across OpenAI, Azure, Anthropic, Bedrock, Ollama clients |
| Test files | Comprehensive updates to all test files with consistent naming |
| Sample files | All samples updated to use new @tool decorator and FunctionTool class |
| Documentation | Updated README files and coding standards to reflect new naming |
Comments suppressed due to low confidence (1)
python/packages/azure-ai/tests/test_provider.py:491
- This class does not call MCPTool.init during initialization. (MockMCPTool.init may be missing a call to a base class init)
class MockMCPTool(MCPTool): # pyright: ignore[reportGeneralTypeIssues]
python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ui_generator_agent.py
Outdated
Show resolved
Hide resolved
|
@eavanvalkenburg @giles17 - Regarding #3368, the issue get resolved when instrumentation is disabled. I suspect |
615e885 to
d4df88d
Compare
|
Will this be accompanied by a documentation update PR? |
aee4a53 to
8c80dd2
Compare
Motivation and Context
Updated naming of
AIFunctiontoFunctionToolAlso added a default to the generic arguments
And the decorator from
@ai_functionto@toolFixes: #3247 and #3368
Closes: #2902 (final point has a additional issue created for it)
Description
Contribution Checklist