@@ -110,9 +110,9 @@ def test_agent_span_reconstructs_messages(self, setup_tracer_with_handler):
110110 provider .force_flush ()
111111
112112 # Verify that messages were cached (indicating reconstruction happened)
113- assert (
114- span_id in processor . _message_cache
115- ), "Messages should be cached for agent span"
113+ assert span_id in processor . _message_cache , (
114+ "Messages should be cached for agent span"
115+ )
116116
117117 cached_input , cached_output = processor ._message_cache [span_id ]
118118
@@ -122,31 +122,31 @@ def test_agent_span_reconstructs_messages(self, setup_tracer_with_handler):
122122
123123 # Verify input message format
124124 input_msg = cached_input [0 ]
125- assert isinstance (
126- input_msg , InputMessage
127- ), "Should be InputMessage object"
125+ assert isinstance (input_msg , InputMessage ), (
126+ "Should be InputMessage object"
127+ )
128128 assert input_msg .role == "user" , "Should have user role"
129129 assert len (input_msg .parts ) == 1 , "Should have 1 part"
130- assert isinstance (
131- input_msg . parts [ 0 ], Text
132- ), "Part should be Text object"
133- assert (
134- input_msg . parts [ 0 ]. content == "Plan a trip to Paris "
135- ), "Input content should match"
130+ assert isinstance (input_msg . parts [ 0 ], Text ), (
131+ "Part should be Text object"
132+ )
133+ assert input_msg . parts [ 0 ]. content == "Plan a trip to Paris" , (
134+ "Input content should match "
135+ )
136136
137137 # Verify output message format
138138 output_msg = cached_output [0 ]
139- assert isinstance (
140- output_msg , OutputMessage
141- ), "Should be OutputMessage object"
139+ assert isinstance (output_msg , OutputMessage ), (
140+ "Should be OutputMessage object"
141+ )
142142 assert output_msg .role == "assistant" , "Should have assistant role"
143143 assert len (output_msg .parts ) == 1 , "Should have 1 part"
144- assert isinstance (
145- output_msg . parts [ 0 ], Text
146- ), "Part should be Text object"
147- assert (
148- "Paris" in output_msg . parts [ 0 ]. content
149- ), "Output should mention Paris"
144+ assert isinstance (output_msg . parts [ 0 ], Text ), (
145+ "Part should be Text object"
146+ )
147+ assert "Paris" in output_msg . parts [ 0 ]. content , (
148+ "Output should mention Paris"
149+ )
150150
151151 def test_agent_span_has_genai_attributes (self , setup_tracer_with_handler ):
152152 """Test that agent spans get gen_ai.input.messages and gen_ai.output.messages."""
@@ -176,18 +176,18 @@ def test_agent_span_has_genai_attributes(self, setup_tracer_with_handler):
176176 assert agent_span .attributes is not None , "Span should have attributes"
177177
178178 # Verify gen_ai attributes are present
179- assert (
180- "gen_ai.input.messages" in agent_span . attributes
181- ), "Should have gen_ai.input.messages"
182- assert (
183- "gen_ai.output.messages" in agent_span . attributes
184- ), "Should have gen_ai.output.messages"
185- assert (
186- "gen_ai.span.kind" in agent_span . attributes
187- ), "Should have gen_ai.span.kind"
188- assert (
189- agent_span . attributes [ "gen_ai.span.kind" ] == " agent"
190- ), "Should preserve agent kind"
179+ assert "gen_ai.input.messages" in agent_span . attributes , (
180+ "Should have gen_ai.input.messages"
181+ )
182+ assert "gen_ai.output.messages" in agent_span . attributes , (
183+ "Should have gen_ai.output.messages"
184+ )
185+ assert "gen_ai.span.kind" in agent_span . attributes , (
186+ "Should have gen_ai.span.kind"
187+ )
188+ assert agent_span . attributes [ "gen_ai.span.kind" ] == "agent" , (
189+ "Should preserve agent kind "
190+ )
191191
192192
193193class TestTaskMessageReconstruction :
@@ -232,9 +232,9 @@ def test_task_span_reconstructs_messages(self, setup_tracer_with_handler):
232232 provider .force_flush ()
233233
234234 # Verify that messages were cached (indicating reconstruction happened)
235- assert (
236- span_id in processor . _message_cache
237- ), "Messages should be cached for task span"
235+ assert span_id in processor . _message_cache , (
236+ "Messages should be cached for task span"
237+ )
238238
239239 cached_input , cached_output = processor ._message_cache [span_id ]
240240
@@ -247,9 +247,9 @@ def test_task_span_reconstructs_messages(self, setup_tracer_with_handler):
247247 cached_input [0 ].parts [0 ].content
248248 == "Search for flights from Seattle to Paris"
249249 ), "Input should match"
250- assert (
251- "5 flights" in cached_output [ 0 ]. parts [ 0 ]. content
252- ), "Output should mention flights"
250+ assert "5 flights" in cached_output [ 0 ]. parts [ 0 ]. content , (
251+ "Output should mention flights"
252+ )
253253
254254 def test_task_span_without_messages_skips_reconstruction (
255255 self , setup_tracer_with_handler
@@ -267,9 +267,9 @@ def test_task_span_without_messages_skips_reconstruction(
267267 provider .force_flush ()
268268
269269 # Should not crash, and span_id should NOT be in cache
270- assert (
271- span_id not in processor . _message_cache
272- ), "Empty task should not be cached"
270+ assert span_id not in processor . _message_cache , (
271+ "Empty task should not be cached"
272+ )
273273
274274
275275class TestLLMOperationMessageReconstruction :
@@ -298,9 +298,9 @@ def test_chat_operation_reconstructs_messages(
298298 provider .force_flush ()
299299
300300 # Verify messages were cached
301- assert (
302- span_id in processor . _message_cache
303- ), "Messages should be cached for chat operation"
301+ assert span_id in processor . _message_cache , (
302+ "Messages should be cached for chat operation"
303+ )
304304
305305 cached_input , cached_output = processor ._message_cache [span_id ]
306306 assert len (cached_input ) == 1 , "Should have 1 input message"
@@ -328,9 +328,9 @@ def test_completion_operation_reconstructs_messages(
328328
329329 provider .force_flush ()
330330
331- assert (
332- span_id in processor . _message_cache
333- ), "Messages should be cached for completion operation"
331+ assert span_id in processor . _message_cache , (
332+ "Messages should be cached for completion operation"
333+ )
334334
335335
336336class TestNonLLMSpanSkipsReconstruction :
@@ -351,9 +351,9 @@ def test_workflow_span_skips_reconstruction(
351351 provider .force_flush ()
352352
353353 # Workflow spans should NOT trigger message reconstruction
354- assert (
355- span_id not in processor . _message_cache
356- ), "Workflow spans should not cache messages"
354+ assert span_id not in processor . _message_cache , (
355+ "Workflow spans should not cache messages"
356+ )
357357
358358 def test_tool_span_skips_reconstruction (self , setup_tracer_with_handler ):
359359 """Test that tool spans skip message reconstruction."""
@@ -367,9 +367,9 @@ def test_tool_span_skips_reconstruction(self, setup_tracer_with_handler):
367367 provider .force_flush ()
368368
369369 # Tool spans should NOT trigger message reconstruction
370- assert (
371- span_id not in processor . _message_cache
372- ), "Tool spans should not cache messages"
370+ assert span_id not in processor . _message_cache , (
371+ "Tool spans should not cache messages"
372+ )
373373
374374 def test_unknown_span_skips_reconstruction (
375375 self , setup_tracer_with_handler
@@ -384,9 +384,9 @@ def test_unknown_span_skips_reconstruction(
384384 provider .force_flush ()
385385
386386 # Random spans should NOT trigger message reconstruction
387- assert (
388- span_id not in processor . _message_cache
389- ), "Unknown spans should not cache messages"
387+ assert span_id not in processor . _message_cache , (
388+ "Unknown spans should not cache messages"
389+ )
390390
391391
392392class TestEdgeCases :
@@ -407,9 +407,9 @@ def test_agent_with_malformed_json(self, setup_tracer_with_handler):
407407 provider .force_flush ()
408408
409409 # Malformed data should not be cached
410- assert (
411- span_id not in processor . _message_cache
412- ), "Malformed JSON should not be cached"
410+ assert span_id not in processor . _message_cache , (
411+ "Malformed JSON should not be cached"
412+ )
413413
414414 def test_task_with_empty_messages (self , setup_tracer_with_handler ):
415415 """Test that task with empty message arrays is handled."""
@@ -431,12 +431,12 @@ def test_task_with_empty_messages(self, setup_tracer_with_handler):
431431 # Empty messages should still be cached (as empty lists)
432432 if span_id in processor ._message_cache :
433433 cached_input , cached_output = processor ._message_cache [span_id ]
434- assert (
435- cached_input == []
436- ), "Empty input should be cached as empty list"
437- assert (
438- cached_output == []
439- ), "Empty output should be cached as empty list"
434+ assert cached_input == [], (
435+ "Empty input should be cached as empty list"
436+ )
437+ assert cached_output == [], (
438+ "Empty output should be cached as empty list"
439+ )
440440
441441 def test_mixed_span_kinds (self , setup_tracer_with_handler ):
442442 """Test different span kinds in same workflow."""
@@ -473,15 +473,15 @@ def test_mixed_span_kinds(self, setup_tracer_with_handler):
473473 provider .force_flush ()
474474
475475 # Verify caching behavior
476- assert (
477- span_ids [ "agent" ] in processor . _message_cache
478- ), "Agent span should cache messages"
479- assert (
480- span_ids [ "task" ] in processor . _message_cache
481- ), "Task span should cache messages"
482- assert (
483- span_ids [ "workflow" ] not in processor . _message_cache
484- ), "Workflow span should not cache messages"
476+ assert span_ids [ "agent" ] in processor . _message_cache , (
477+ "Agent span should cache messages"
478+ )
479+ assert span_ids [ "task" ] in processor . _message_cache , (
480+ "Task span should cache messages"
481+ )
482+ assert span_ids [ "workflow" ] not in processor . _message_cache , (
483+ "Workflow span should not cache messages"
484+ )
485485
486486
487487if __name__ == "__main__" :
0 commit comments