Skip to content

Python: Input & output attributes in invoke_agent span #12834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 4, 2025

Conversation

TaoChenOSU
Copy link
Contributor

@TaoChenOSU TaoChenOSU commented Jul 30, 2025

Motivation and Context

The OTel workgroup has been thinking about enhancing tracing for agents. This is a proposal from our tracing team: open-telemetry/semantic-conventions#2528. This PR implements part of the proposal so that when the proposal gets merged, we can quickly follow.

Description

Two new attributes are added to the invoke_agent span, namely the gen_ai.agent.invocation_input and gen_ai.agent.invocation_output.

image

Contribution Checklist

@TaoChenOSU TaoChenOSU self-assigned this Jul 30, 2025
@TaoChenOSU TaoChenOSU requested a review from a team as a code owner July 30, 2025 19:20
@TaoChenOSU TaoChenOSU added the python Pull requests for the Python Semantic Kernel label Jul 30, 2025
@github-actions github-actions bot changed the title Input & output attributes in invoke_agent span Python: Input & output attributes in invoke_agent span Jul 30, 2025
@TaoChenOSU TaoChenOSU added the PR: in progress Under development and/or addressing feedback label Jul 30, 2025
@moonbox3
Copy link
Collaborator

moonbox3 commented Jul 30, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
agents/azure_ai
   azure_ai_agent.py36218050%99, 101–104, 106–108, 110–115, 117, 119, 121–123, 125, 142, 144–147, 149–154, 156, 161–162, 167–170, 175–179, 181–184, 186–192, 197, 199–202, 204–206, 208–211, 213, 215, 225–226, 228–231, 233–234, 239, 241–247, 249, 282, 293–294, 299–300, 303, 308–313, 320–321, 323, 328–329, 340–346, 398, 400, 406, 417, 420, 422, 424, 426, 460, 491–493, 495, 497–498, 500–503, 506–508, 510–511, 514, 517–526, 528, 537–538, 541–543, 545–546, 556–557, 559, 577, 579, 582, 584–585, 587–588, 590, 599–600, 602, 604–607, 610, 612, 615–617, 621, 690, 796, 900, 973
agents/bedrock
   bedrock_agent.py2545677%78, 84–85, 94, 160, 287, 300, 319, 335–338, 344, 346, 349, 354, 386, 389, 402, 434–435, 442–445, 453–454, 458, 491, 494, 507, 526–529, 531–534, 576, 587–588, 600, 636–637, 647, 658, 675–676, 688, 705, 707, 709, 711–712, 714
agents/chat_completion
   chat_completion_agent.py2303385%69, 74, 79, 85, 101, 103, 109–113, 171, 174, 184, 192, 195, 197, 206, 232, 251, 253–254, 256–257, 260–262, 264, 266, 268, 416, 513, 590
agents/copilot_studio
   copilot_studio_agent.py2472470%3–8, 10–14, 16–19, 23–26, 31–36, 42, 50, 56–60, 63–64, 67, 78–84, 86–87, 89, 93–95, 99–102, 104, 106, 108, 110–111, 115–119, 121–122, 129–131, 135–137, 139–140, 143, 148, 151, 153, 156–157, 162–163, 168, 170–175, 177–180, 182–184, 193–194, 197, 208–210, 212–213, 215–216, 218, 220–221, 223, 225–227, 229, 231–232, 234–236, 238–245, 247–248, 255–256, 259–260, 262, 287–288, 290, 295–302, 304–305, 310–311, 315–316, 318, 320, 322–324, 326–327, 364–365, 367–368, 383–384, 386–388, 390, 394, 405, 409–411, 432, 438–439, 441, 443–444, 452, 454, 456–458, 481, 487–488, 490, 492, 500, 502–504, 535, 541–542, 544, 546–547, 555, 557–559, 565, 574–575, 577, 579–580, 582, 584–586, 588–589, 591, 593, 595–597, 602–604, 607, 609, 611–612, 614–618, 621, 623–624, 626–627, 629–630, 632–635, 637–638, 644, 652–653, 658
agents/open_ai
   openai_assistant_agent.py3637180%75, 111–114, 119, 123–124, 157, 174–175, 183–188, 195–196, 199, 204–205, 216–222, 400–401, 408–409, 411–412, 414–415, 417–422, 424, 472–473, 476, 479, 482–491, 493, 503, 527–528, 566, 582, 592, 608, 621, 657, 801, 910, 1017
   openai_responses_agent.py41010474%66, 95, 114–117, 125, 129–130, 162–166, 170, 175, 180, 185, 191, 196–197, 200, 203, 208–213, 218–219, 221–222, 228–231, 237, 239–240, 244–248, 339, 343, 347, 349, 355, 368, 370, 372, 376, 471–472, 479–480, 482–483, 485–486, 488–493, 495, 543–544, 547, 592, 608, 618, 652, 660, 663, 667, 669, 672, 695, 698–702, 712, 752, 777, 788, 879, 999, 1040, 1042, 1116, 1156–1157, 1159–1163, 1182
utils/telemetry/agent_diagnostics
   decorators.py116893%163, 230–235, 240
   gen_ai_attributes.py70100% 
TOTAL26775460182% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3661 22 💤 0 ❌ 0 🔥 1m 56s ⏱️

@moonbox3 moonbox3 enabled auto-merge August 4, 2025 05:27
@moonbox3 moonbox3 added this pull request to the merge queue Aug 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 4, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Aug 4, 2025
Merged via the queue into main with commit b7bb283 Aug 4, 2025
28 of 30 checks passed
@moonbox3 moonbox3 deleted the taochen/python-agent-span-new-attrs branch August 4, 2025 22:01
@github-project-automation github-project-automation bot moved this to Sprint: Done in Semantic Kernel Aug 4, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 15, 2025
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
The OTel workgroup has been thinking about enhancing tracing for agents.
This is a proposal from our tracing team:
open-telemetry/semantic-conventions#2528. This
PR implements part of the proposal so that when the proposal gets
merged, we can quickly follow.

This is a follow-up PR after the Python PR #12834 
### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

Two new attributes are added to the invoke_agent span, namely the
`gen_ai.agent.invocation_input` and `gen_ai.agent.invocation_output`.

<img width="870" height="384" alt="image"
src="https://github.com/user-attachments/assets/c2cf069a-af00-4ae2-8fed-745c166d9cbc"
/>

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: Chris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents PR: in progress Under development and/or addressing feedback python Pull requests for the Python Semantic Kernel telemetry
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants