ChannelServiceRoutes improved treatment of handler results - #462
Merged
Rodrigo Brandão (rodrigobr-msft) merged 10 commits intoJul 22, 2026
Merged
Conversation
ChannelServiceRoutes improved processing of handler resultsChannelServiceRoutes improved treatment of handler results
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 10, 2026 21:09
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the hosting HTTP channel service pipeline by making handler result serialization more type-safe and aligning route handler return shapes with what the HTTP layers can reliably serialize, while also tightening adapter initialization requirements.
Changes:
- Added generic/overloaded serialization + generic deserialization to improve type safety in
ChannelServiceRoutes. - Adjusted member endpoints to return
list[dict]and delete endpoints to return empty payloads where appropriate. - Hardened
HttpAdapterBaseinitialization and tweakedHttpResponseFactory.accepted()to avoid content-type issues on empty responses.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_response.py | Adjusts 202 Accepted response metadata for empty responses. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_adapter_base.py | Makes adapter initialization stricter by requiring a client factory or connection manager. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_channel_service_routes.py | Improves typing/serialization and updates endpoint handler return shapes. |
| libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/channel_service_route_table.py | Updates aiohttp JSON response helper typing to support list payloads. |
💡 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)
July 13, 2026 17:05
View session
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 13, 2026 17:11
View session
This was
linked to
issues
Jul 13, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Rodrigo Brandão (rodrigobr-msft)
marked this pull request as ready for review
July 13, 2026 17:15
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 13, 2026 17:22
View session
…ub.com/microsoft/Agents-for-python into users/robrandao/channel-service-routes
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 13, 2026 17:50
View session
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 13, 2026 18:14
View session
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 13, 2026 18:21
View session
Kyle Rohn (kylerohn-msft)
approved these changes
Jul 22, 2026
Rodrigo Brandão (rodrigobr-msft)
enabled auto-merge (squash)
July 22, 2026 17:31
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 22, 2026 17:32
View session
Rodrigo Brandão (rodrigobr-msft)
merged commit Jul 22, 2026
74e1959
into
main
10 of 11 checks passed
Rodrigo Brandão (rodrigobr-msft)
deleted the
users/robrandao/channel-service-routes
branch
July 22, 2026 17:34
Comment on lines
+192
to
+194
| if result: | ||
| return self.serialize_model(result) | ||
| return {} |
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 type-safety enhancements to the channel service HTTP route handling, especially around serialization, deserialization, and response typing. The changes ensure better type consistency, clearer error handling, and improved compatibility with different model types.
Type and Serialization Improvements:
AgentsModelTto theChannelServiceRoutesclass and updated thedeserialize_from_bodyandserialize_modelmethods to use this generic type, allowing for more precise type checking and flexibility when working with different agent models. Overloads were added toserialize_modelfor single models and lists of models. [1] [2] [3] [4]Response Typing and Consistency:
get_activity_membersandget_conversation_membersmethods to returnlist[dict]instead ofdict, reflecting the actual data returned and improving type safety. [1] [2]json_responsehelper in the aiohttp integration to accept bothdictandlist[dict], ensuring compatibility with updated route handler return types.Error Handling and Robustness:
delete_conversation_memberto return an empty dictionary if no result is found, preventing serialization errors and ensuring consistent response shapes.HttpAdapterBaseto require either achannel_service_client_factoryor aconnection_manager, raising a clear error if neither is provided. This ensures proper configuration and prevents runtime issues.Minor Response Fix:
content_type=Nonein theaccepted()static method ofHttpResponseto clarify the response type for 202 responses.