From 8134b3c1ef0a36202e50fe7f79da22e33d0a7757 Mon Sep 17 00:00:00 2001 From: venti <1308199824@qq.com> Date: Sat, 30 May 2026 15:22:49 +0800 Subject: [PATCH] fix(core): preserve null arguments in tool function calls --- python/packages/core/agent_framework/_tools.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/python/packages/core/agent_framework/_tools.py b/python/packages/core/agent_framework/_tools.py index 93722a8987..ec0bd28196 100644 --- a/python/packages/core/agent_framework/_tools.py +++ b/python/packages/core/agent_framework/_tools.py @@ -635,9 +635,7 @@ async def invoke( if isinstance(arguments, Mapping): parsed_arguments = dict(arguments) if self.input_model is not None and not self._schema_supplied: - parsed_arguments = self.input_model.model_validate(parsed_arguments).model_dump( - exclude_none=True - ) + parsed_arguments = self.input_model.model_validate(parsed_arguments).model_dump() elif isinstance(arguments, BaseModel): if ( self.input_model is not None @@ -645,7 +643,7 @@ async def invoke( and not isinstance(arguments, self.input_model) ): raise TypeError(f"Expected {self.input_model.__name__}, got {type(arguments).__name__}") - parsed_arguments = arguments.model_dump(exclude_none=True) + parsed_arguments = arguments.model_dump() else: raise TypeError( f"Expected mapping-like arguments for tool '{self.name}', got {type(arguments).__name__}" @@ -1492,7 +1490,7 @@ async def _auto_invoke_function( runtime_kwargs["session"] = invocation_session try: if not cast(bool, getattr(tool, "_schema_supplied", False)) and tool.input_model is not None: - args = tool.input_model.model_validate(parsed_args).model_dump(exclude_none=True) + args = tool.input_model.model_validate(parsed_args).model_dump() else: args = dict(parsed_args) args = _validate_arguments_against_schema(