@@ -57,16 +57,22 @@ def make_message(
5757
5858def test_extract_last_content_of_text_message () -> None :
5959 # Build a message containing two text segments.
60- content1 = ResponseOutputText (annotations = [], text = "Hello " , type = "output_text" )
61- content2 = ResponseOutputText (annotations = [], text = "world!" , type = "output_text" )
60+ content1 = ResponseOutputText (
61+ annotations = [], text = "Hello " , type = "output_text" , logprobs = []
62+ )
63+ content2 = ResponseOutputText (
64+ annotations = [], text = "world!" , type = "output_text" , logprobs = []
65+ )
6266 message = make_message ([content1 , content2 ])
6367 # Helpers should yield the last segment's text.
6468 assert ItemHelpers .extract_last_content (message ) == "world!"
6569
6670
6771def test_extract_last_content_of_refusal_message () -> None :
6872 # Build a message whose last content entry is a refusal.
69- content1 = ResponseOutputText (annotations = [], text = "Before refusal" , type = "output_text" )
73+ content1 = ResponseOutputText (
74+ annotations = [], text = "Before refusal" , type = "output_text" , logprobs = []
75+ )
7076 refusal = ResponseOutputRefusal (refusal = "I cannot do that" , type = "refusal" )
7177 message = make_message ([content1 , refusal ])
7278 # Helpers should extract the refusal string when last content is a refusal.
@@ -87,8 +93,12 @@ def test_extract_last_content_non_message_returns_empty() -> None:
8793
8894def test_extract_last_text_returns_text_only () -> None :
8995 # A message whose last segment is text yields the text.
90- first_text = ResponseOutputText (annotations = [], text = "part1" , type = "output_text" )
91- second_text = ResponseOutputText (annotations = [], text = "part2" , type = "output_text" )
96+ first_text = ResponseOutputText (
97+ annotations = [], text = "part1" , type = "output_text" , logprobs = []
98+ )
99+ second_text = ResponseOutputText (
100+ annotations = [], text = "part2" , type = "output_text" , logprobs = []
101+ )
92102 message = make_message ([first_text , second_text ])
93103 assert ItemHelpers .extract_last_text (message ) == "part2"
94104 # Whereas when last content is a refusal, extract_last_text returns None.
@@ -116,9 +126,13 @@ def test_input_to_new_input_list_deep_copies_lists() -> None:
116126def test_text_message_output_concatenates_text_segments () -> None :
117127 # Build a message with both text and refusal segments, only text segments are concatenated.
118128 pieces : list [ResponseOutputText | ResponseOutputRefusal ] = []
119- pieces .append (ResponseOutputText (annotations = [], text = "a" , type = "output_text" ))
129+ pieces .append (
130+ ResponseOutputText (annotations = [], text = "a" , type = "output_text" , logprobs = [])
131+ )
120132 pieces .append (ResponseOutputRefusal (refusal = "denied" , type = "refusal" ))
121- pieces .append (ResponseOutputText (annotations = [], text = "b" , type = "output_text" ))
133+ pieces .append (
134+ ResponseOutputText (annotations = [], text = "b" , type = "output_text" , logprobs = [])
135+ )
122136 message = make_message (pieces )
123137 # Wrap into MessageOutputItem to feed into text_message_output.
124138 item = MessageOutputItem (agent = Agent (name = "test" ), raw_item = message )
@@ -131,8 +145,12 @@ def test_text_message_outputs_across_list_of_runitems() -> None:
131145 that only MessageOutputItem instances contribute any text. The non-message
132146 (ReasoningItem) should be ignored by Helpers.text_message_outputs.
133147 """
134- message1 = make_message ([ResponseOutputText (annotations = [], text = "foo" , type = "output_text" )])
135- message2 = make_message ([ResponseOutputText (annotations = [], text = "bar" , type = "output_text" )])
148+ message1 = make_message (
149+ [ResponseOutputText (annotations = [], text = "foo" , type = "output_text" , logprobs = [])]
150+ )
151+ message2 = make_message (
152+ [ResponseOutputText (annotations = [], text = "bar" , type = "output_text" , logprobs = [])]
153+ )
136154 item1 : RunItem = MessageOutputItem (agent = Agent (name = "test" ), raw_item = message1 )
137155 item2 : RunItem = MessageOutputItem (agent = Agent (name = "test" ), raw_item = message2 )
138156 # Create a non-message run item of a different type, e.g., a reasoning trace.
@@ -171,7 +189,9 @@ def test_tool_call_output_item_constructs_function_call_output_dict():
171189
172190def test_to_input_items_for_message () -> None :
173191 """An output message should convert into an input dict matching the message's own structure."""
174- content = ResponseOutputText (annotations = [], text = "hello world" , type = "output_text" )
192+ content = ResponseOutputText (
193+ annotations = [], text = "hello world" , type = "output_text" , logprobs = []
194+ )
175195 message = ResponseOutputMessage (
176196 id = "m1" , content = [content ], role = "assistant" , status = "completed" , type = "message"
177197 )
@@ -184,6 +204,7 @@ def test_to_input_items_for_message() -> None:
184204 "content" : [
185205 {
186206 "annotations" : [],
207+ "logprobs" : [],
187208 "text" : "hello world" ,
188209 "type" : "output_text" ,
189210 }
0 commit comments