Skip to content

Update the root Otel span to be an invoke_agentspan#45033

Open
luigiw wants to merge 2 commits intoAzure:mainfrom
luigiw:hosted-invoke-agent
Open

Update the root Otel span to be an invoke_agentspan#45033
luigiw wants to merge 2 commits intoAzure:mainfrom
luigiw:hosted-invoke-agent

Conversation

@luigiw
Copy link
Contributor

@luigiw luigiw commented Feb 5, 2026

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings February 5, 2026 08:51
@github-actions github-actions bot added the Hosted Agents sdk/agentserver/* label Feb 5, 2026
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 refactors OpenTelemetry tracing to align with the "invoke_agent" semantic convention. The changes extract agent name/ID retrieval into a reusable helper function and update the root span to follow GenAI semantic conventions.

Changes:

  • Refactored agent name/ID extraction into a reusable get_agent_name() helper function
  • Updated span naming from HostedAgents-{response_id} to invoke_agent {agent_name}
  • Changed span kind from SERVER to CLIENT and added GenAI semantic convention attributes

name=span_name,
attributes=ctx,
kind=trace.SpanKind.SERVER,
kind=trace.SpanKind.CLIENT,
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The span kind has been changed from SERVER to CLIENT, but this endpoint is receiving HTTP requests, which indicates it should use SpanKind.SERVER according to OpenTelemetry semantic conventions. SpanKind.CLIENT is typically used for outbound calls the service makes, not for handling incoming requests. This is a server endpoint (runs_endpoint) handling incoming POST requests to /runs or /responses. Unless this represents the client-side invocation of an agent (not the HTTP server receiving the request), this should remain SpanKind.SERVER.

Suggested change
kind=trace.SpanKind.CLIENT,
kind=trace.SpanKind.SERVER,

Copilot uses AI. Check for mistakes.
Comment on lines +308 to +312
Extract the agent name and agent id from an AgentRunContext.

:param agent_run_context: The AgentRunContext instance to extract from.
:type agent_run_context: AgentRunContext
:return: Tuple of (agent_name, agent_id). Agent id is formatted as "name:version".
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The docstring uses the term "Agent id" in the description, but the parameter name is "agent_run_context". For consistency with other docstrings in the codebase and clarity, consider rephrasing to "Extract the agent name and agent ID from an AgentRunContext." (capitalizing "ID" to match the parameter description).

Suggested change
Extract the agent name and agent id from an AgentRunContext.
:param agent_run_context: The AgentRunContext instance to extract from.
:type agent_run_context: AgentRunContext
:return: Tuple of (agent_name, agent_id). Agent id is formatted as "name:version".
Extract the agent name and agent ID from an AgentRunContext.
:param agent_run_context: The AgentRunContext instance to extract from.
:type agent_run_context: AgentRunContext
:return: Tuple of (agent_name, agent_id). Agent ID is formatted as "name:version".

Copilot uses AI. Check for mistakes.

:param agent_run_context: The AgentRunContext instance to extract from.
:type agent_run_context: AgentRunContext
:return: Tuple of (agent_name, agent_id). Agent id is formatted as "name:version".
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The docstring states "Agent id is formatted as 'name:version'" but should be "Agent ID is formatted as 'name:version'" for consistency with standard capitalization of "ID" in technical documentation.

Suggested change
:return: Tuple of (agent_name, agent_id). Agent id is formatted as "name:version".
:return: Tuple of (agent_name, agent_id). Agent ID is formatted as "name:version".

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-ai-agentserver-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant