Skip to content

Python: fix(core): keep the JSON schema of dict-schema tools in FunctionTool.to_dict() - #9299

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
shanto462:fix-function-tool-to-dict-schema
Oct 13, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
shanto462:fix-function-tool-to-dict-schema

Conversation

@shanto462

@shanto462 Md. Shalah Uddin (shanto462) commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

FunctionTool.to_dict() left out the parameter schema of tools declared with a JSON schema dict (MCP server tools, AG-UI client tools, vector store tools and others). Since #3907 these tools keep self.input_model = None, and to_dict() skipped input_model whenever it was empty. After from_dict() the tool declared different or empty parameters.

Description & Review Guide

  • What are the major changes? to_dict() now writes input_model from parameters() for every tool, unless the caller excludes input_model. A regression test, with and without a function, checks that to_dict() contains the schema and that from_dict() restores the same parameters().
  • What is the impact of these changes? Serialized dict-schema tools include their schema, so a restored tool declares the same parameters. The output for Pydantic-model and signature-based tools does not change, and exclude={"input_model"} still omits the key.
  • What do you want reviewers to focus on? I removed the not self.input_model condition instead of adding a _schema_supplied check. input_model is None only for dict-schema tools; every other tool gets a Pydantic model (passed in, inferred from the function, or an empty generated model). So the condition had no other effect.

Related Issue

Fixes #9296

No other open PR covers this issue.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: issue analysis, implementation, tests, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:37
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change correctly resolves the reported serialization regression with appropriate coverage.

0 open findings

What changed in this PR

Fixes schema loss when serializing and restoring dict-schema FunctionTool instances.

Changes:

  • Always serializes tool parameters unless explicitly excluded.
  • Adds regression coverage for executable and declaration-only tools.
File Description
python/​packages/​core/​agent_framework/​_tools.py Preserves dict-based input schemas during serialization.
python/​packages/​core/​tests/​core/​test_tools.py Verifies schema-preserving round trips.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Merged via the queue into microsoft:main with commit f76d0a3 Oct 13, 2026
54 checks passed
@shanto462
Md. Shalah Uddin (shanto462) deleted the fix-function-tool-to-dict-schema branch October 19, 2026 09:42

This branch was previously deployed

1 inactive deployment
github-app-auth — 5be3d0df Deployed Oct 13, 2026 by shanto462 via add_label #25116
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: FunctionTool.to_dict() drops the parameter schema of tools declared with a JSON schema

3 participants