Skip to content

Add AgenticIdentity API surface#478

Merged
heyitsaamir merged 1 commit into
feature_agent365_supportfrom
reimplement_agentic_api_surface
Jun 24, 2026
Merged

Add AgenticIdentity API surface#478
heyitsaamir merged 1 commit into
feature_agent365_supportfrom
reimplement_agentic_api_surface

Conversation

@heyitsaamir

@heyitsaamir heyitsaamir commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This PR adds AgenticIdentity as a new auth context across the Teams API surface.

Why:
Agent ID calls need a user-shaped Agent ID token instead of the normal bot token. The API methods now accept agentic_identity where needed, and the shared auth interceptor uses local request metadata to pick the right auth path.

Interesting bits:

  • Adds optional agentic_identity to conversation create, activity operations, conversation members, reactions, teams, and meetings.
  • Adds optional service_url overrides across the service-url based APIs touched here.
  • Agentic identity is passed through httpx request extensions, not headers. So it stays inside the client pipeline and does not leak to Teams endpoints.
  • The auth interceptor reads that extension and asks the auth provider for the right token.

Reviewer tips:
Start with the API method signatures, then the changed call sites in ConversationActivityClient, ConversationMemberClient, ReactionClient, TeamClient, and MeetingClient. The auth plumbing itself lives one PR down in #485.

Testing:

  • Focused API unit tests for conversation, reaction, bot, user, team, and meeting clients.
  • Full test suite passed locally.

Live smoke tested with Agent ID token:

  • conversation activity create/update/reply/get_members
  • conversation members get_all/get/get_paged
  • reactions add/delete
  • teams get_by_id/get_conversations
  • conversations.create
  • meetings get_by_id/get_participant

Known limitation:

  • targeted activity create/update reached the service but returned 500. Leaving that as not proven until platform behavior is confirmed.

@heyitsaamir

heyitsaamir commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces an AgenticIdentity model and threads it through the Teams API client layer to enable per-call “agentic” authentication, plus adds an apps-layer AppAuthProvider/TokenManager support to mint the appropriate tokens when an agentic identity is used.

Changes:

  • Added AgenticIdentity model and surfaced it through API clients (default + per-call override) via a new AuthProvider hook.
  • Updated TokenManager/credentials typing to support token providers that can optionally accept agentic_identity.
  • Added/updated unit tests and the examples/agent365 sample to demonstrate API-level agentic calls.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/apps/tests/test_token_manager.py Adds coverage for passing agentic_identity through token providers and for AppAuthProvider behavior.
packages/apps/src/microsoft_teams/apps/token_manager.py Adds app-level token APIs and extends token-provider invocation to support agentic tokens.
packages/apps/src/microsoft_teams/apps/options.py Broadens token option typing to allow agentic-aware token providers.
packages/apps/src/microsoft_teams/apps/auth_provider.py Introduces AppAuthProvider to mint app vs agentic tokens using TokenManager.
packages/apps/src/microsoft_teams/apps/app.py Wires AppAuthProvider into ApiClient and adds get_agentic_identity() helper.
packages/api/tests/unit/test_reaction_client.py Updates reaction client tests for agentic token plumbing.
packages/api/tests/unit/test_conversation_client.py Adds tests for service URL override and agentic identity usage in activity operations.
packages/api/tests/unit/test_api_client.py Verifies ApiClient propagates auth defaults into lazily created sub-clients.
packages/api/src/microsoft_teams/api/models/agentic_identity.py Adds the AgenticIdentity model.
packages/api/src/microsoft_teams/api/models/account.py Adds Agent ID fields and a convenience agentic_identity property.
packages/api/src/microsoft_teams/api/models/init.py Exports AgenticIdentity from the models package.
packages/api/src/microsoft_teams/api/clients/reaction/client.py Adds agentic auth support (default + per-call) to reaction operations.
packages/api/src/microsoft_teams/api/clients/conversation/client.py Adds agentic identity + service URL overrides to activity operation surfaces and plumbs auth defaults.
packages/api/src/microsoft_teams/api/clients/conversation/activity.py Implements service URL override and agentic token injection for activity calls.
packages/api/src/microsoft_teams/api/clients/bot/token_client.py Updates deprecated token client to tolerate token providers that accept agentic_identity.
packages/api/src/microsoft_teams/api/clients/base_client.py Adds AuthProvider protocol and centralized agentic token factory logic.
packages/api/src/microsoft_teams/api/clients/api_client.py Adds auth defaults to ApiClient and propagates them to sub-clients.
packages/api/src/microsoft_teams/api/clients/init.py Exposes AuthProvider in the clients package exports.
packages/api/src/microsoft_teams/api/auth/credentials.py Updates TokenCredentials.token typing to support agentic-aware token providers.
packages/api/src/microsoft_teams/api/auth/cloud_environment.py Adds agentic_bot_scope to the cloud environment configuration.
examples/agent365/src/main.py Updates the sample to send via API client using agentic_identity.
examples/agent365/README.md Updates documentation to match the new sample flow and env var expectations.

Comment thread packages/apps/src/microsoft_teams/apps/token_manager.py
Comment thread packages/api/src/microsoft_teams/api/clients/base_client.py Outdated
Comment thread packages/api/src/microsoft_teams/api/clients/bot/token_client.py
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch 3 times, most recently from b335f67 to 22c23a6 Compare June 19, 2026 00:52
Comment thread packages/api/src/microsoft_teams/api/auth/credentials.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/options.py Outdated
Comment thread packages/api/src/microsoft_teams/api/auth/cloud_environment.py

@corinagum corinagum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can agentic identity not create conversations or list members? Looks like only sending/modifying activities is performable?

Comment thread packages/api/src/microsoft_teams/api/auth/cloud_environment.py
Comment thread packages/api/src/microsoft_teams/api/models/message/message.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/token_manager.py
Comment thread packages/api/src/microsoft_teams/api/clients/base_client.py Outdated
Comment thread packages/api/src/microsoft_teams/api/clients/bot/token_client.py
Comment thread packages/api/src/microsoft_teams/api/auth/credentials.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.

Comment thread packages/api/src/microsoft_teams/api/auth/credentials.py Outdated
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from 30f6a0c to 4e1274e Compare June 22, 2026 15:38
@heyitsaamir heyitsaamir changed the base branch from add_inbound_token_validation to add_agentic_auth_infra June 22, 2026 15:38
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from dd2f47d to 36ad717 Compare June 22, 2026 19:28
@heyitsaamir heyitsaamir force-pushed the add_agentic_auth_infra branch from 3d65157 to 5090e99 Compare June 22, 2026 19:35
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from 36ad717 to 307c694 Compare June 22, 2026 19:35
@heyitsaamir heyitsaamir force-pushed the add_agentic_auth_infra branch from 5090e99 to 70506df Compare June 22, 2026 19:53
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from 307c694 to ea94db0 Compare June 22, 2026 19:53
self.service_url = service_url.rstrip("/")

async def create(self, conversation_id: str, activity: ActivityParams) -> SentActivity:
def _get_service_url(self, service_url: str | None = None) -> str:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

move this to the bottom.

Comment thread packages/api/src/microsoft_teams/api/clients/conversation/client.py Outdated
Comment thread packages/api/src/microsoft_teams/api/clients/conversation/member.py Outdated
Comment thread packages/api/src/microsoft_teams/api/clients/reaction/client.py
Comment thread packages/api/src/microsoft_teams/api/clients/conversation/member.py Outdated
Comment thread packages/api/src/microsoft_teams/api/clients/meeting/client.py Outdated
Comment thread packages/api/src/microsoft_teams/api/auth/credentials.py Outdated
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch 2 times, most recently from 45dbacd to e37e732 Compare June 22, 2026 22:18
@heyitsaamir heyitsaamir force-pushed the add_agentic_auth_infra branch from 70506df to e2b8163 Compare June 22, 2026 22:39
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from e37e732 to 7b4376b Compare June 22, 2026 22:39
@heyitsaamir heyitsaamir force-pushed the add_agentic_auth_infra branch from e2b8163 to cfdbefa Compare June 23, 2026 04:07
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch 2 times, most recently from 16b61b4 to 14c6a68 Compare June 23, 2026 04:11
Comment thread packages/api/src/microsoft_teams/api/clients/conversation/activity.py Outdated

@corinagum corinagum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm! Just one nit

@lilyydu lilyydu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks pretty clean to me!

@heyitsaamir heyitsaamir force-pushed the add_agentic_auth_infra branch from cfdbefa to e102800 Compare June 24, 2026 00:34
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from 14c6a68 to 5a364f3 Compare June 24, 2026 00:35
@heyitsaamir heyitsaamir force-pushed the add_agentic_auth_infra branch from e102800 to 5f44f4a Compare June 24, 2026 00:43
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from 5a364f3 to 9f395c9 Compare June 24, 2026 00:43
Base automatically changed from add_agentic_auth_infra to feature_agent365_support June 24, 2026 05:25
@heyitsaamir heyitsaamir force-pushed the feature_agent365_support branch from f39b58f to 6198553 Compare June 24, 2026 05:30
@heyitsaamir heyitsaamir force-pushed the reimplement_agentic_api_surface branch from 9f395c9 to 84bccbd Compare June 24, 2026 05:30
@heyitsaamir heyitsaamir requested a review from Copilot June 24, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread packages/api/src/microsoft_teams/api/clients/conversation/client.py
@heyitsaamir heyitsaamir merged commit 2f8b767 into feature_agent365_support Jun 24, 2026
10 checks passed
@heyitsaamir heyitsaamir deleted the reimplement_agentic_api_surface branch June 24, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants