Skip to content

Python: [Bug]: response.oauth_consent_requested events silently dropped - OAuth consent link never surfaces to callers #3950

@djw-bsn

Description

@djw-bsn

Description

What happened?

When a Foundry-hosted agent requires OAuth consent for a connected MCP tool (e.g., identity passthrough), the Azure AI Agent Service returns a response.oauth_consent_requested SSE event containing a consent_link URL. The SDK logs "Unparsed event of type: response.oauth_consent_requested" and discards it. The event never appears on AgentResponseUpdate.contents, so consuming code has no way to detect it or present the consent URL to the end user. The agent run completes with zero content — the user sees nothing.

Additionally, even if the base SDK did parse this event, agent-framework-ag-ui's _emit_content only handles text, function_call, function_result, and function_approval_request — there is no mapping for consent events to AG-UI protocol events.

What did you expect to happen?

The SDK should parse response.oauth_consent_requested into a typed content object (e.g., OAuthConsentContent with a consent_link: str field) and include it in AgentResponseUpdate.contents.
agent-framework-ag-ui should emit this as a CUSTOM event (or similar) so frontends can render an actionable link for the user to complete OAuth consent.

Steps to reproduce the issue:

  • Configure a Foundry agent with an MCP tool that uses OAuth identity passthrough
  • Call the agent via agent-framework Python SDK before the user has completed OAuth consent
  • Observe Unparsed event of type: response.oauth_consent_requested in logs
  • No content is returned to the caller — the run finishes silently

Code Sample

from agent_framework import Agent, AgentSession
from agent_framework.azure import AzureAIClient

client = AzureAIClient(
    project_endpoint="https://<project>.services.ai.azure.com/api",
    credential=credential,
    agent_name="my-agent-with-oauth-mcp-tool",
    use_latest_version=True,
)

agent = Agent(client, None, name="my-agent")
session = AgentSession()

async for update in agent.run("query that triggers the MCP tool", session=session):
    # update.contents is empty — consent event was dropped
    print(update)

Error Messages / Stack Traces

Unparsed event of type: response.oauth_consent_requested


No exception is raised. The run completes normally but with zero content updates. The raw SSE stream from the service contains:


event: response.oauth_consent_requested
data: {"consent_link": "https://login.microsoftonline.com/..."}


This data is available in the wire stream but discarded by the SDK's event parser before it reaches user code.

Package Versions

agent-framework-core: 1.0.0b260212 agent-framework-azure-ai: 1.0.0b260212 agent-framework-ag-ui: 1.0.0b260212

Python Version

Python 3.12

Additional Context

Two layers need updates:

agent-framework-core / agent-framework-azure-ai - The SSE response parser needs to recognize response.oauth_consent_requested and oauth_consent_request output items, and produce a typed content object instead of logging "Unparsed event" and dropping it.

agent-framework-ag-ui - _emit_content needs a handler for the new content type, mapping it to an AG-UI event (likely CUSTOM) so frontends can render the consent link.

This is a blocker for any scenario where Foundry agents use OAuth-protected MCP tools and the consuming application needs to guide users through the consent flow programmatically.

Metadata

Metadata

Assignees

Labels

agentsIssues related to single agentsbugSomething isn't workingpythonv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions