@@ -66,7 +66,7 @@ def sample_tool_request():
6666 name = "get_weather" ,
6767 description = "Get the current weather in a location" ,
6868 parameters = FunctionParameters (
69- RootModel = {
69+ {
7070 "type" : "object" ,
7171 "properties" : {
7272 "location" : {
@@ -228,6 +228,66 @@ async def test_tool_choice_passed_to_model_options(
228228 assert ModelOption .TOOL_CHOICE in model_options
229229 assert model_options [ModelOption .TOOL_CHOICE ] == "auto"
230230
231+ @pytest .mark .asyncio
232+ async def test_standard_json_schema_tools_passed_to_model_options (
233+ self , mock_module
234+ ):
235+ """Test that standard OpenAI function.parameters shape is preserved."""
236+ request = ChatCompletionRequest (
237+ model = "test-model" ,
238+ messages = [ChatMessage (role = "user" , content = "What's the weather in Paris?" )],
239+ tools = [
240+ ToolFunction (
241+ type = "function" ,
242+ function = FunctionDefinition (
243+ name = "get_weather" ,
244+ description = "Get the current weather in a location" ,
245+ parameters = FunctionParameters (
246+ {
247+ "type" : "object" ,
248+ "properties" : {
249+ "location" : {
250+ "type" : "string" ,
251+ "description" : "The city name" ,
252+ },
253+ "units" : {
254+ "type" : "string" ,
255+ "enum" : ["celsius" , "fahrenheit" ],
256+ "description" : "Temperature units" ,
257+ },
258+ },
259+ "required" : ["location" ],
260+ }
261+ ),
262+ ),
263+ )
264+ ],
265+ tool_choice = {"type" : "function" , "function" : {"name" : "get_weather" }},
266+ )
267+ mock_output = ModelOutputThunk ("Test response" )
268+ mock_module .serve .return_value = mock_output
269+
270+ endpoint = make_chat_endpoint (mock_module )
271+ await endpoint (request )
272+
273+ call_args = mock_module .serve .call_args
274+ assert call_args is not None
275+ model_options = call_args .kwargs ["model_options" ]
276+ assert ModelOption .TOOLS in model_options
277+
278+ tool_payload = model_options [ModelOption .TOOLS ][0 ]
279+ assert tool_payload ["function" ]["name" ] == "get_weather"
280+ assert tool_payload ["function" ]["parameters" ]["type" ] == "object"
281+ assert (
282+ tool_payload ["function" ]["parameters" ]["properties" ]["location" ]["type" ]
283+ == "string"
284+ )
285+ assert tool_payload ["function" ]["parameters" ]["required" ] == ["location" ]
286+ assert model_options [ModelOption .TOOL_CHOICE ] == {
287+ "type" : "function" ,
288+ "function" : {"name" : "get_weather" },
289+ }
290+
231291 @pytest .mark .asyncio
232292 async def test_tool_calls_with_complex_arguments (
233293 self , mock_module , sample_tool_request
0 commit comments