Skip to content

ChannelServiceRoutes improved treatment of handler results#462

Open
rodrigobr-msft wants to merge 9 commits into
mainfrom
users/robrandao/channel-service-routes
Open

ChannelServiceRoutes improved treatment of handler results#462
rodrigobr-msft wants to merge 9 commits into
mainfrom
users/robrandao/channel-service-routes

Conversation

@rodrigobr-msft

@rodrigobr-msft rodrigobr-msft commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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:

  • Introduced a generic type variable AgentsModelT to the ChannelServiceRoutes class and updated the deserialize_from_body and serialize_model methods to use this generic type, allowing for more precise type checking and flexibility when working with different agent models. Overloads were added to serialize_model for single models and lists of models. [1] [2] [3] [4]

Response Typing and Consistency:

  • Updated the return types of get_activity_members and get_conversation_members methods to return list[dict] instead of dict, reflecting the actual data returned and improving type safety. [1] [2]
  • Modified the json_response helper in the aiohttp integration to accept both dict and list[dict], ensuring compatibility with updated route handler return types.

Error Handling and Robustness:

  • Improved error handling in delete_conversation_member to return an empty dictionary if no result is found, preventing serialization errors and ensuring consistent response shapes.
  • Enhanced the initialization logic of HttpAdapterBase to require either a channel_service_client_factory or a connection_manager, raising a clear error if neither is provided. This ensures proper configuration and prevents runtime issues.

Minor Response Fix:

  • Set content_type=None in the accepted() static method of HttpResponse to clarify the response type for 202 responses.

Copilot AI review requested due to automatic review settings July 10, 2026 21:08
@rodrigobr-msft rodrigobr-msft changed the title ChannelServiceRoutes improved processing of handler results ChannelServiceRoutes improved treatment of handler results Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 HttpAdapterBase initialization and tweaked HttpResponseFactory.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 AI review requested due to automatic review settings July 13, 2026 17:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rodrigobr-msft rodrigobr-msft marked this pull request as ready for review July 13, 2026 17:15
@rodrigobr-msft rodrigobr-msft requested a review from a team as a code owner July 13, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 13, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 13, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread libraries/microsoft-agents-hosting-fastapi/readme.md
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread libraries/microsoft-agents-hosting-fastapi/readme.md
Copilot AI review requested due to automatic review settings July 13, 2026 18:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment on lines 95 to +99
from microsoft_agents.hosting.fastapi import start_agent_process, CloudAdapter
from microsoft_agents.hosting.core.app import AgentApplication

app = FastAPI()
adapter = CloudAdapter()
connection_manager = MsalConnectionManager(**agents_sdk_config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants