Skip to content

Conversation

@M-Hietala
Copy link
Contributor

adding agent id to response generation trace

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 adds agent ID to response generation traces for improved telemetry tracking in Azure Monitor. The change enables better trace filtering and debugging by including the agent ID alongside the existing agent name in telemetry spans. This enhancement is particularly useful for viewing traces in the Microsoft Foundry portal.

Key Changes

  • Extended the responses instrumentor to extract and include agent ID in trace spans
  • Added comprehensive test coverage for both streaming and non-streaming scenarios
  • Updated sample code to demonstrate proper agent ID inclusion in response generation

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
_responses_instrumentor.py Added agent_id parameter to span creation and implemented _extract_agent_id() method to parse agent ID from request kwargs
test_responses_instrumentor.py Added two new test methods for non-streaming and streaming responses with agent ID verification
test_responses_instrumentor_async.py Added async equivalents of the new test methods for comprehensive async coverage
sample_agent_basic_with_azure_monitor_tracing.py Updated sample to demonstrate responses API with agent ID in the extra_body parameter
README.md Added documentation note explaining the importance of passing agent ID for portal trace viewing
CHANGELOG.md Documented the new tracing feature and sample update
assets.json Updated asset tag to reflect test recording changes

@M-Hietala M-Hietala merged commit a6eef48 into main Jan 6, 2026
20 checks passed
@M-Hietala M-Hietala deleted the m-hietala/adding_agent_id_to_response_generation_trace branch January 6, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants