11from openai .types .responses import ResponseOutputMessage , ResponseOutputText
22
3- from agents import Agent , HandoffInputData
3+ from agents import Agent , HandoffInputData , RunContextWrapper
44from agents .extensions .handoff_filters import remove_all_tools
55from agents .items import (
66 HandoffOutputItem ,
@@ -78,13 +78,23 @@ def _get_handoff_output_run_item(content: str) -> HandoffOutputItem:
7878
7979
8080def test_empty_data ():
81- handoff_input_data = HandoffInputData (input_history = (), pre_handoff_items = (), new_items = ())
81+ handoff_input_data = HandoffInputData (
82+ input_history = (),
83+ pre_handoff_items = (),
84+ new_items = (),
85+ run_context = RunContextWrapper (context = ()),
86+ )
8287 filtered_data = remove_all_tools (handoff_input_data )
8388 assert filtered_data == handoff_input_data
8489
8590
8691def test_str_historyonly ():
87- handoff_input_data = HandoffInputData (input_history = "Hello" , pre_handoff_items = (), new_items = ())
92+ handoff_input_data = HandoffInputData (
93+ input_history = "Hello" ,
94+ pre_handoff_items = (),
95+ new_items = (),
96+ run_context = RunContextWrapper (context = ()),
97+ )
8898 filtered_data = remove_all_tools (handoff_input_data )
8999 assert filtered_data == handoff_input_data
90100
@@ -94,6 +104,7 @@ def test_str_history_and_list():
94104 input_history = "Hello" ,
95105 pre_handoff_items = (),
96106 new_items = (_get_message_output_run_item ("Hello" ),),
107+ run_context = RunContextWrapper (context = ()),
97108 )
98109 filtered_data = remove_all_tools (handoff_input_data )
99110 assert filtered_data == handoff_input_data
@@ -104,6 +115,7 @@ def test_list_history_and_list():
104115 input_history = (_get_message_input_item ("Hello" ),),
105116 pre_handoff_items = (_get_message_output_run_item ("123" ),),
106117 new_items = (_get_message_output_run_item ("World" ),),
118+ run_context = RunContextWrapper (context = ()),
107119 )
108120 filtered_data = remove_all_tools (handoff_input_data )
109121 assert filtered_data == handoff_input_data
@@ -121,6 +133,7 @@ def test_removes_tools_from_history():
121133 _get_message_output_run_item ("123" ),
122134 ),
123135 new_items = (_get_message_output_run_item ("World" ),),
136+ run_context = RunContextWrapper (context = ()),
124137 )
125138 filtered_data = remove_all_tools (handoff_input_data )
126139 assert len (filtered_data .input_history ) == 2
@@ -136,6 +149,7 @@ def test_removes_tools_from_new_items():
136149 _get_message_output_run_item ("Hello" ),
137150 _get_tool_output_run_item ("World" ),
138151 ),
152+ run_context = RunContextWrapper (context = ()),
139153 )
140154 filtered_data = remove_all_tools (handoff_input_data )
141155 assert len (filtered_data .input_history ) == 0
@@ -158,6 +172,7 @@ def test_removes_tools_from_new_items_and_history():
158172 _get_message_output_run_item ("Hello" ),
159173 _get_tool_output_run_item ("World" ),
160174 ),
175+ run_context = RunContextWrapper (context = ()),
161176 )
162177 filtered_data = remove_all_tools (handoff_input_data )
163178 assert len (filtered_data .input_history ) == 2
@@ -181,6 +196,7 @@ def test_removes_handoffs_from_history():
181196 _get_tool_output_run_item ("World" ),
182197 _get_handoff_output_run_item ("World" ),
183198 ),
199+ run_context = RunContextWrapper (context = ()),
184200 )
185201 filtered_data = remove_all_tools (handoff_input_data )
186202 assert len (filtered_data .input_history ) == 1
0 commit comments