Skip to content

Python: Fix auto function calling stripping explicit null arguments (fixes #5934)#6202

Open
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-5934-preserve-null-arguments
Open

Python: Fix auto function calling stripping explicit null arguments (fixes #5934)#6202
hanhan761 wants to merge 1 commit into
microsoft:mainfrom
hanhan761:fix-5934-preserve-null-arguments

Conversation

@hanhan761
Copy link
Copy Markdown

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

  • python/packages/core/agent_framework/_tools.py: Changed exclude_none=True to exclude_none=False in 3 locations (lines 639, 648, 1495)
  • python/packages/core/tests/core/test_tools.py: Added est_invoke_preserves_explicit_none_arguments test

Issue

Fixes #5934

Verification

  • New test est_invoke_preserves_explicit_none_arguments passes
  • All existing tests in test_tools.py continue to pass

Copilot AI review requested due to automatic review settings May 30, 2026 07:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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=True to exclude_none=False in three model_dump calls within _tools.py so explicit None values 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.

@github-actions github-actions Bot changed the title Fix auto function calling stripping explicit null arguments (fixes #5934) Python: Fix auto function calling stripping explicit null arguments (fixes #5934) May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Auto function calling removes null arguments

3 participants