Skip to content
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

Python: Add agent invocation spans #10255

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

TaoChenOSU
Copy link
Contributor

@TaoChenOSU TaoChenOSU commented Jan 22, 2025

Motivation and Context

Address feature request: #10174

Description

This pull request introduces a new decorator for tracing agent invocations and applies it to various methods in the ChatCompletionAgent and OpenAIAssistantAgent classes. Additionally, it includes new unit tests to ensure the decorator is correctly applied and functions as expected.

Key Changes:

Decorator Implementation:

  • Added a new trace_agent_invocation decorator in python/semantic_kernel/utils/telemetry/agent_diagnostics/decorators.py to trace agent invocations using OpenTelemetry.

Decorator Application:

  • Applied the trace_agent_invocation decorator to the invoke and invoke_stream methods in ChatCompletionAgent (python/semantic_kernel/agents/chat_completion/chat_completion_agent.py). [1] [2] [3]
  • Applied the trace_agent_invocation decorator to the invoke and invoke_stream methods in OpenAIAssistantAgent (python/semantic_kernel/agents/open_ai/open_ai_assistant_base.py). [1] [2] [3]

Contribution Checklist

@TaoChenOSU TaoChenOSU added python Pull requests for the Python Semantic Kernel agents labels Jan 22, 2025
@TaoChenOSU TaoChenOSU self-assigned this Jan 22, 2025
@TaoChenOSU TaoChenOSU requested a review from a team as a code owner January 22, 2025 01:20
@github-actions github-actions bot changed the title Add agent invocation spans Python: Add agent invocation spans Jan 22, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 22, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
semantic_kernel/agents/open_ai
   open_ai_assistant_base.py483799%256, 342–343, 754, 922, 996, 1060
TOTAL16731177789% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3010 4 💤 0 ❌ 0 🔥 1m 12s ⏱️

@TaoChenOSU TaoChenOSU enabled auto-merge January 22, 2025 01:26
Copy link
Contributor

@esttenorio esttenorio left a comment

Choose a reason for hiding this comment

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

should there be a readme or a demo mentioning/explaining the use of the new decorator?

@TaoChenOSU TaoChenOSU added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Jan 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 22, 2025
@moonbox3 moonbox3 merged commit 6ecfdcf into microsoft:main Jan 22, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents python Pull requests for the Python Semantic Kernel
Projects
Status: Sprint: Done
Development

Successfully merging this pull request may close these issues.

New Feature: Agent Names captured in traces and logs to aggregate per agent stats
4 participants