@@ -239,13 +239,8 @@ def _test_agent_creation_with_tracing_content_recording_enabled_impl(self, use_e
239239 expected_system_message = json .dumps (
240240 [
241241 {
242- "role" : "system" ,
243- "parts" : [
244- {
245- "type" : "text" ,
246- "content" : "You are a helpful AI assistant. Be polite and provide accurate information." ,
247- }
248- ],
242+ "type" : "text" ,
243+ "content" : "You are a helpful AI assistant. Be polite and provide accurate information." ,
249244 }
250245 ],
251246 ensure_ascii = False ,
@@ -279,15 +274,12 @@ def _test_agent_creation_with_tracing_content_recording_enabled_impl(self, use_e
279274 system_message_json = span .attributes [GEN_AI_SYSTEM_MESSAGE ]
280275 system_message = json .loads (system_message_json )
281276
282- # Verify structure
277+ # Verify structure (new format without role/parts wrapper)
283278 assert isinstance (system_message , list )
284279 assert len (system_message ) == 1
285- assert system_message [0 ]["role" ] == "system"
286- assert "parts" in system_message [0 ]
287- assert len (system_message [0 ]["parts" ]) == 1
288- assert system_message [0 ]["parts" ][0 ]["type" ] == "text"
280+ assert system_message [0 ]["type" ] == "text"
289281 assert (
290- system_message [0 ]["parts" ][ 0 ][ " content" ]
282+ system_message [0 ]["content" ]
291283 == "You are a helpful AI assistant. Be polite and provide accurate information."
292284 )
293285
@@ -349,25 +341,27 @@ def _test_agent_creation_with_tracing_content_recording_disabled_impl(self, use_
349341 ]
350342
351343 # When using attributes (regardless of content recording), add system message attribute
352- # When content recording is disabled, it will have empty content (just role)
344+ # When content recording is disabled, it will have type indicator without content
353345 if not use_events :
354346 from azure .ai .projects .telemetry ._utils import GEN_AI_SYSTEM_MESSAGE
355347 import json
356348
357- # Empty system message (no parts, just role )
358- expected_system_message = json .dumps ([{"role " : "system " }], ensure_ascii = False )
349+ # Empty system message (type indicator only, no content )
350+ expected_system_message = json .dumps ([{"type " : "text " }], ensure_ascii = False )
359351 expected_attributes .append ((GEN_AI_SYSTEM_MESSAGE , expected_system_message ))
360352
361353 attributes_match = GenAiTraceVerifier ().check_span_attributes (span , expected_attributes )
362354 assert attributes_match == True
363355
364356 if use_events :
357+ import json
358+
365359 expected_events = [
366360 {
367361 "name" : GEN_AI_SYSTEM_INSTRUCTION_EVENT ,
368362 "attributes" : {
369363 GEN_AI_PROVIDER_NAME : AGENTS_PROVIDER ,
370- GEN_AI_EVENT_CONTENT : "[]" ,
364+ GEN_AI_EVENT_CONTENT : json . dumps ([{ "type" : "text" }]) ,
371365 },
372366 }
373367 ]
@@ -383,12 +377,11 @@ def _test_agent_creation_with_tracing_content_recording_disabled_impl(self, use_
383377
384378 system_message_json = span .attributes [GEN_AI_SYSTEM_MESSAGE ]
385379 system_message = json .loads (system_message_json )
386- # Should have empty content (just role, no parts)
380+ # Should have type indicator when content recording is disabled
387381 assert isinstance (system_message , list )
388382 assert len (system_message ) == 1
389- assert system_message [0 ]["role" ] == "system"
390- # No parts field when content recording is disabled
391- assert "parts" not in system_message [0 ]
383+ assert system_message [0 ]["type" ] == "text"
384+ assert "content" not in system_message [0 ]
392385
393386 @pytest .mark .usefixtures ("instrument_without_content" )
394387 @servicePreparer ()
@@ -594,21 +587,19 @@ def _test_agent_with_structured_output_with_instructions_impl(
594587 expected_system_msg = json .dumps (
595588 [
596589 {
597- "role" : "system" ,
598- "parts" : [
599- {
600- "type" : "text" ,
601- "content" : "You are a helpful assistant that extracts person information." ,
602- },
603- {"type" : "response_schema" , "content" : json .dumps (test_schema )},
604- ],
605- }
590+ "type" : "text" ,
591+ "content" : "You are a helpful assistant that extracts person information." ,
592+ },
593+ {"type" : "response_schema" , "content" : json .dumps (test_schema )},
606594 ],
607595 ensure_ascii = False ,
608596 )
609597 else :
610- # When content recording disabled, attribute has empty structure
611- expected_system_msg = json .dumps ([{"role" : "system" }], ensure_ascii = False )
598+ # When content recording disabled, type indicators without content
599+ expected_system_msg = json .dumps (
600+ [{"type" : "text" }, {"type" : "response_schema" }],
601+ ensure_ascii = False ,
602+ )
612603 expected_attributes .append ((GEN_AI_SYSTEM_MESSAGE , expected_system_msg ))
613604
614605 attributes_match = GenAiTraceVerifier ().check_span_attributes (span , expected_attributes )
@@ -634,7 +625,12 @@ def _test_agent_with_structured_output_with_instructions_impl(
634625 assert "name" in schema_obj ["properties" ]
635626 assert "age" in schema_obj ["properties" ]
636627 else :
637- assert len (event_content ) == 0 # Empty when content recording disabled
628+ # Type indicators without content when content recording disabled
629+ assert len (event_content ) == 2
630+ assert event_content [0 ]["type" ] == "text"
631+ assert "content" not in event_content [0 ]
632+ assert event_content [1 ]["type" ] == "response_schema"
633+ assert "content" not in event_content [1 ]
638634 else :
639635 # When using attributes, verify attribute
640636 from azure .ai .projects .telemetry ._utils import GEN_AI_SYSTEM_MESSAGE
@@ -646,25 +642,26 @@ def _test_agent_with_structured_output_with_instructions_impl(
646642 system_message = json .loads (system_message_json )
647643
648644 assert isinstance (system_message , list )
649- assert len (system_message ) == 1
650- assert system_message [0 ]["role" ] == "system"
651645
652646 if content_recording_enabled :
653- assert "parts" in system_message [0 ]
654- assert len (system_message [0 ]["parts" ]) == 2
647+ assert len (system_message ) == 2
655648
656649 # Check instruction part
657- assert system_message [0 ]["parts" ][ 0 ][ " type" ] == "text"
658- assert "helpful assistant" in system_message [0 ]["parts" ][ 0 ][ " content" ]
650+ assert system_message [0 ]["type" ] == "text"
651+ assert "helpful assistant" in system_message [0 ]["content" ]
659652
660653 # Check schema part
661- assert system_message [0 ][ "parts" ][ 1 ]["type" ] == "response_schema"
662- schema_obj = json .loads (system_message [0 ][ "parts" ][ 1 ]["content" ])
654+ assert system_message [1 ]["type" ] == "response_schema"
655+ schema_obj = json .loads (system_message [1 ]["content" ])
663656 assert schema_obj ["type" ] == "object"
664657 assert "name" in schema_obj ["properties" ]
665658 else :
666- # When content recording disabled, no parts field
667- assert "parts" not in system_message [0 ]
659+ # When content recording disabled, type indicators without content
660+ assert len (system_message ) == 2
661+ assert system_message [0 ]["type" ] == "text"
662+ assert "content" not in system_message [0 ]
663+ assert system_message [1 ]["type" ] == "response_schema"
664+ assert "content" not in system_message [1 ]
668665
669666 @pytest .mark .usefixtures ("instrument_with_content" )
670667 @servicePreparer ()
@@ -776,12 +773,12 @@ def _test_agent_with_structured_output_without_instructions_impl(
776773
777774 if content_recording_enabled :
778775 expected_system_msg = json .dumps (
779- [{"role" : "system" , "parts" : [{ " type" : "response_schema" , "content" : json .dumps (test_schema )}] }],
776+ [{"type" : "response_schema" , "content" : json .dumps (test_schema )}],
780777 ensure_ascii = False ,
781778 )
782779 else :
783- # When content recording disabled, attribute has empty structure
784- expected_system_msg = json .dumps ([{"role " : "system " }], ensure_ascii = False )
780+ # When content recording disabled, type indicator without content
781+ expected_system_msg = json .dumps ([{"type " : "response_schema " }], ensure_ascii = False )
785782 expected_attributes .append ((GEN_AI_SYSTEM_MESSAGE , expected_system_msg ))
786783
787784 attributes_match = GenAiTraceVerifier ().check_span_attributes (span , expected_attributes )
@@ -804,7 +801,10 @@ def _test_agent_with_structured_output_without_instructions_impl(
804801 assert schema_obj ["type" ] == "object"
805802 assert "result" in schema_obj ["properties" ]
806803 else :
807- assert len (event_content ) == 0 # Empty when content recording disabled
804+ # Type indicator without content when content recording disabled
805+ assert len (event_content ) == 1
806+ assert event_content [0 ]["type" ] == "response_schema"
807+ assert "content" not in event_content [0 ]
808808 else :
809809 # When using attributes, verify attribute
810810 from azure .ai .projects .telemetry ._utils import GEN_AI_SYSTEM_MESSAGE
@@ -816,21 +816,20 @@ def _test_agent_with_structured_output_without_instructions_impl(
816816 system_message = json .loads (system_message_json )
817817
818818 assert isinstance (system_message , list )
819- assert len (system_message ) == 1
820- assert system_message [0 ]["role" ] == "system"
821819
822820 if content_recording_enabled :
823- assert "parts" in system_message [0 ]
824- assert len (system_message [0 ]["parts" ]) == 1
821+ assert len (system_message ) == 1
825822
826823 # Check schema part
827- assert system_message [0 ]["parts" ][ 0 ][ " type" ] == "response_schema"
828- schema_obj = json .loads (system_message [0 ]["parts" ][ 0 ][ " content" ])
824+ assert system_message [0 ]["type" ] == "response_schema"
825+ schema_obj = json .loads (system_message [0 ]["content" ])
829826 assert schema_obj ["type" ] == "object"
830827 assert "result" in schema_obj ["properties" ]
831828 else :
832- # When content recording disabled, no parts field
833- assert "parts" not in system_message [0 ]
829+ # When content recording disabled, type indicator without content
830+ assert len (system_message ) == 1
831+ assert system_message [0 ]["type" ] == "response_schema"
832+ assert "content" not in system_message [0 ]
834833
835834 @pytest .mark .usefixtures ("instrument_with_content" )
836835 @servicePreparer ()
0 commit comments