@@ -893,51 +893,6 @@ async def test_thinking_part_in_history(allow_model_requests: None):
893893 )
894894
895895
896- @pytest .mark .parametrize ('strict' , [True , False , None ])
897- async def test_tool_strict_mode (allow_model_requests : None , strict : bool | None ):
898- tool_call = ChatCompletionOutputToolCall .parse_obj_as_instance ( # type:ignore
899- {
900- 'function' : ChatCompletionOutputFunctionDefinition .parse_obj_as_instance ( # type:ignore
901- {
902- 'name' : 'my_tool' ,
903- 'arguments' : '{"x": 42}' ,
904- }
905- ),
906- 'id' : '1' ,
907- 'type' : 'function' ,
908- }
909- )
910- responses = [
911- completion_message (
912- ChatCompletionOutputMessage .parse_obj_as_instance ( # type:ignore
913- {
914- 'content' : None ,
915- 'role' : 'assistant' ,
916- 'tool_calls' : [tool_call ],
917- }
918- )
919- ),
920- completion_message (ChatCompletionOutputMessage (content = 'final response' , role = 'assistant' )), # type: ignore
921- ]
922- mock_client = MockHuggingFace .create_mock (responses )
923- model = HuggingFaceModel ('hf-model' , provider = HuggingFaceProvider (hf_client = mock_client , api_key = 'x' ))
924- agent = Agent (model )
925-
926- @agent .tool_plain (strict = strict )
927- def my_tool (x : int ) -> int :
928- return x
929-
930- result = await agent .run ('hello' )
931- assert result .output == 'final response'
932-
933- kwargs = get_mock_chat_completion_kwargs (mock_client )[0 ]
934- tools = kwargs ['tools' ]
935- if strict is not None :
936- assert tools [0 ]['function' ]['strict' ] is strict
937- else :
938- assert 'strict' not in tools [0 ]['function' ]
939-
940-
941896@pytest .mark .parametrize (
942897 'content_item, error_message' ,
943898 [
0 commit comments