Python: Fix auto function calling stripping explicit null arguments (fixes #5934)#6202
Open
hanhan761 wants to merge 1 commit into
Open
Python: Fix auto function calling stripping explicit null arguments (fixes #5934)#6202hanhan761 wants to merge 1 commit into
hanhan761 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes an issue where explicit None values for optional tool arguments were being stripped before invocation, causing them to be treated as missing.
Changes:
- Changed
exclude_none=Truetoexclude_none=Falsein threemodel_dumpcalls within_tools.pyso explicitNonevalues are preserved. - Added a test verifying that
None-valued optional parameters are passed through to the tool function.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/core/agent_framework/_tools.py | Preserve None argument values during argument parsing for invoke and _auto_invoke_function. |
| python/packages/core/tests/core/test_tools.py | New test asserting explicit None arguments survive invocation. |
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
Changes exclude_none=True to exclude_none=False in FunctionTool.invoke() and _auto_invoke_function() to preserve explicitly-provided
ull values. When a model passes {"param": null} for a required-but-nullable parameter, exclude_none=True strips the key, causing the schema validation to report it as "missing required argument".
Root Cause
model_dump(exclude_none=True) cannot distinguish between "field was never provided" (default None) and "field was explicitly set to None". This splits the model's intent when it provides
ull for optional parameters.
Changes
Issue
Fixes #5934
Verification