Small tweaks for microsoft_agents.hosting.core.http modules - #445
Closed
Rodrigo Brandão (rodrigobr-msft) wants to merge 5 commits into
Closed
Small tweaks for microsoft_agents.hosting.core.http modules#445Rodrigo Brandão (rodrigobr-msft) wants to merge 5 commits into
Rodrigo Brandão (rodrigobr-msft) wants to merge 5 commits into
Conversation
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 7, 2026 18:17
View session
This was
linked to
issues
Jul 7, 2026
Rodrigo Brandão (rodrigobr-msft)
marked this pull request as ready for review
July 7, 2026 18:19
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the framework-agnostic HTTP layer in microsoft_agents.hosting.core.http by improving type annotations for channel service route handlers and tweaking how 202 Accepted responses are represented.
Changes:
- Added a bounded
TypeVarto makedeserialize_from_body/serialize_modelmore type-safe forAgentsModelsubclasses, and widened handler return types to allow list-shaped JSON payloads. - Updated
HttpResponseFactory.accepted()to explicitly setcontent_type=Nonefor 202 responses. - Adjusted multiple
ChannelServiceRouteshandler method return annotations to reflect that some endpoints may return collections.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_response.py | Makes 202 Accepted responses explicitly omit a content type in the abstraction. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_channel_service_routes.py | Introduces a generic AgentsModelT and broadens route handler return typing to support list responses. |
💡 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 7, 2026 18:21
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_channel_service_routes.py:149
get_conversationscallsself.handler.on_get_conversations(request.get_claims_identity(), None), butChannelApiHandlerProtocol.on_get_conversationscurrently typesconversation_idasstr(and the connector client API doesn’t take a conversation_id at all). PassingNonehere is inconsistent with the protocol and can break handler implementations that expect a string. Consider reconciling the protocol and this route (e.g., make the parameter an Optional continuation_token, or remove/rename it) so the call site is type-correct and unambiguous.
) -> dict | list[dict]:
"""Handle GET /."""
# TODO: continuation token? conversation_id?
result = await self.handler.on_get_conversations(
request.get_claims_identity(), None
Rodrigo Brandão (rodrigobr-msft)
enabled auto-merge (squash)
July 8, 2026 19:18
Copilot started reviewing on behalf of
Rodrigo Brandão (rodrigobr-msft)
July 8, 2026 19:19
View session
Comment on lines
+189
to
197
| async def delete_conversation_member(self, request: HttpRequestProtocol) -> None: | ||
| """Handle DELETE /v3/conversations/{conversation_id}/members/{member_id}.""" | ||
| conversation_id = request.get_path_param("conversation_id") | ||
| member_id = request.get_path_param("member_id") | ||
| result = await self.handler.on_delete_conversation_member( | ||
| await self.handler.on_delete_conversation_member( | ||
| request.get_claims_identity(), | ||
| conversation_id, | ||
| member_id, | ||
| ) |
Comment on lines
39
to
49
| @@ -47,7 +49,9 @@ async def deserialize_from_body( | |||
| return target_model.model_validate(body) | |||
auto-merge was automatically disabled
July 8, 2026 19:30
Pull request was closed
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 updates the
ChannelServiceRoutesclass inmicrosoft_agents/hosting/core/http/_channel_service_routes.pyto improve type safety and response flexibility. The main changes ensure that handler methods and serialization/deserialization routines are more generic and can handle both single models and lists of models, supporting a wider range of API responses.Type Safety and Serialization Improvements:
AgentsModelTto makedeserialize_from_bodyandserialize_modelmethods type-safe for any subclass ofAgentsModel. Now, these methods can handle both single models and lists, returning appropriately typed results. [1] [2] [3] [4]send_to_conversation,reply_to_activity, etc.) to return either a single dictionary or a list of dictionaries, reflecting that handlers may return a single object or a collection. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]HTTP Response Consistency:
accepted()static method inHttpResponseto explicitly setcontent_type=Nonefor 202 responses, ensuring consistent response formatting.