2222def test_gen_user_scenarios (client ):
2323 """Tests that generate_user_scenarios() correctly calls the API and parses the response."""
2424 eval_dataset = client .evals .generate_user_scenarios (
25- agents = {
26- "booking-agent" : types .evals .AgentConfig (
27- agent_id = "booking-agent" ,
28- agent_type = "service_agent" ,
29- description = "An agent capable of booking flights and hotels." ,
30- instruction = "You are a helpful travel assistant. Use tools to find flights." ,
31- tools = [
32- {
33- "function_declarations" : [
34- {
35- "name" : "search_flights" ,
36- "description" : "Search for available flights." ,
37- }
38- ]
39- }
40- ],
41- )
42- },
25+ agent_info = types .evals .AgentInfo (
26+ agents = {
27+ "booking-agent" : types .evals .AgentConfig (
28+ agent_id = "booking-agent" ,
29+ agent_type = "service_agent" ,
30+ description = "An agent capable of booking flights and hotels." ,
31+ instruction = "You are a helpful travel assistant. Use tools to find flights." ,
32+ tools = [
33+ {
34+ "function_declarations" : [
35+ {
36+ "name" : "search_flights" ,
37+ "description" : "Search for available flights." ,
38+ }
39+ ]
40+ }
41+ ],
42+ )
43+ },
44+ root_agent_id = "booking-agent" ,
45+ ),
4346 user_scenario_generation_config = types .evals .UserScenarioGenerationConfig (
4447 user_scenario_count = 2 ,
4548 simulation_instruction = (
@@ -49,18 +52,11 @@ def test_gen_user_scenarios(client):
4952 environment_data = "Today is Monday. Flights to Paris are available." ,
5053 model_name = "gemini-2.5-flash" ,
5154 ),
52- root_agent_id = "booking-agent" ,
5355 )
5456 assert isinstance (eval_dataset , types .EvaluationDataset )
5557 assert len (eval_dataset .eval_cases ) == 2
56- assert (
57- eval_dataset .eval_cases [0 ].user_scenario .starting_prompt
58- == "I want to find a flight from New York to London."
59- )
60- assert (
61- eval_dataset .eval_cases [0 ].user_scenario .conversation_plan
62- == "Actually, I meant Paris, not London. Please search for flights to Paris."
63- )
58+ assert eval_dataset .eval_cases [0 ].user_scenario .starting_prompt
59+ assert eval_dataset .eval_cases [0 ].user_scenario .conversation_plan
6460
6561
6662pytest_plugins = ("pytest_asyncio" ,)
@@ -70,24 +66,27 @@ def test_gen_user_scenarios(client):
7066async def test_gen_user_scenarios_async (client ):
7167 """Tests that generate_user_scenarios() async correctly calls the API and parses the response."""
7268 eval_dataset = await client .aio .evals .generate_user_scenarios (
73- agents = {
74- "booking-agent" : types .evals .AgentConfig (
75- agent_id = "booking-agent" ,
76- agent_type = "service_agent" ,
77- description = "An agent capable of booking flights and hotels." ,
78- instruction = "You are a helpful travel assistant. Use tools to find flights." ,
79- tools = [
80- {
81- "function_declarations" : [
82- {
83- "name" : "search_flights" ,
84- "description" : "Search for available flights." ,
85- }
86- ]
87- }
88- ],
89- )
90- },
69+ agent_info = types .evals .AgentInfo (
70+ agents = {
71+ "booking-agent" : types .evals .AgentConfig (
72+ agent_id = "booking-agent" ,
73+ agent_type = "service_agent" ,
74+ description = "An agent capable of booking flights and hotels." ,
75+ instruction = "You are a helpful travel assistant. Use tools to find flights." ,
76+ tools = [
77+ {
78+ "function_declarations" : [
79+ {
80+ "name" : "search_flights" ,
81+ "description" : "Search for available flights." ,
82+ }
83+ ]
84+ }
85+ ],
86+ )
87+ },
88+ root_agent_id = "booking-agent" ,
89+ ),
9190 user_scenario_generation_config = types .evals .UserScenarioGenerationConfig (
9291 user_scenario_count = 2 ,
9392 simulation_instruction = (
@@ -97,18 +96,11 @@ async def test_gen_user_scenarios_async(client):
9796 environment_data = "Today is Monday. Flights to Paris are available." ,
9897 model_name = "gemini-2.5-flash" ,
9998 ),
100- root_agent_id = "booking-agent" ,
10199 )
102100 assert isinstance (eval_dataset , types .EvaluationDataset )
103101 assert len (eval_dataset .eval_cases ) == 2
104- assert (
105- eval_dataset .eval_cases [1 ].user_scenario .starting_prompt
106- == "Find me a flight from Boston to Rome for next month."
107- )
108- assert (
109- eval_dataset .eval_cases [1 ].user_scenario .conversation_plan
110- == "Wait, change of plans. I need to go to Milan instead, and it needs to be a round trip, returning two weeks after departure."
111- )
102+ assert eval_dataset .eval_cases [1 ].user_scenario .starting_prompt
103+ assert eval_dataset .eval_cases [1 ].user_scenario .conversation_plan
112104
113105
114106pytestmark = pytest_helper .setup (
0 commit comments