@@ -57,12 +57,8 @@ def make_message(
5757
5858def test_extract_last_content_of_text_message () -> None :
5959 # Build a message containing two text segments.
60- content1 = ResponseOutputText (
61- annotations = [], text = "Hello " , type = "output_text" , logprobs = []
62- )
63- content2 = ResponseOutputText (
64- annotations = [], text = "world!" , type = "output_text" , logprobs = []
65- )
60+ content1 = ResponseOutputText (annotations = [], text = "Hello " , type = "output_text" , logprobs = [])
61+ content2 = ResponseOutputText (annotations = [], text = "world!" , type = "output_text" , logprobs = [])
6662 message = make_message ([content1 , content2 ])
6763 # Helpers should yield the last segment's text.
6864 assert ItemHelpers .extract_last_content (message ) == "world!"
@@ -93,12 +89,8 @@ def test_extract_last_content_non_message_returns_empty() -> None:
9389
9490def test_extract_last_text_returns_text_only () -> None :
9591 # A message whose last segment is text yields the 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- )
92+ first_text = ResponseOutputText (annotations = [], text = "part1" , type = "output_text" , logprobs = [])
93+ second_text = ResponseOutputText (annotations = [], text = "part2" , type = "output_text" , logprobs = [])
10294 message = make_message ([first_text , second_text ])
10395 assert ItemHelpers .extract_last_text (message ) == "part2"
10496 # Whereas when last content is a refusal, extract_last_text returns None.
@@ -126,13 +118,9 @@ def test_input_to_new_input_list_deep_copies_lists() -> None:
126118def test_text_message_output_concatenates_text_segments () -> None :
127119 # Build a message with both text and refusal segments, only text segments are concatenated.
128120 pieces : list [ResponseOutputText | ResponseOutputRefusal ] = []
129- pieces .append (
130- ResponseOutputText (annotations = [], text = "a" , type = "output_text" , logprobs = [])
131- )
121+ pieces .append (ResponseOutputText (annotations = [], text = "a" , type = "output_text" , logprobs = []))
132122 pieces .append (ResponseOutputRefusal (refusal = "denied" , type = "refusal" ))
133- pieces .append (
134- ResponseOutputText (annotations = [], text = "b" , type = "output_text" , logprobs = [])
135- )
123+ pieces .append (ResponseOutputText (annotations = [], text = "b" , type = "output_text" , logprobs = []))
136124 message = make_message (pieces )
137125 # Wrap into MessageOutputItem to feed into text_message_output.
138126 item = MessageOutputItem (agent = Agent (name = "test" ), raw_item = message )
@@ -321,14 +309,14 @@ def test_input_to_new_input_list_copies_the_ones_produced_by_pydantic() -> None:
321309 # Given a list of message dictionaries, ensure the returned list is a deep copy.
322310 original = ResponseOutputMessageParam (
323311 id = "a75654dc-7492-4d1c-bce0-89e8312fbdd7" ,
324- content = [
325- ResponseOutputTextParam (
326- type = "output_text" ,
327- text = "Hey, what's up?" ,
328- annotations = [],
329- logprobs = [],
330- )
331- ],
312+ content = [
313+ ResponseOutputTextParam (
314+ type = "output_text" ,
315+ text = "Hey, what's up?" ,
316+ annotations = [],
317+ logprobs = [],
318+ )
319+ ],
332320 role = "assistant" ,
333321 status = "completed" ,
334322 type = "message" ,
0 commit comments