Skip to content

Add gen_ai.caller.agent.type attribute for A2A tracing#161

Merged
nikhilNava merged 4 commits intomainfrom
copilot/implement-nodejs-features-in-python
Feb 6, 2026
Merged

Add gen_ai.caller.agent.type attribute for A2A tracing#161
nikhilNava merged 4 commits intomainfrom
copilot/implement-nodejs-features-in-python

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Ports Agent365-nodejs#187 to Python. Adds the gen_ai.caller.agent.type OpenTelemetry attribute to agent-to-agent invocation traces.

Changes

  • trace_processor/util.py: Add GEN_AI_CALLER_AGENT_TYPE_KEY to INVOKE_AGENT_ATTRIBUTES
  • invoke_agent_scope.py: Set agent_type span attribute from caller_agent_details
  • test_invoke_agent_scope.py: Add test coverage for the new attribute

Usage

caller_agent = AgentDetails(
    agent_id="caller-123",
    agent_name="Orchestrator",
    agent_type=AgentType.DECLARATIVE_AGENT,  # Now recorded in traces
)

scope = InvokeAgentScope.start(
    invoke_agent_details=details,
    tenant_details=tenant,
    caller_agent_details=caller_agent,
)

The constant GEN_AI_CALLER_AGENT_TYPE_KEY was already defined in constants.py but wasn't being used.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • il-1234567812345678123456781234567.8.tenant.api.powerplatform.com
    • Triggering command: /home/REDACTED/work/Agent365-python/Agent365-python/.venv/bin/pytest pytest tests/observability/ -v --tb=short -m not integration (dns block)
  • il-testtenan.t.tenant.api.powerplatform.com
    • Triggering command: /home/REDACTED/work/Agent365-python/Agent365-python/.venv/bin/pytest pytest tests/observability/ -v --tb=short -m not integration (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 5, 2026 17:05
…187)

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
…back

Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
@nikhilNava nikhilNava marked this pull request as ready for review February 5, 2026 17:08
@nikhilNava nikhilNava requested a review from a team as a code owner February 5, 2026 17:08
Copilot AI review requested due to automatic review settings February 5, 2026 17:08
Copilot AI changed the title [WIP] Implement features from Node.js PR in Python Add gen_ai.caller.agent.type attribute for A2A tracing Feb 5, 2026
Copilot AI requested a review from nikhilNava February 5, 2026 17:08
@nikhilNava nikhilNava enabled auto-merge (squash) February 5, 2026 17:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements Python equivalents of changes from Node.js PR #187, adding support for tracking the gen_ai.caller.agent.type attribute in agent-to-agent invocation traces using OpenTelemetry.

Changes:

  • Added GEN_AI_CALLER_AGENT_TYPE_KEY constant to the list of invoke agent attributes for trace processing
  • Implemented agent type tag setting in the InvokeAgentScope to capture caller agent type during invocations
  • Added comprehensive test coverage to verify the agent type attribute is properly set in telemetry spans

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/trace_processor/util.py Added GEN_AI_CALLER_AGENT_TYPE_KEY to the INVOKE_AGENT_ATTRIBUTES list for trace processing
libraries/microsoft-agents-a365-observability-core/microsoft_agents_a365/observability/core/invoke_agent_scope.py Imported the constant and added logic to set the agent type tag from caller agent details, following the existing pattern for enum value handling
tests/observability/core/test_invoke_agent_scope.py Added new test method and updated test fixture with agent type to verify the attribute is correctly captured in telemetry spans

@nikhilNava nikhilNava merged commit 61d7807 into main Feb 6, 2026
8 checks passed
@nikhilNava nikhilNava deleted the copilot/implement-nodejs-features-in-python branch February 6, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments