4040 GEN_AI_RUN_STEP_END_TIMESTAMP ,
4141 GEN_AI_RUN_STEP_STATUS ,
4242 GEN_AI_AGENT_VERSION ,
43+ GEN_AI_AGENT_HOSTED_CPU ,
44+ GEN_AI_AGENT_HOSTED_MEMORY ,
45+ GEN_AI_AGENT_HOSTED_IMAGE ,
46+ GEN_AI_AGENT_HOSTED_PROTOCOL ,
47+ GEN_AI_AGENT_HOSTED_PROTOCOL_VERSION ,
48+ AGENT_TYPE_PROMPT ,
49+ AGENT_TYPE_WORKFLOW ,
50+ AGENT_TYPE_HOSTED ,
51+ AGENT_TYPE_UNKNOWN ,
52+ GEN_AI_AGENT_TYPE ,
4353 ERROR_MESSAGE ,
4454 OperationName ,
4555 start_span ,
@@ -530,6 +540,11 @@ def start_create_agent_span( # pylint: disable=too-many-locals
530540 structured_inputs : Optional [Any ] = None ,
531541 agent_type : Optional [str ] = None ,
532542 workflow_yaml : Optional [str ] = None ,
543+ hosted_cpu : Optional [str ] = None ,
544+ hosted_memory : Optional [str ] = None ,
545+ hosted_image : Optional [str ] = None ,
546+ hosted_protocol : Optional [str ] = None ,
547+ hosted_protocol_version : Optional [str ] = None ,
533548 ) -> "Optional[AbstractSpan]" :
534549 span = start_span (
535550 OperationName .CREATE_AGENT ,
@@ -551,7 +566,19 @@ def start_create_agent_span( # pylint: disable=too-many-locals
551566 if description :
552567 span .add_attribute (GEN_AI_AGENT_DESCRIPTION , description )
553568 if agent_type :
554- span .add_attribute ("gen_ai.agent.type" , agent_type )
569+ span .add_attribute (GEN_AI_AGENT_TYPE , agent_type )
570+
571+ # Add hosted agent specific attributes
572+ if hosted_cpu :
573+ span .add_attribute (GEN_AI_AGENT_HOSTED_CPU , hosted_cpu )
574+ if hosted_memory :
575+ span .add_attribute (GEN_AI_AGENT_HOSTED_MEMORY , hosted_memory )
576+ if hosted_image :
577+ span .add_attribute (GEN_AI_AGENT_HOSTED_IMAGE , hosted_image )
578+ if hosted_protocol :
579+ span .add_attribute (GEN_AI_AGENT_HOSTED_PROTOCOL , hosted_protocol )
580+ if hosted_protocol_version :
581+ span .add_attribute (GEN_AI_AGENT_HOSTED_PROTOCOL_VERSION , hosted_protocol_version )
555582
556583 # Extract response schema from text parameter if available
557584 response_schema = None
@@ -647,19 +674,41 @@ def _create_agent_span_from_parameters(
647674 workflow_yaml = definition .get ("workflow" ) # Extract workflow YAML for workflow agents
648675 # toolset = definition.get("toolset")
649676
677+ # Extract hosted agent specific attributes
678+ hosted_cpu = definition .get ("cpu" )
679+ hosted_memory = definition .get ("memory" )
680+ hosted_image = definition .get ("image" )
681+ hosted_protocol = None
682+ hosted_protocol_version = None
683+ container_protocol_versions = definition .get ("container_protocol_versions" )
684+ if container_protocol_versions and len (container_protocol_versions ) > 0 :
685+ # Extract protocol and version from first entry
686+ protocol_record = container_protocol_versions [0 ]
687+ if hasattr (protocol_record , "protocol" ):
688+ hosted_protocol = getattr (protocol_record , "protocol" , None )
689+ elif isinstance (protocol_record , dict ):
690+ hosted_protocol = protocol_record .get ("protocol" )
691+
692+ if hasattr (protocol_record , "version" ):
693+ hosted_protocol_version = getattr (protocol_record , "version" , None )
694+ elif isinstance (protocol_record , dict ):
695+ hosted_protocol_version = protocol_record .get ("version" )
696+
650697 # Determine agent type from definition
651- # Check for workflow first (most specific)
698+ # Check for hosted agent first (most specific - has container/image configuration )
652699 agent_type = None
653- if workflow_yaml :
654- agent_type = "workflow"
700+ if hosted_image or hosted_cpu or hosted_memory :
701+ agent_type = AGENT_TYPE_HOSTED
702+ elif workflow_yaml :
703+ agent_type = AGENT_TYPE_WORKFLOW
655704 elif instructions or model :
656705 # Prompt agent - identified by having instructions and/or a model.
657706 # Note: An agent with only a model (no instructions) is treated as a prompt agent,
658707 # though this is uncommon. Typically prompt agents have both model and instructions.
659- agent_type = "prompt"
708+ agent_type = AGENT_TYPE_PROMPT
660709 else :
661710 # Unknown type - set to "unknown" to indicate we couldn't determine it
662- agent_type = "unknown"
711+ agent_type = AGENT_TYPE_UNKNOWN
663712
664713 # Extract reasoning effort and summary from reasoning if available
665714 reasoning_effort = None
@@ -739,6 +788,11 @@ def _create_agent_span_from_parameters(
739788 structured_inputs = structured_inputs ,
740789 agent_type = agent_type ,
741790 workflow_yaml = workflow_yaml ,
791+ hosted_cpu = hosted_cpu ,
792+ hosted_memory = hosted_memory ,
793+ hosted_image = hosted_image ,
794+ hosted_protocol = hosted_protocol ,
795+ hosted_protocol_version = hosted_protocol_version ,
742796 )
743797
744798 def trace_create_agent (self , function , * args , ** kwargs ):
0 commit comments