Python: fix(foundry-hosting): emit oauth_consent_request and function_approval_request#5537
Open
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
Open
Python: fix(foundry-hosting): emit oauth_consent_request and function_approval_request#5537mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
mvanhorn wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…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.
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.
Motivation and Context
Fixes #5535.
When
ResponsesHostServerreceives streaming Content of typeoauth_consent_requestorfunction_approval_requestfrom a Foundry MCP toolbox, the SSE stream returnsoutput: []and the consent link / approval prompt is silently dropped with a warning: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()inagent_framework_foundry_hosting._responseshad no handler for either type, so they fell through to the warning branch.Description
Adds two
elifbranches to_to_outputs(right before the finalelsewarning), both using the existingaoutput_item_messageSSE helper:oauth_consent_requestemits a text message containing the consent URL and the MCP server label (fromadditional_properties.server_label).function_approval_requestemits a text message describing the function name, server label, request id, and arguments. The Content carries a nestedfunction_callwithname/arguments, which we surface via the existing_arguments_to_strhelper.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.pyfor 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 passedruff check— cleanruff format --check— cleanContribution Checklist