From 5a93245f9237d885020bc1aa516e3e2d93c9cf9d Mon Sep 17 00:00:00 2001 From: heyitsaamir Date: Wed, 1 Jul 2026 15:16:26 -0700 Subject: [PATCH] Default agentic_app_blueprint_id to app client id in get_agentic_identity When agentic_app_blueprint_id is omitted in App.get_agentic_identity, it now defaults to the app's own client/app id (self.id) instead of passing None through to AgenticIdentity. Mirrors the existing tenant-resolution style. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/apps/src/microsoft_teams/apps/app.py | 9 ++++-- packages/apps/tests/test_app.py | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/apps/src/microsoft_teams/apps/app.py b/packages/apps/src/microsoft_teams/apps/app.py index 1af304b1..9b3aea86 100644 --- a/packages/apps/src/microsoft_teams/apps/app.py +++ b/packages/apps/src/microsoft_teams/apps/app.py @@ -341,16 +341,21 @@ def get_agentic_identity( tenant_id: Optional[str] = None, agentic_app_blueprint_id: Optional[str] = None, ) -> AgenticIdentity: - """Get an Agent ID identity for API calls.""" + """Get an Agent ID identity for API calls. + + When ``agentic_app_blueprint_id`` is omitted, it defaults to the app's own + client/app id (``self.id``). + """ resolved_tenant_id = tenant_id or (self.credentials.tenant_id if self.credentials else None) if resolved_tenant_id is None: raise ValueError("tenant_id is required to get an agentic identity") + resolved_blueprint_id = agentic_app_blueprint_id or self.id return AgenticIdentity( agentic_app_id=agentic_app_id, agentic_user_id=agentic_user_id, tenant_id=resolved_tenant_id, - agentic_app_blueprint_id=agentic_app_blueprint_id, + agentic_app_blueprint_id=resolved_blueprint_id, ) @overload diff --git a/packages/apps/tests/test_app.py b/packages/apps/tests/test_app.py index 8a27eb15..55a4b180 100644 --- a/packages/apps/tests/test_app.py +++ b/packages/apps/tests/test_app.py @@ -834,6 +834,34 @@ async def test_send_passes_agentic_identity_and_service_url(self, mock_storage) } assert result.id == "sent-activity-id" + def test_get_agentic_identity_preserves_explicit_blueprint_id(self, mock_storage) -> None: + """An explicitly provided agentic_app_blueprint_id should be preserved.""" + options = AppOptions(storage=mock_storage, client_id="test-client-id", client_secret="test-secret") + app = App(**options) + + identity = app.get_agentic_identity( + "agentic-app-id", + "agentic-user-id", + tenant_id="tenant-id", + agentic_app_blueprint_id="explicit-blueprint-id", + ) + + assert identity.agentic_app_blueprint_id == "explicit-blueprint-id" + + def test_get_agentic_identity_defaults_blueprint_id_to_client_id(self, mock_storage) -> None: + """When agentic_app_blueprint_id is omitted, it should default to the app's client id.""" + options = AppOptions(storage=mock_storage, client_id="test-client-id", client_secret="test-secret") + app = App(**options) + + identity = app.get_agentic_identity( + "agentic-app-id", + "agentic-user-id", + tenant_id="tenant-id", + ) + + assert identity.agentic_app_blueprint_id == app.id + assert identity.agentic_app_blueprint_id == "test-client-id" + class TestAppInitialize: """Test cases for App.initialize() method."""