@@ -204,9 +204,7 @@ async def test_agent_invocation_span_no_pii(
204204 span for span in spans if span ["attributes" ]["sentry.op" ] == OP .GEN_AI_CHAT
205205 )
206206
207- transactions = [item .payload for item in items if item .type == "transaction" ]
208- assert len (transactions ) == 1
209- transaction = transactions [0 ]
207+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
210208 assert transaction ["transaction" ] == "test_agent workflow"
211209 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
212210
@@ -354,9 +352,7 @@ async def test_agent_invocation_span(
354352 assert result is not None
355353 assert result .final_output == "Hello, how can I help you?"
356354
357- transactions = [item .payload for item in items if item .type == "transaction" ]
358- assert len (transactions ) == 1
359- transaction = transactions [0 ]
355+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
360356 assert transaction ["transaction" ] == "test_agent workflow"
361357 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
362358
@@ -583,9 +579,7 @@ def test_agent_invocation_span_sync_no_pii(
583579 assert result is not None
584580 assert result .final_output == "Hello, how can I help you?"
585581
586- transactions = [item .payload for item in items if item .type == "transaction" ]
587- assert len (transactions ) == 1
588- transaction = transactions [0 ]
582+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
589583 assert transaction ["transaction" ] == "test_agent workflow"
590584 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
591585
@@ -739,9 +733,7 @@ def test_agent_invocation_span_sync(
739733 assert result is not None
740734 assert result .final_output == "Hello, how can I help you?"
741735
742- transactions = [item .payload for item in items if item .type == "transaction" ]
743- assert len (transactions ) == 1
744- transaction = transactions [0 ]
736+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
745737 assert transaction ["transaction" ] == "test_agent workflow"
746738 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
747739
@@ -1208,9 +1200,7 @@ def simple_test_tool(message: str) -> str:
12081200 run_config = test_run_config ,
12091201 )
12101202
1211- transactions = [item .payload for item in items if item .type == "transaction" ]
1212- assert len (transactions ) == 1
1213- transaction = transactions [0 ]
1203+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
12141204 assert transaction ["transaction" ] == "test_agent workflow"
12151205 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
12161206
@@ -1700,9 +1690,7 @@ def simple_test_tool(message: str) -> str:
17001690 run_config = test_run_config ,
17011691 )
17021692
1703- transactions = [item .payload for item in items if item .type == "transaction" ]
1704- assert len (transactions ) == 1
1705- transaction = transactions [0 ]
1693+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
17061694 assert transaction ["transaction" ] == "test_agent workflow"
17071695 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
17081696
@@ -1747,16 +1735,12 @@ async def test_error_handling(sentry_init, capture_items, test_agent):
17471735 test_agent , "Test input" , run_config = test_run_config
17481736 )
17491737
1750- error_events = [item .payload for item in items if item .type == "event" ]
1751- assert len (error_events ) == 1
1752- error_event = error_events [0 ]
1738+ (error_event ,) = (item .payload for item in items if item .type == "event" )
17531739 assert error_event ["exception" ]["values" ][0 ]["type" ] == "Exception"
17541740 assert error_event ["exception" ]["values" ][0 ]["value" ] == "Model Error"
17551741 assert error_event ["exception" ]["values" ][0 ]["mechanism" ]["type" ] == "openai_agents"
17561742
1757- transactions = [item .payload for item in items if item .type == "transaction" ]
1758- assert len (transactions ) == 1
1759- transaction = transactions [0 ]
1743+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
17601744 assert transaction ["transaction" ] == "test_agent workflow"
17611745 assert transaction ["contexts" ]["trace" ]["origin" ] == "auto.ai.openai_agents"
17621746
@@ -1811,9 +1795,7 @@ async def test_error_captures_input_data(sentry_init, capture_items, test_agent)
18111795 with pytest .raises (InternalServerError , match = "Error code: 500" ):
18121796 await agents .Runner .run (agent , "Test input" , run_config = test_run_config )
18131797
1814- error_events = [item .payload for item in items if item .type == "event" ]
1815- assert len (error_events ) == 1
1816- error_event = error_events [0 ]
1798+ (error_event ,) = (item .payload for item in items if item .type == "event" )
18171799 assert error_event ["exception" ]["values" ][0 ]["type" ] == "InternalServerError"
18181800 assert error_event ["exception" ]["values" ][0 ]["value" ] == "Error code: 500"
18191801
@@ -3574,9 +3556,7 @@ async def test_no_conversation_id_when_not_provided(
35743556
35753557 assert result is not None
35763558
3577- transactions = [item .payload for item in items if item .type == "transaction" ]
3578- assert len (transactions ) == 1
3579- transaction = transactions [0 ]
3559+ (transaction ,) = (item .payload for item in items if item .type == "transaction" )
35803560
35813561 spans = [item .payload for item in items if item .type == "span" ]
35823562 invoke_agent_span = next (
0 commit comments