Skip to content

Python: fix(foundry-hosting): emit oauth_consent_request and function_approval_request#5537

Open
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn:osc/5535-foundry-hosting-oauth-emission
Open

Python: fix(foundry-hosting): emit oauth_consent_request and function_approval_request#5537
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn:osc/5535-foundry-hosting-oauth-emission

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Motivation and Context

Fixes #5535.

When ResponsesHostServer receives streaming Content of type oauth_consent_request or function_approval_request from a Foundry MCP toolbox, the SSE stream returns output: [] and the consent link / approval prompt is silently dropped with a warning:

WARNING:agent_framework_foundry_hosting._responses:Content type 'oauth_consent_request' is not supported yet. This is usually safe to ignore.

PR #5070 fixed the streaming chunk parser so these content types now surface from the Responses API into the agent framework. The remaining gap was in the hosting layer's SSE emission: _to_outputs() in agent_framework_foundry_hosting._responses had no handler for either type, so they fell through to the warning branch.

Description

Adds two elif branches to _to_outputs (right before the final else warning), both using the existing aoutput_item_message SSE helper:

  1. oauth_consent_request emits a text message containing the consent URL and the MCP server label (from additional_properties.server_label).
  2. function_approval_request emits a text message describing the function name, server label, request id, and arguments. The Content carries a nested function_call with name/arguments, which we surface via the existing _arguments_to_str helper.

No SSE wire-format changes. No new dependencies. The reporter's monkey-patch workaround in the issue body is replaced by upstream support so users do not have to patch.

Adds unit coverage in test_responses.py for both new branches: each test calls _to_outputs(stream, content) directly with a mocked stream and asserts the emitted text contains the consent link / function name.

Verified locally:

  • pytest packages/foundry_hosting/tests/test_responses.py — 90 passed
  • ruff check — clean
  • ruff format --check — clean

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? No.

…l_request in _to_outputs (microsoft#5535)

ResponsesHostServer was silently dropping oauth_consent_request and
function_approval_request content from MCP toolboxes. PR microsoft#5070 fixed
the streaming parser so these content types now reach the hosting
layer; only _to_outputs() in agent_framework_foundry_hosting._responses
was missing handlers, so the SSE stream returned output: [] with a
warning log instead of surfacing the consent link or approval prompt.

Add explicit branches that emit the relevant payload as a text message
via the existing aoutput_item_message helper, so clients can act on the
consent URL and approval request. Add unit coverage for both branches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: ResponsesHostServer drops oauth_consent_request and function_approval_request from toolbox MCP connectors

2 participants