55import pytest
66
77from agents import Agent , MaxTurnsExceeded , Runner
8+ from agents .items import TResponseOutputItem
89from agents .run import DEFAULT_MAX_TURNS
910
1011from .fake_model import FakeModel
@@ -22,7 +23,7 @@ async def test_runner_run_max_turns_none_defaults_to_constant():
2223
2324 # Prepare 11 turns (DEFAULT_MAX_TURNS is 10) to ensure exceeding default.
2425 func_output = json .dumps ({"a" : "b" })
25- turns : list [list [object ] ] = []
26+ turns : list [list [TResponseOutputItem ] | Exception ] = []
2627 for i in range (1 , DEFAULT_MAX_TURNS + 1 ):
2728 turns .append ([get_text_message (str (i )), get_function_tool_call ("tool" , func_output )])
2829 model .add_multiple_turn_outputs (turns )
@@ -44,12 +45,11 @@ async def test_agent_as_tool_forwards_max_turns():
4445
4546 # Make inner agent require more than 1 turn.
4647 func_output = json .dumps ({"x" : 1 })
47- inner_model .add_multiple_turn_outputs (
48- [
49- [get_text_message ("t1" ), get_function_tool_call ("some_function" , func_output )],
50- [get_text_message ("t2" ), get_function_tool_call ("some_function" , func_output )],
51- ]
52- )
48+ inner_turns : list [list [TResponseOutputItem ] | Exception ] = [
49+ [get_text_message ("t1" ), get_function_tool_call ("some_function" , func_output )],
50+ [get_text_message ("t2" ), get_function_tool_call ("some_function" , func_output )],
51+ ]
52+ inner_model .add_multiple_turn_outputs (inner_turns )
5353
5454 # Wrap inner agent as a tool with max_turns=1.
5555 wrapped_tool = inner_agent .as_tool (
@@ -68,11 +68,10 @@ async def test_agent_as_tool_forwards_max_turns():
6868
6969 # Outer model asks to call the tool once;
7070 # exceeding happens inside the tool call when inner runs.
71- outer_model .add_multiple_turn_outputs (
72- [
73- [get_function_tool_call ("inner_tool" )],
74- ]
75- )
71+ outer_turns : list [list [TResponseOutputItem ] | Exception ] = [
72+ [get_function_tool_call ("inner_tool" )],
73+ ]
74+ outer_model .add_multiple_turn_outputs (outer_turns )
7675
7776 # Since tool default error handling returns a string on error,
7877 # the run should not raise here.
0 commit comments