Python: Added explicit schema handling to @tool decorator#3734
Merged
dmytrostruk merged 4 commits intomicrosoft:mainfrom Feb 9, 2026
Merged
Python: Added explicit schema handling to @tool decorator#3734dmytrostruk merged 4 commits intomicrosoft:mainfrom
dmytrostruk merged 4 commits intomicrosoft:mainfrom
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class support for supplying an explicit input schema to the Python @tool decorator, enabling callers to bypass signature-based schema inference (per issue #3579).
Changes:
- Added a
schemaparameter toagent_framework.tool()that is forwarded toFunctionTool(input_model=...). - Added unit tests covering explicit schema usage via both Pydantic models and JSON-schema-like dicts.
- Added a new getting-started sample and updated the tools README to document explicit schema usage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_tools.py | Extends @tool to accept an explicit schema and updates docstring/docs. |
| python/packages/core/tests/core/test_tools.py | Adds coverage for @tool(schema=...) with Pydantic, dict schema, and schema=None. |
| python/samples/getting_started/tools/function_tool_with_explicit_schema.py | New sample demonstrating explicit schema usage. |
| python/samples/getting_started/tools/README.md | Documents the new explicit-schema capability and links the new sample. |
Comments suppressed due to low confidence (1)
python/samples/getting_started/tools/function_tool_with_explicit_schema.py:60
- The schema above declares a default for
timezone(making it effectively optional), butget_current_time()requirestimezonewith no default in the function signature. Consider either adding a default in the signature (e.g.,timezone="UTC") or marking it as required in the schema to keep behavior consistent.
def get_current_time(timezone: str) -> str:
"""Get the current time."""
python/samples/getting_started/tools/function_tool_with_explicit_schema.py
Show resolved
Hide resolved
eavanvalkenburg
approved these changes
Feb 6, 2026
giles17
approved these changes
Feb 6, 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
Resolves: #3579
Contribution Checklist