@@ -138,24 +138,16 @@ def test_stream_preserves_single_pass_tools(client: OpenAI, respx2_mock: MockRou
138138 assert_request_and_parsed_tool (respx2_mock , tool_calls [0 ].function .parsed_arguments )
139139
140140
141- @pytest .mark .respx2 (base_url = base_url )
142- def test_stream_preserves_non_strict_single_pass_tools (client : OpenAI , respx2_mock : MockRouter ) -> None :
143- respx2_mock .post ("/chat/completions" ).mock (
144- return_value = httpx2 .Response (200 , text = STREAM_RESPONSE , headers = {"content-type" : "text/event-stream" })
145- )
146-
147- with client .chat .completions .stream (
148- model = "gpt-test" ,
149- messages = [{"role" : "user" , "content" : "weather" }],
150- tools = non_strict_tools (),
151- ) as stream :
152- completion = stream .get_final_completion ()
153-
154- tool_calls = completion .choices [0 ].message .tool_calls
155- assert tool_calls is not None
156- body = json .loads (cast ("list[MockRequestCall]" , respx2_mock .calls )[0 ].request .content )
157- assert body ["tools" ] == list (non_strict_tools ())
158- assert tool_calls [0 ].function .parsed_arguments is None
141+ def test_stream_rejects_non_strict_single_pass_tools (client : OpenAI ) -> None :
142+ with pytest .raises (
143+ ValueError ,
144+ match = r"`get_weather` is not strict\. Only `strict` function tools can be auto-parsed" ,
145+ ):
146+ client .chat .completions .stream (
147+ model = "gpt-test" ,
148+ messages = [{"role" : "user" , "content" : "weather" }],
149+ tools = non_strict_tools (),
150+ )
159151
160152
161153@pytest .mark .respx2 (base_url = base_url )
0 commit comments