-
Notifications
You must be signed in to change notification settings - Fork 23
Add agent version #220
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
Add agent version #220
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,14 @@ | |
| from microsoft_agents_a365.observability.core.constants import ( | ||
| CHANNEL_LINK_KEY, | ||
| CHANNEL_NAME_KEY, | ||
| GEN_AI_AGENT_VERSION_KEY, | ||
| GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY, | ||
| GEN_AI_CALLER_AGENT_EMAIL_KEY, | ||
| GEN_AI_CALLER_AGENT_ID_KEY, | ||
| GEN_AI_CALLER_AGENT_NAME_KEY, | ||
| GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY, | ||
| GEN_AI_CALLER_AGENT_USER_ID_KEY, | ||
| GEN_AI_CALLER_AGENT_VERSION_KEY, | ||
| GEN_AI_INPUT_MESSAGES_KEY, | ||
| SERVER_ADDRESS_KEY, | ||
| SERVER_PORT_KEY, | ||
|
|
@@ -92,6 +100,7 @@ def setUpClass(cls): | |
| agentic_user_email="[email protected]", | ||
| tenant_id="tenant-789", | ||
| agent_platform_id="platform-123", | ||
| agent_version="2.1.0", | ||
| ) | ||
|
|
||
| def setUp(self): | ||
|
|
@@ -271,6 +280,94 @@ def test_span_processor_propagates_server_baggage_for_invoke_agent_span(self): | |
| self.assertEqual(span_attributes.get(SERVER_ADDRESS_KEY), server_address) | ||
| self.assertEqual(span_attributes.get(SERVER_PORT_KEY), str(server_port)) | ||
|
|
||
| def test_agent_version_set_on_span(self): | ||
| """Test that agent_version from AgentDetails is set on span attributes.""" | ||
| agent_with_version = AgentDetails( | ||
| agent_id="versioned-agent", | ||
| agent_name="Versioned Agent", | ||
| agent_version="1.0.0", | ||
| ) | ||
| scope = InvokeAgentScope.start( | ||
| self.test_request, | ||
| self.invoke_scope_details, | ||
| agent_with_version, | ||
| ) | ||
| if scope is not None: | ||
| scope.dispose() | ||
|
|
||
| finished_spans = self.span_exporter.get_finished_spans() | ||
| self.assertTrue(finished_spans, "Expected at least one span") | ||
| span_attributes = getattr(finished_spans[-1], "attributes", {}) or {} | ||
| self.assertEqual(span_attributes.get(GEN_AI_AGENT_VERSION_KEY), "1.0.0") | ||
|
|
||
| def test_agent_version_not_set_when_none(self): | ||
| """Test that agent_version is not set on span when it is None.""" | ||
| agent_without_version = AgentDetails( | ||
| agent_id="no-version-agent", | ||
| agent_name="No Version Agent", | ||
| ) | ||
| scope = InvokeAgentScope.start( | ||
| self.test_request, | ||
| self.invoke_scope_details, | ||
| agent_without_version, | ||
| ) | ||
| if scope is not None: | ||
| scope.dispose() | ||
|
|
||
| finished_spans = self.span_exporter.get_finished_spans() | ||
| self.assertTrue(finished_spans, "Expected at least one span") | ||
| span_attributes = getattr(finished_spans[-1], "attributes", {}) or {} | ||
| self.assertNotIn(GEN_AI_AGENT_VERSION_KEY, span_attributes) | ||
|
|
||
| def test_caller_agent_version_set_on_span(self): | ||
| """Test that caller agent version is emitted on invoke_agent spans.""" | ||
| caller_with_version = CallerDetails( | ||
| user_details=self.user_details, | ||
| caller_agent_details=self.caller_agent_details, | ||
| ) | ||
| scope = InvokeAgentScope.start( | ||
| self.test_request, | ||
| self.invoke_scope_details, | ||
| self.agent_details, | ||
| caller_details=caller_with_version, | ||
| ) | ||
| if scope is not None: | ||
| scope.dispose() | ||
|
|
||
| finished_spans = self.span_exporter.get_finished_spans() | ||
| self.assertTrue(finished_spans, "Expected at least one span") | ||
| span_attributes = getattr(finished_spans[-1], "attributes", {}) or {} | ||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_VERSION_KEY), "2.1.0") | ||
|
|
||
| def test_caller_agent_details_all_fields_set_on_span(self): | ||
| """Test that all caller agent detail fields are set on span attributes.""" | ||
| caller_with_agent = CallerDetails( | ||
| user_details=self.user_details, | ||
| caller_agent_details=self.caller_agent_details, | ||
| ) | ||
| scope = InvokeAgentScope.start( | ||
| self.test_request, | ||
| self.invoke_scope_details, | ||
| self.agent_details, | ||
| caller_details=caller_with_agent, | ||
| ) | ||
| if scope is not None: | ||
| scope.dispose() | ||
|
|
||
| finished_spans = self.span_exporter.get_finished_spans() | ||
| self.assertTrue(finished_spans, "Expected at least one span") | ||
| span_attributes = getattr(finished_spans[-1], "attributes", {}) or {} | ||
|
|
||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_NAME_KEY), "Caller Agent") | ||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_ID_KEY), "caller-agent-789") | ||
| self.assertEqual( | ||
| span_attributes.get(GEN_AI_CALLER_AGENT_APPLICATION_ID_KEY), "blueprint-456" | ||
| ) | ||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_USER_ID_KEY), "auid-123") | ||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_EMAIL_KEY), "[email protected]") | ||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY), "platform-123") | ||
| self.assertEqual(span_attributes.get(GEN_AI_CALLER_AGENT_VERSION_KEY), "2.1.0") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Run pytest only on the current file | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.