@@ -137,6 +137,7 @@ def function_tool(
137137 docstring_style : DocstringStyle | None = None ,
138138 use_docstring_info : bool = True ,
139139 failure_error_function : ToolErrorFunction | None = None ,
140+ strict_mode : bool = True ,
140141) -> FunctionTool :
141142 """Overload for usage as @function_tool (no parentheses)."""
142143 ...
@@ -150,6 +151,7 @@ def function_tool(
150151 docstring_style : DocstringStyle | None = None ,
151152 use_docstring_info : bool = True ,
152153 failure_error_function : ToolErrorFunction | None = None ,
154+ strict_mode : bool = True ,
153155) -> Callable [[ToolFunction [...]], FunctionTool ]:
154156 """Overload for usage as @function_tool(...)."""
155157 ...
@@ -163,6 +165,7 @@ def function_tool(
163165 docstring_style : DocstringStyle | None = None ,
164166 use_docstring_info : bool = True ,
165167 failure_error_function : ToolErrorFunction | None = default_tool_error_function ,
168+ strict_mode : bool = True ,
166169) -> FunctionTool | Callable [[ToolFunction [...]], FunctionTool ]:
167170 """
168171 Decorator to create a FunctionTool from a function. By default, we will:
@@ -186,6 +189,7 @@ def function_tool(
186189 failure_error_function: If provided, use this function to generate an error message when
187190 the tool call fails. The error message is sent to the LLM. If you pass None, then no
188191 error message will be sent and instead an Exception will be raised.
192+ strict_mode: If False, allows optional parameters in the function schema.
189193 """
190194
191195 def _create_function_tool (the_func : ToolFunction [...]) -> FunctionTool :
@@ -195,6 +199,7 @@ def _create_function_tool(the_func: ToolFunction[...]) -> FunctionTool:
195199 description_override = description_override ,
196200 docstring_style = docstring_style ,
197201 use_docstring_info = use_docstring_info ,
202+ strict_json_schema = strict_mode ,
198203 )
199204
200205 async def _on_invoke_tool_impl (ctx : RunContextWrapper [Any ], input : str ) -> str :
@@ -273,6 +278,7 @@ async def _on_invoke_tool(ctx: RunContextWrapper[Any], input: str) -> str:
273278 description = schema .description or "" ,
274279 params_json_schema = schema .params_json_schema ,
275280 on_invoke_tool = _on_invoke_tool ,
281+ strict_json_schema = strict_mode ,
276282 )
277283
278284 # If func is actually a callable, we were used as @function_tool with no parentheses
0 commit comments