Skip to content

Small tweaks to HTTP-related adapter code - #514

Merged
Rodrigo Brandão (rodrigobr-msft) merged 3 commits into
mainfrom
users/robrandao/small-fries
Jul 31, 2026
Merged

Small tweaks to HTTP-related adapter code#514
Rodrigo Brandão (rodrigobr-msft) merged 3 commits into
mainfrom
users/robrandao/small-fries

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

No description provided.

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 makes small adjustments to the hosting SDK’s HTTP abstractions and adapter integration points, aiming to improve cross-framework compatibility and tighten type usage.

Changes:

  • Makes HttpResponse.content_type non-optional and updates the aiohttp adapter to always pass a default content type.
  • Broadens HttpRequestProtocol.headers from dict to Mapping to better match framework header types.
  • Adjusts the microsoft_agents.hosting.core public exports to expose _Route instead of the previously exported (but undefined) Route.

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 Tightens HttpResponse.content_type typing, impacting response factory behavior.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/http/_http_request_protocol.py Updates request header typing to Mapping for framework compatibility.
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py Changes the package export surface around route types.
libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/cloud_adapter.py Ensures aiohttp responses always receive a non-empty content_type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings July 31, 2026 18:59

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 no new comments.

Suppressed comments (2)

libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py:137

  • Exporting "_Route" from the top-level hosting.core package exposes an internal (underscore-prefixed) class in the public interface. If the intent is to provide a public route type, add a public alias (Route = _Route) and export "Route" instead, which also keeps star-imports working without leaking the private name.
    "ApplicationOptions",
    "InputFile",
    "InputFileDownloader",
    "Query",
    "_Route",
    "RouteHandler",

libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/cloud_adapter.py:72

  • Passing content_type through to aiohttp.web.Response unconditionally can crash when HttpResponseFactory.accepted() sets content_type=None (aiohttp expects a str for content_type). Only include content_type when it is not None, so 202 Accepted (and other no-body responses) can omit the header safely.
        return Response(
            status=http_response.status_code,
            headers=http_response.headers,
            content_type=http_response.content_type,
        )

Copilot AI review requested due to automatic review settings July 31, 2026 20:08
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit 686fb90 into main Jul 31, 2026
17 of 18 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/small-fries branch July 31, 2026 20: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 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (2)

libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py:136

  • core.init now exports the private routing type name ("_Route") in all, but there is still no public Route symbol to import. If Route is intended to be part of the public surface, add a Route alias for _Route and export both names (or at least Route) so users don’t have to depend on a private underscore-prefixed type.
    "ApplicationOptions",
    "InputFile",
    "InputFileDownloader",
    "Query",
    "_Route",

libraries/microsoft-agents-hosting-aiohttp/microsoft_agents/hosting/aiohttp/cloud_adapter.py:72

  • _to_aiohttp_response now always forwards http_response.content_type into aiohttp.web.Response() for empty-body responses, but HttpResponseFactory.accepted() sets content_type=None. Passing None through as content_type can lead to invalid/ambiguous response construction; only include the content_type kwarg when it’s a non-None string.
        return Response(
            status=http_response.status_code,
            headers=http_response.headers,
            content_type=http_response.content_type,
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants