-
Notifications
You must be signed in to change notification settings - Fork 8
[Observability] Clean up input and output messages from auto-instrumented invoke_agent spans #178
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 fixes a bug in the observability cleanup logic for auto-instrumented spans from Semantic Kernel. The existing cleanup attempted to filter invocation_input and invocation_output attributes but failed because: (1) SK actually uses input_messages and output_messages attributes for invoke_agent spans, and (2) deserialization expected a list of strings but received a list of MessageContent objects.
Key Changes:
- Enhanced deserialization to handle JSON arrays of MessageContent objects directly, with fallback to string array format
- Added filtering support for
gen_ai.input.messagesandgen_ai.output.messagesattributes - Refactored code to reduce duplication by introducing a helper overload
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Observability/Extensions/SemanticKernel/Utils/SemanticKernelSpanProcessorHelper.cs | Refactored filtering logic to support additional message attribute keys (input_messages, output_messages) and fixed deserialization to handle JSON arrays of objects directly |
| src/Tests/Microsoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs | Added test verifying the new deserialization logic correctly handles JSON arrays of MessageContent objects |
...icrosoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs
Show resolved
Hide resolved
...icrosoft.Agents.A365.Observability.Extension.Tests/SemanticKernelSpanProcessorHelperTests.cs
Show resolved
Hide resolved
nikhilNava
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ask from the agents activity page team is they want human readable text.
From the images we only require value of the content field e.g "Hello! Before I can ....."
Updated to handle nested content. See new "after fix" screenshot in PR descritpion |
Why?
Existing clean up logic does not work as expected because:
It attempts to cleanup invocation_input and invocation_output attributes, but for invoke_agent spans SK uses input_messages and output_messages
Deserialization fails because it expects a list of strings but actually it is a list of objects of type
MessageContent.What?
Try to filter input_messages and output_messages attributes in addition to existing.
First try to deserialize into a list of objects.
Testing
Without fix

Zooming in on input_messages and output_messages


With fix
