@@ -191,7 +191,7 @@ def test_start_model_invoke_span_latest_conventions(mock_tracer):
191191 [
192192 {
193193 "role" : messages [0 ]["role" ],
194- "parts" : [{"type" : "text" , "content" : messages [ 0 ][ "content" ] }],
194+ "parts" : [{"type" : "text" , "content" : "Hello" }],
195195 }
196196 ]
197197 )
@@ -255,7 +255,7 @@ def test_end_model_invoke_span_latest_conventions(mock_span):
255255 [
256256 {
257257 "role" : "assistant" ,
258- "parts" : [{"type" : "text" , "content" : message [ "content" ] }],
258+ "parts" : [{"type" : "text" , "content" : "Response" }],
259259 "finish_reason" : "end_turn" ,
260260 }
261261 ]
@@ -324,7 +324,7 @@ def test_start_tool_call_span_latest_conventions(mock_tracer):
324324 "type" : "tool_call" ,
325325 "name" : tool ["name" ],
326326 "id" : tool ["toolUseId" ],
327- "arguments" : [{ "content" : tool ["input" ]} ],
327+ "arguments" : tool ["input" ],
328328 }
329329 ],
330330 }
@@ -508,7 +508,7 @@ def test_end_tool_call_span_latest_conventions(mock_span):
508508 {
509509 "type" : "tool_call_response" ,
510510 "id" : tool_result .get ("toolUseId" , "" ),
511- "result " : tool_result .get ("content" ),
511+ "response " : tool_result .get ("content" ),
512512 }
513513 ],
514514 }
@@ -564,9 +564,7 @@ def test_start_event_loop_cycle_span_latest_conventions(mock_tracer):
564564 mock_span .add_event .assert_any_call (
565565 "gen_ai.client.inference.operation.details" ,
566566 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" }]}])
570568 },
571569 )
572570 assert span is not None
@@ -576,7 +574,12 @@ def test_end_event_loop_cycle_span(mock_span):
576574 """Test ending an event loop cycle span."""
577575 tracer = Tracer ()
578576 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+ }
580583
581584 tracer .end_event_loop_cycle_span (mock_span , message , tool_result_message )
582585
@@ -596,7 +599,12 @@ def test_end_event_loop_cycle_span_latest_conventions(mock_span):
596599 tracer = Tracer ()
597600 tracer .use_latest_genai_conventions = True
598601 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+ }
600608
601609 tracer .end_event_loop_cycle_span (mock_span , message , tool_result_message )
602610
@@ -607,7 +615,13 @@ def test_end_event_loop_cycle_span_latest_conventions(mock_span):
607615 [
608616 {
609617 "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+ ],
611625 }
612626 ]
613627 )
@@ -682,7 +696,7 @@ def test_start_agent_span_latest_conventions(mock_tracer):
682696 "gen_ai.client.inference.operation.details" ,
683697 attributes = {
684698 "gen_ai.input.messages" : serialize (
685- [{"role" : "user" , "parts" : [{"type" : "text" , "content" : [{ "text" : " test prompt"}] }]}]
699+ [{"role" : "user" , "parts" : [{"type" : "text" , "content" : " test prompt" }]}]
686700 )
687701 },
688702 )
0 commit comments