Skip to content

Python: [Bug]: MCP Tool Calls + Reasoning Not Emitted as AG-UI Events (Foundry) #4213

@djw-bsn

Description

@djw-bsn

Description

On Foundry (Responses API) streams, mcp_server_tool_call, mcp_server_tool_result, and text_reasoning content items are received by the server but produce no AG-UI SSE events because they fall through unhandled in _emit_content.

Impact: frontends consuming AG-UI events cannot display MCP tool execution state (tool call start/result) and cannot reflect reasoning/progress during text_reasoning.

Scope

Foundry agents only (Azure AI Foundry / OpenAI Responses API MCP tool items).

Standard function_call / function_result mapping is unaffected.

Where It Happens

agent_framework_ag_ui/_run.py::run_agent_stream dispatches each streamed content item through _emit_content(...) and yields whatever events it returns. If _emit_content returns [] for a given content type, nothing is emitted to the SSE stream.

# Emit events for each content item
for content in update.contents:
    content_type = getattr(content, "type", None)
    logger.debug(f"Processing content type={content_type}, message_id={flow.message_id}")
    for event in _emit_content(
        content,
        flow,
        predictive_handler,
        skip_text,
        config.require_confirmation,
    ):
        yield event

Evidence / Symptoms

Server debug shows content arriving, e.g.:

Processing content type=mcp_server_tool_call

Processing content type=mcp_server_tool_result

AG-UI SSE stream shows no TOOL_CALL_* events for those items.

Root Cause

_emit_content only handles text, function_call, function_result, and function_approval_request. The Foundry MCP and reasoning content types are not handled and therefore return [].

Expected Fix

Add handling in _emit_content for:

mcp_server_tool_call → emit tool-call start (same as function_call mapping)

mcp_server_tool_result → emit tool-call result (same as function_result mapping)

text_reasoning → emit some progress/timing-visible event (e.g. a state/progress delta) so reasoning is not silently invisible

This makes MCP tool calls and text_reasoning visible to AG-UI consumers.

Code Sample

Error Messages / Stack Traces

Package Versions

agent-framework-ag-ui==1.0.0b260219 agent-framework-azure-ai==1.0.0rc1 agent-framework-core==1.0.0rc1

Python Version

Python 3.12

Additional Context

No response

Metadata

Metadata

Labels

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions