Conversation
Notification routes registered via OnAgentNotification and OnLifecycleNotification were not passing isAgenticOnly: true to AgentExtension.AddRoute. Starting with Microsoft.Agents.Builder 1.4.68, routes flagged as Agentic (Order=1) are evaluated before Other (Order=0) routes. This caused OnActivity(Message, isAgenticOnly: true) handlers to intercept agentic notifications before the notification handler ran. Fix: pass isAgenticOnly: true in both OnAgentNotification and OnLifecycleNotification since A365 notifications are always agentic requests (recipient.role = agenticUser). Also bumps Azure.Identity 1.14.2 -> 1.17.1 to satisfy transitive dependency from Microsoft.Agents.Authentication.Msal 1.4.83, and adds routing integration tests that exercise the real AgentApplication dispatch pipeline to verify notification handlers win over competing generic message handlers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
src/Tests/Microsoft.Agents.A365.Notifications.Tests/AgentNotificationRoutingTests.cs
Fixed
Show fixed
Hide fixed
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes A365 notification routing priority regressions introduced by agentic route ordering changes in newer Microsoft.Agents.* SDKs by ensuring notification routes are classified as agentic and therefore evaluated before generic agentic message routes.
Changes:
- Mark
OnAgentNotificationandOnLifecycleNotificationroutes asisAgenticOnly: trueso they participate in agentic route ordering. - Add integration-style routing tests that exercise
AgentApplication.OnTurnAsyncdispatch behavior in the presence of competing agentic message handlers. - Update central package versions (notably
Azure.IdentityandMicrosoft.Agents.*).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/Tests/Microsoft.Agents.A365.Notifications.Tests/AgentNotificationRoutingTests.cs |
Adds routing integration tests to validate notification handlers win over generic agentic message handlers. |
src/Notification/Microsoft.Agents.A365.Notifications/AgentNotification.cs |
Updates notification/lifecycle route registration to pass isAgenticOnly: true. |
src/Directory.Packages.props |
Bumps central package versions for Azure.Identity and Microsoft.Agents.*. |
src/Tests/Microsoft.Agents.A365.Notifications.Tests/AgentNotificationRoutingTests.cs
Show resolved
Hide resolved
src/Tests/Microsoft.Agents.A365.Notifications.Tests/AgentNotificationRoutingTests.cs
Show resolved
Hide resolved
src/Notification/Microsoft.Agents.A365.Notifications/AgentNotification.cs
Outdated
Show resolved
Hide resolved
- Add using declarations on TurnContext instances to ensure disposal - Use ChannelId constructor instead of implicit string conversion for msteams and directline channel IDs for consistency - Fix grammar in comment: 'we will required' -> 'we will require' Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
MattB-msft
approved these changes
Apr 2, 2026
juliomenendez
approved these changes
Apr 2, 2026
ajmfehr
approved these changes
Apr 2, 2026
tmlsousa
approved these changes
Apr 2, 2026
flaviocdc
added a commit
to flaviocdc/Agents-for-net
that referenced
this pull request
Apr 3, 2026
Adds tests that verify agentic route priority through OnTurnAsync dispatch, closing a coverage gap exposed by microsoft/Agent365-dotnet#231 where notification routes registered without isAgenticOnly were deprioritized. - Agentic route beats non-agentic for agentic requests - Two agentic routes at same rank: first match wins - Non-agentic request skips agentic-only routes - AgentExtension.AddRoute propagates isAgenticOnly flag correctly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
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.
A365 Notification Routes Not Marked as Agentic — Deprioritized by SDK 1.4.68+ Route Ordering
Problem
After upgrading
Microsoft.Agents.Builder, A365 notification activities (email, comment) withtype=message,channelId=agents,recipient.role=agenticUserare no longer routed toOnAgentNotification. Instead, they are intercepted by application-levelOnActivity(ActivityTypes.Message, isAgenticOnly: true)handlers.This repo pins
Microsoft.Agents.Builderat 1.4.83 (seeDirectory.Packages.props). The breaking change was introduced in SDK 1.4.68-beta and also affects the latest 1.5.83 beta.Root Cause
In microsoft/Agents-for-net@90e3d788 ("Using RouteBuilders internally", version 1.4.68-beta),
AgentApplication.AddRoute(RouteSelector, ...)gained a newbool isAgenticOnly = falseparameter. Routes created withisAgenticOnly: true(e.g., viaOnActivity) are now flagged withRouteFlags.Agentic, which gives themOrder = Agentic(1)inRouteList— sorted before allOrder = Other(0)routes regardless of rank or insertion order.AgentExtension.AddRoute(used byAgentNotification.OnAgentNotificationandOnLifecycleNotification) callsAgentApplication.AddRoutewithout passingisAgenticOnly, so it defaults tofalse. This means notification routes are classified asOther(0)and are evaluated after anyAgentic(1)routes.In 1.4.1,
AddRoutehad noisAgenticOnlyparameter — both notification and message routes wereOther(0), so insertion order determined priority andOnAgentNotification(registered first) won.In 1.4.68+,
OnActivity(Message, isAgenticOnly: true)isAgentic(1)and always evaluated first, intercepting notifications beforeOnAgentNotificationgets a chance.Timeline
Other(0)→ insertion order wins → notifications routed correctlyAddRoutegainsisAgenticOnlyparam;OnActivitynow usesTypeRouteBuilder.AsAgentic(true)— breaking changeAgentic(1), notification routes remainOther(0)Fix
Mark A365 notification routes as agentic since they are always agentic requests (
recipient.role = agenticUser):Applied to both
OnAgentNotificationandOnLifecycleNotificationinAgentNotification.cs.Additional changes
Microsoft.Agents.Authentication.Msal1.4.83AgentApplication.OnTurnAsyncdispatch pipeline, proving notification handlers win over competing generic agentic message handlers. WithisAgenticOnly: false, 7 of 9 tests fail.