Repository navigation
Add Agent 365 agentLifecycle event support - #492
Merged
Aamir Jawaid (heyitsaamir) merged 5 commits intoJul 9, 2026
Merged
Aamir Jawaid (heyitsaamir) merged 5 commits into
Aamir Jawaid (heyitsaamir) merged 5 commits into
Conversation
Model and route Agent 365 "agentLifecycle" event activities, which arrive as event activities (name="agentLifecycle") from the System user on the "agents" channel. The activity-level valueType names the variant and value carries the typed payload. - Add Pydantic models for the 8 agentLifecycle payloads, discriminated by eventType, with an unknown fallback (mirrors the Entity discriminator). - Add one typed activity class per variant plus an AgentLifecycleEventActivity union. - Switch EventActivity from a name-based discriminator to a callable Discriminator so agentLifecycle variants discriminate on valueType while meeting/read-receipt events still discriminate on name. - Add routing configs and regenerate handlers to expose on_agent_lifecycle plus per-variant on_agentic_user_* registration methods. - Add API parsing tests and apps route-selector tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aamir Jawaid (heyitsaamir)
marked this pull request as ready for review
July 2, 2026 00:24
Aamir Jawaid (heyitsaamir)
requested review from
Corina (corinagum) and
Lily Du (lilyydu)
July 2, 2026 00:25
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Lily Du (lilyydu)
approved these changes
Jul 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class Agent 365 agentLifecycle support across the SDK: typed event activities/value payloads, nested discriminator parsing (name â valueType), app routing/handler registration, and runnable example loggingâplus corresponding unit tests and lockfile sync for an existing example workspace member.
Changes:
- Introduces
agentLifecycleevent activity/value models and exports them through the API activity unions. - Adds Apps routing selectors + generated handler registration methods for
on_agent_lifecycleand per-varianton_agentic_user_*handlers, with route-selector tests. - Updates
examples/agent365to log lifecycle traffic for live validation; updatesuv.lockto includeexamples/formatted-messaging.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Adds formatted-messaging workspace member package metadata to the lockfile. |
| packages/apps/tests/test_agent_lifecycle_routes.py | New tests asserting general + per-variant route selectors behave correctly. |
| packages/apps/src/microsoft_teams/apps/routing/generated_handlers.py | Adds handler registration methods and type imports for lifecycle events. |
| packages/apps/src/microsoft_teams/apps/routing/activity_route_configs.py | Adds lifecycle route configs and selectors (agentLifecycle + per-valueType variants). |
| packages/api/tests/unit/test_agent_lifecycle_event.py | New parsing/serialization unit tests for lifecycle event variants. |
| packages/api/src/microsoft_teams/api/activities/event/agent_lifecycle/value.py | Adds typed value payload models for observed lifecycle variants. |
| packages/api/src/microsoft_teams/api/activities/event/agent_lifecycle/activity.py | Adds typed activity models + valueType-discriminated union. |
| packages/api/src/microsoft_teams/api/activities/event/agent_lifecycle/init.py | Exports lifecycle activities/values from the new module. |
| packages/api/src/microsoft_teams/api/activities/event/init.py | Wires lifecycle into EventActivity parsing via name discriminator and exports symbols. |
| examples/agent365/src/main.py | Adds lifecycle handlers and logging as a runnable validation harness. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aamir Jawaid (heyitsaamir)
merged commit Jul 9, 2026
11a9bb8
into
feature_agent365_support
5 checks passed
Merged
Aamir Jawaid (heyitsaamir)
added a commit
that referenced
this pull request
Aug 3, 2026
This is the Python feature branch for Agent 365 and ACF support in 2.1. It brings the stacked identity, lifecycle, proactive messaging, and observability work together as one integration point. ## Included commits - [`24b0ffa`](24b0ffa) Start Agent 365 support branch - [`ecd2654`](ecd2654) Add Agent 365 token support (#457) - [`02c2091`](02c2091) Support Entra inbound Agent ID tokens (#462) - [`6198553`](6198553) Add agentic auth provider infrastructure (#485) - [`2f8b767`](2f8b767) Add AgenticIdentity API surface (#478) - [`5ce920a`](5ce920a) Remove ActivitySender send abstraction (#479) - [`b65a997`](b65a997) Add app-level agentic send helpers (#480) - [`3b441b8`](3b441b8) Default agentic app blueprint ID to app client ID - [`11a9bb8`](11a9bb8) Add Agent 365 agentLifecycle event support (#492) - [`b5b1d44`](b5b1d44) Fix Agent365 base branch deprecation errors - [`36e7c27`](36e7c27) Simplify API client scoping (#505) - [`b620848`](b620848) Add OpenTelemetry API middleware (#514) - [`fc4cbc0`](fc4cbc0) Add OpenTelemetry app diagnostics (#515) - [`287bee1`](287bee1) Rename Agent 365 identity surface to AgenticUser (#524) - [`af1b76c`](af1b76c) Agent365 OpenTelemetry: SDK token-provider surface (#530) - [`3781421`](3781421) Agent365 OpenTelemetry: Agent365 baggage bridge (#516) - [`c2af463`](c2af463) Use AgenticIdentity as Python Agent 365 SDK scope (#533) --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Copilot-Session: 56462895-549f-4889-82c7-16a7d7232ae3 Copilot-Session: b861cde5-a4a6-4d2b-9ca7-0a4f8ccda4ff Copilot-Session: 8398c990-e5b5-41b6-8d04-0519128726c1 Copilot-Session: 0d367487-e88d-4423-8016-475637d47ed0 Copilot-Session: 69dcf0c6-166e-4c59-8a3f-6c0b0c1d8071 Copilot-Session: 69dcf0c6-166e-4c59-8a3f-6c0b0c1c05d3 Copilot-Session: a43ae3bd-97f9-4dbb-bfd0-ffc3dce0a3b7
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
agentLifecycleevent activity models and value payloads for the observed lifecycle variants.agentLifecycleintoEventActivityparsing via nested discriminators (namethenvalueType).on_agent_lifecycleand per-varianton_agentic_user_*handlers.examples/agent365as a runnable validation/reference harness.uv.lockso the existingexamples/formatted-messagingworkspace member is represented in the lockfile.Manual validation
Validated against live Agent 365 lifecycle traffic using
examples/agent365on port 4000 with handlers registered for both the general lifecycle event and each variant-specific lifecycle event.AgenticUserIdentityCreateduserId,email, anddisplayName.AgenticUserIdentityUpdatedMail,Alias, andUserPrincipalNameupdates with versions.AgenticUserEnabledAgenticUserDisabledAgenticUserManagerUpdatedmanager.managerId.AgenticUserWorkloadOnboardingUpdatedworkloadName=TeamsandworkloadOnboardingState=succeeded.AgenticUserDeletedAgenticUserUndeletedAgenticUserDeletedAdditional live-test findings:
type="event",name="agentLifecycle",channelId="agents", andfrom.id="system".valueTypematched the concrete lifecycle variant andvalue.eventTypematched the lower-camel event name.await ctx.next()for variant-specific handlers to run afterward.AgenticUserDeleted; live payloads did not include a populated deletion reason, so the model keeps it optional.AgenticUserManagerUpdated; updating the primary Entra manager did.200 OKand Bot API reply returned201 Created.Validation
ruff checkpyrightpytest packages