1
1
from openai .types .responses import ResponseOutputMessage , ResponseOutputText
2
2
3
- from agents import Agent , HandoffInputData
3
+ from agents import Agent , HandoffInputData , RunContextWrapper
4
4
from agents .extensions .handoff_filters import remove_all_tools
5
5
from agents .items import (
6
6
HandoffOutputItem ,
@@ -78,13 +78,23 @@ def _get_handoff_output_run_item(content: str) -> HandoffOutputItem:
78
78
79
79
80
80
def 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
+ )
82
87
filtered_data = remove_all_tools (handoff_input_data )
83
88
assert filtered_data == handoff_input_data
84
89
85
90
86
91
def 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
+ )
88
98
filtered_data = remove_all_tools (handoff_input_data )
89
99
assert filtered_data == handoff_input_data
90
100
@@ -94,6 +104,7 @@ def test_str_history_and_list():
94
104
input_history = "Hello" ,
95
105
pre_handoff_items = (),
96
106
new_items = (_get_message_output_run_item ("Hello" ),),
107
+ run_context = RunContextWrapper (context = ()),
97
108
)
98
109
filtered_data = remove_all_tools (handoff_input_data )
99
110
assert filtered_data == handoff_input_data
@@ -104,6 +115,7 @@ def test_list_history_and_list():
104
115
input_history = (_get_message_input_item ("Hello" ),),
105
116
pre_handoff_items = (_get_message_output_run_item ("123" ),),
106
117
new_items = (_get_message_output_run_item ("World" ),),
118
+ run_context = RunContextWrapper (context = ()),
107
119
)
108
120
filtered_data = remove_all_tools (handoff_input_data )
109
121
assert filtered_data == handoff_input_data
@@ -121,6 +133,7 @@ def test_removes_tools_from_history():
121
133
_get_message_output_run_item ("123" ),
122
134
),
123
135
new_items = (_get_message_output_run_item ("World" ),),
136
+ run_context = RunContextWrapper (context = ()),
124
137
)
125
138
filtered_data = remove_all_tools (handoff_input_data )
126
139
assert len (filtered_data .input_history ) == 2
@@ -136,6 +149,7 @@ def test_removes_tools_from_new_items():
136
149
_get_message_output_run_item ("Hello" ),
137
150
_get_tool_output_run_item ("World" ),
138
151
),
152
+ run_context = RunContextWrapper (context = ()),
139
153
)
140
154
filtered_data = remove_all_tools (handoff_input_data )
141
155
assert len (filtered_data .input_history ) == 0
@@ -158,6 +172,7 @@ def test_removes_tools_from_new_items_and_history():
158
172
_get_message_output_run_item ("Hello" ),
159
173
_get_tool_output_run_item ("World" ),
160
174
),
175
+ run_context = RunContextWrapper (context = ()),
161
176
)
162
177
filtered_data = remove_all_tools (handoff_input_data )
163
178
assert len (filtered_data .input_history ) == 2
@@ -181,6 +196,7 @@ def test_removes_handoffs_from_history():
181
196
_get_tool_output_run_item ("World" ),
182
197
_get_handoff_output_run_item ("World" ),
183
198
),
199
+ run_context = RunContextWrapper (context = ()),
184
200
)
185
201
filtered_data = remove_all_tools (handoff_input_data )
186
202
assert len (filtered_data .input_history ) == 1
0 commit comments