Repository navigation
Description
Description
When a Foundry agent is backed by an MCP server that requires OAuth consent, FoundryAgent (which uses the Responses API) silently drops the oauth_consent_request stream events. The consent link is never surfaced to the caller.
This is a regression from AzureAIClient (Assistants API), which correctly emits a CUSTOM AG-UI event with name="oauth_consent_request" that callers can intercept.
Environment
| Client | agent_framework.foundry.FoundryAgent (new) |
| Upstream API | Azure OpenAI Responses API |
| MCP server | Databricks Genie MCP server requiring OAuth consent |
| AG-UI layer | agent_framework_ag_ui |
Steps to Reproduce
- Configure a Foundry agent with an MCP server that requires OAuth consent (e.g. Databricks Genie MCP server)
- Instantiate the agent using
FoundryAgent/FoundryChatClient - Send a request that triggers MCP tool listing - causing the MCP server to require OAuth
Expected Behaviour
A CUSTOM AG-UI event is emitted with:
{
"type": "CUSTOM",
"name": "oauth_consent_request",
"value": {
"consent_link": "https://[consent-host]/login?data=..."
}
}This is the behaviour produced by AzureAIClient (Assistants API path) and is what downstream callers depend on to surface the consent link to the user.
Actual Behaviour
The Responses API stream delivers two OAuth-related events:
response.output_item.added -> item.type = 'oauth_consent_request' (contains consent_link)
response.oauth_consent_requested -> (also contains consent_link)
Both fall through to the case _: catchall in RawOpenAIChatClient's streaming event handler:
case _:
logger.debug("Unparsed event of type: %s: %s", event.type, event)Neither event is translated into a CUSTOM AG-UI event. The consent link is never surfaced to the caller. The stream completes normally with no output and no error.
Evidence
Broken (FoundryAgent - Responses API)
[DEBUG] agent_framework.openai - Unparsed event of type: response.output_item.added:
ResponseOutputItemAddedEvent(item=ResponseOutputMessage(..., type='oauth_consent_request',
consent_link='https://[consent-host]/login?data=...'), ...)
[DEBUG] agent_framework.openai - Unparsed event of type: response.oauth_consent_requested:
ResponseAudioDeltaEvent(..., consent_link='https://...', ...)
[DEBUG] backend - Stream completed normally
No CUSTOM event. No consent link surfaced. Stream exits silently.
Working (AzureAIClient - Assistants API)
[DEBUG] agent_framework_ag_ui - Emitting CUSTOM AG-UI event: name='oauth_consent_request' value={'consent_link': 'https://[consent-host]/login?data=...'}
CUSTOM AG-UI event emitted correctly. Consent link surfaced and forwarded to the frontend.
Root Cause
RawOpenAIChatClient's streaming event handler (the match event.type block) has no case for:
"response.oauth_consent_requested""response.output_item.added"whereitem.type == "oauth_consent_request"
These event types are present in the commented-out section of the handler (confirming awareness), but no implementation exists:
# ResponseMcpListToolsCompletedEvent,
# ResponseMcpListToolsFailedEvent,
# ResponseMcpListToolsInProgressEvent,The agent_framework_ag_ui layer does handle the equivalent signal from the Assistants API and emits a CUSTOM event - but the Responses API path has no equivalent handling.
Impact
Any agent migrated from AzureAIClient -> FoundryAgent that uses an MCP server with OAuth consent will silently break. The migration is actively encouraged (the deprecation warning on AzureAIClient reads: "Use OpenAIChatClient with an AsyncAzureOpenAI client, or FoundryChatClient for Foundry projects"), making this a migration blocker.
Fix Required
In RawOpenAIChatClient's streaming event handler, add handling for the OAuth consent events and emit an appropriate signal - either:
- A
CUSTOMAG-UI event withname="oauth_consent_request"andvalue={"consent_link": "..."}, consistent with the Assistants API behaviour; or - A dedicated exception type (e.g.
OAuthConsentRequiredException) that callers can catch
Option 1 is preferred for backward compatibility with existing callers.
case "response.oauth_consent_requested":
consent_link = getattr(event, "consent_link", None)
if consent_link:
contents.append(
Content.custom(name="oauth_consent_request", value={"consent_link": consent_link})
)Workaround
Revert to AzureAIClient for any agent that requires MCP OAuth consent until this is resolved.
# Temporary workaround - revert to deprecated client
from agent_framework.azure import AzureAIClientCode Sample
Error Messages / Stack Traces
Package Versions
agent-framework-core==1.0.0rc6, agent-framework-foundry==1.0.0rc6, agent_framework_ag_ui==1.0.0b260330
Python Version
Python 3.12
Additional Context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Fix Foundry clients not surfacing oauth_consent_request events (micro…
Address PR review feedback for microsoft#5054 OAuth consent parsing
Handle response.oauth_consent_requested top-level event (microsoft#5054)
Address review feedback for microsoft#5054: Python: [Bug]: `FoundryAg…
Address review feedback: defensive getattr and dedicated helper tests (…
Address review feedback for microsoft#5054: Python: [Bug]: `FoundryAg…
djw-bsn commentedon Apr 17, 2026
Correction: Bug confirmed present in
agent-framework-openai==1.0.1— workaround no longer viable on 1.0.1The package versions in the original report were incorrect. Those were the versions we reverted to as a workaround, not the versions exhibiting the bug. Corrected versions:
Bug confirmed in 1.0.1. In
agent_framework_openai/_chat_client.py, theresponse.output_item.addedhandler matches onevent_item.typebut has no case foroauth_consent_request— it falls through tocase _:. Similarly,response.oauth_consent_requestedhas no case in the outer match and also falls through. Both events are silently dropped in 1.0.1, consistent with the original report.The documented workaround is no longer viable for anyone upgrading to 1.0.1.
AzureAIClientwas only available inagent-framework-azure-ai, which was never promoted past1.0.0rc6. Pinningagent-framework-azure-ai==1.0.0rc6alongsideagent-framework-core==1.0.1also fails due to a breaking API rename (BaseContextProvider→ContextProvider), making the mixed-version approach unviable. The only workaround is to remain on the fullrc6package set, which is increasingly untenable given the active deprecation warnings pushing users towardFoundryAgent.Python: Surface `oauth_consent_request` events from Responses API in …