AgentApplication route registration improvements - #429
Merged
Rodrigo Brandão (rodrigobr-msft) merged 5 commits intoJun 23, 2026
Conversation
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
June 18, 2026 22:21
View session
Rodrigo Brandão (rodrigobr-msft)
marked this pull request as ready for review
June 18, 2026 22:21
This was
linked to
issues
Jun 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors AgentApplication route registration to make selectors more flexible (supporting lists/patterns) and improves handoff registration ergonomics (decorator vs direct-call) with better typing. It also adds focused routing tests and applies minor test formatting cleanups.
Changes:
- Extend route selector behavior to accept lists for activity type and message match criteria (including regex patterns).
- Refactor
AgentApplication.handoffto support both decorator and direct-call usage, and adjust handler registration behavior. - Add new routing-focused tests and apply formatting/whitespace cleanups in existing tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/agent_application.py | Adds list/pattern selector support and refactors handoff registration/typing. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/turn_context.py | Adds a return type annotation for TurnContext.activity. |
| tests/hosting_core/app/test_agent_application_routes.py | New tests covering activity/message selectors, handoff routing, and route ordering. |
| tests/hosting_teams/test_teams_agent_extension.py | Test formatting-only changes for readability/consistency. |
| tests/hosting_core/app/proactive/test_proactive.py | Removes an unnecessary blank line. |
| tests/hosting_core/app/proactive/test_conversation_reference_builder.py | Removes an unnecessary blank line. |
| tests/hosting_core/app/proactive/test_conversation_builder.py | Removes an unnecessary blank line. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
June 18, 2026 22:38
View session
Axel Suárez (axelsrz)
requested changes
Jun 19, 2026
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
June 22, 2026 15:08
View session
Rodrigo Brandão (rodrigobr-msft)
enabled auto-merge (squash)
June 22, 2026 15:51
Axel Suárez (axelsrz)
approved these changes
Jun 23, 2026
Rodrigo Brandão (rodrigobr-msft)
deleted the
users/robrandao/agent-application
branch
June 23, 2026 17:56
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.
This pull request introduces several improvements and refactors to the
AgentApplicationcore logic, particularly around route selectors and handler registration, as well as minor test code cleanups and formatting. The most significant changes are the enhanced flexibility in route selectors to support lists and patterns, improvements to thehandoffmethod's typing and decorator usability, and various test code formatting updates for clarity.Core Logic Improvements
agent_application.pyto support lists of allowedactivity_typevalues and lists of text or regex patterns for matching, making route definitions more flexible and expressive. [1] [2]handoffmethod inAgentApplicationto support both decorator and direct-call usage with proper type annotations and overloads, improving developer ergonomics and static analysis. [1] [2]handoffto wrap the provided function and ensure the correct handler is registered with the router, not the original function.activityproperty inTurnContextfor better type checking, with atype: ignorecomment to suppress mypy errors.Test Code Formatting and Cleanup
test_teams_agent_extension.pyto use consistent argument formatting and improved readability in context creation, without changing test logic. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]