@@ -719,7 +719,75 @@ def test_function_google_search(client):
719719 # bad request to combine function call and google search retrieval
720720 with pytest .raises (errors .ClientError ):
721721 client .models .generate_content (
722- model = 'gemini-2.5-flash' ,
722+ model = 'gemini-3.5-flash' ,
723+ contents = contents ,
724+ config = config ,
725+ )
726+
727+
728+ def test_function_google_search_server_side_tool_invocations (client ):
729+ contents = (
730+ 'What is the weather in Buenos Aires? If it is raining, schedule a'
731+ ' meeting.'
732+ )
733+ schedule_meeting = {
734+ 'name' : 'schedule_meeting' ,
735+ 'description' : 'Schedule a meeting' ,
736+ 'parameters' : {
737+ 'type' : 'object' ,
738+ 'properties' : {'reason' : {'type' : 'string' }},
739+ 'required' : ['reason' ],
740+ },
741+ }
742+ config = types .GenerateContentConfig (
743+ tools = [
744+ types .Tool (
745+ google_search = types .GoogleSearch (),
746+ ),
747+ types .Tool (
748+ function_declarations = [schedule_meeting ],
749+ ),
750+ ],
751+ tool_config = types .ToolConfig (
752+ include_server_side_tool_invocations = True ,
753+ ),
754+ )
755+ with pytest_helper .exception_if_vertex (client , ValueError ):
756+ client .models .generate_content (
757+ model = 'gemini-3.5-flash' ,
758+ contents = contents ,
759+ config = config ,
760+ )
761+
762+
763+ def test_function_google_search_server_side_tool_invocations_one_tool (client ):
764+ contents = (
765+ 'What is the weather in Buenos Aires? If it is raining, schedule a'
766+ ' meeting.'
767+ )
768+ schedule_meeting = {
769+ 'name' : 'schedule_meeting' ,
770+ 'description' : 'Schedule a meeting' ,
771+ 'parameters' : {
772+ 'type' : 'object' ,
773+ 'properties' : {'reason' : {'type' : 'string' }},
774+ 'required' : ['reason' ],
775+ },
776+ }
777+ config = types .GenerateContentConfig (
778+ tools = [
779+ types .Tool (
780+ google_search = types .GoogleSearch (),
781+ function_declarations = [schedule_meeting ],
782+ ),
783+ ],
784+ tool_config = types .ToolConfig (
785+ include_server_side_tool_invocations = True ,
786+ ),
787+ )
788+ with pytest_helper .exception_if_vertex (client , ValueError ):
789+ client .models .generate_content (
790+ model = 'gemini-3.5-flash' ,
723791 contents = contents ,
724792 config = config ,
725793 )
0 commit comments