@@ -191,7 +191,7 @@ def test_start_model_invoke_span_latest_conventions(mock_tracer):
191
191
[
192
192
{
193
193
"role" : messages [0 ]["role" ],
194
- "parts" : [{"type" : "text" , "content" : messages [ 0 ][ "content" ] }],
194
+ "parts" : [{"type" : "text" , "content" : "Hello" }],
195
195
}
196
196
]
197
197
)
@@ -255,7 +255,7 @@ def test_end_model_invoke_span_latest_conventions(mock_span):
255
255
[
256
256
{
257
257
"role" : "assistant" ,
258
- "parts" : [{"type" : "text" , "content" : message [ "content" ] }],
258
+ "parts" : [{"type" : "text" , "content" : "Response" }],
259
259
"finish_reason" : "end_turn" ,
260
260
}
261
261
]
@@ -324,7 +324,7 @@ def test_start_tool_call_span_latest_conventions(mock_tracer):
324
324
"type" : "tool_call" ,
325
325
"name" : tool ["name" ],
326
326
"id" : tool ["toolUseId" ],
327
- "arguments" : [{ "content" : tool ["input" ]} ],
327
+ "arguments" : tool ["input" ],
328
328
}
329
329
],
330
330
}
@@ -508,7 +508,7 @@ def test_end_tool_call_span_latest_conventions(mock_span):
508
508
{
509
509
"type" : "tool_call_response" ,
510
510
"id" : tool_result .get ("toolUseId" , "" ),
511
- "result " : tool_result .get ("content" ),
511
+ "response " : tool_result .get ("content" ),
512
512
}
513
513
],
514
514
}
@@ -564,9 +564,7 @@ def test_start_event_loop_cycle_span_latest_conventions(mock_tracer):
564
564
mock_span .add_event .assert_any_call (
565
565
"gen_ai.client.inference.operation.details" ,
566
566
attributes = {
567
- "gen_ai.input.messages" : serialize (
568
- [{"role" : "user" , "parts" : [{"type" : "text" , "content" : messages [0 ]["content" ]}]}]
569
- )
567
+ "gen_ai.input.messages" : serialize ([{"role" : "user" , "parts" : [{"type" : "text" , "content" : "Hello" }]}])
570
568
},
571
569
)
572
570
assert span is not None
@@ -576,7 +574,12 @@ def test_end_event_loop_cycle_span(mock_span):
576
574
"""Test ending an event loop cycle span."""
577
575
tracer = Tracer ()
578
576
message = {"role" : "assistant" , "content" : [{"text" : "Response" }]}
579
- tool_result_message = {"role" : "assistant" , "content" : [{"toolResult" : {"response" : "Success" }}]}
577
+ tool_result_message = {
578
+ "role" : "assistant" ,
579
+ "content" : [
580
+ {"toolResult" : {"toolUseId" : "123" , "status" : "success" , "content" : [{"text" : "Weather is sunny" }]}}
581
+ ],
582
+ }
580
583
581
584
tracer .end_event_loop_cycle_span (mock_span , message , tool_result_message )
582
585
@@ -596,7 +599,12 @@ def test_end_event_loop_cycle_span_latest_conventions(mock_span):
596
599
tracer = Tracer ()
597
600
tracer .use_latest_genai_conventions = True
598
601
message = {"role" : "assistant" , "content" : [{"text" : "Response" }]}
599
- tool_result_message = {"role" : "assistant" , "content" : [{"toolResult" : {"response" : "Success" }}]}
602
+ tool_result_message = {
603
+ "role" : "assistant" ,
604
+ "content" : [
605
+ {"toolResult" : {"toolUseId" : "123" , "status" : "success" , "content" : [{"text" : "Weather is sunny" }]}}
606
+ ],
607
+ }
600
608
601
609
tracer .end_event_loop_cycle_span (mock_span , message , tool_result_message )
602
610
@@ -607,7 +615,13 @@ def test_end_event_loop_cycle_span_latest_conventions(mock_span):
607
615
[
608
616
{
609
617
"role" : "assistant" ,
610
- "parts" : [{"type" : "text" , "content" : tool_result_message ["content" ]}],
618
+ "parts" : [
619
+ {
620
+ "type" : "tool_call_response" ,
621
+ "id" : "123" ,
622
+ "response" : [{"text" : "Weather is sunny" }],
623
+ }
624
+ ],
611
625
}
612
626
]
613
627
)
@@ -682,7 +696,7 @@ def test_start_agent_span_latest_conventions(mock_tracer):
682
696
"gen_ai.client.inference.operation.details" ,
683
697
attributes = {
684
698
"gen_ai.input.messages" : serialize (
685
- [{"role" : "user" , "parts" : [{"type" : "text" , "content" : [{ "text" : " test prompt"}] }]}]
699
+ [{"role" : "user" , "parts" : [{"type" : "text" , "content" : " test prompt" }]}]
686
700
)
687
701
},
688
702
)
0 commit comments