Skip to content

Python: [Bug]: Responses stream parser silently drops unhandled platform/hosted tool call and result item types, causing AG-UI tool calls to go missing or show "tool calls missing results" #8068

Description

@djw-bsn

Description

When a Foundry hosted agent uses a Foundry Toolbox to dispatch a knowledge-base tool call, the Responses API emits the result as a response.output_item.added item with type == "function_call_output". agent_framework_openai has no handler for this item type, logs it as unparsed, and discards it. No Content.from_function_result(...) reaches agent_framework_ag_ui.

Downstream, this means:

  • agent_framework_ag_ui emits TOOL_CALL_END but no matching TOOL_CALL_RESULT; its fallback treats the call as declaration-only.

The model still receives and uses the real output, but the structured result never reaches the AG-UI client.

Caveat: the model sees a generic call_tool wrapper; the Toolbox executes the inner MCP tool locally and ResponsesHostServer intentionally serializes its function_result as the standard function_call_output Responses item. The same KB tool called directly is a normal mcp_call and works, confirming this is a client-parser gap rather than a KB-tool failure.

Reproduction

  1. Configure a Foundry hosted agent with a Foundry Toolbox connected to a knowledge-base retrieval tool. The agent must call the KB tool through the toolbox's generic call_tool function; a direct call does not reproduce this.
  2. Drive it via agent_framework_ag_ui's AgentFrameworkAgent.run() (AG-UI protocol) with DEBUG logging enabled for agent_framework.openai.
  3. Ask a question that triggers the hosted tool.
  4. Observe, with DEBUG logging on agent_framework.openai:
    DEBUG agent_framework.openai - Unparsed event of type: response.output_item.added:
    ResponseOutputItemAddedEvent(item=ResponseFunctionToolCallOutputItem(...,
    call_id='call_XXXX', output='<actual tool result text>',
    type='function_call_output', ...))
    
  5. The stream emits TOOL_CALL_END but no matching TOOL_CALL_RESULT. agent_framework_ag_ui._agent_run logs:
    INFO agent_framework_ag_ui._agent_run - Found 1 pending tool calls without end event
    INFO agent_framework_ag_ui._agent_run - Emitting ToolCallEndEvent for declaration-only tool 'call_XXXX'
    
    No function_result content is produced, despite the successful tool output in step 4.

Controls

  • The same FoundryIQ KB tool called directly, without a Toolbox, is exposed as mcp_call and produces the complete TOOL_CALL_STARTTOOL_CALL_ENDTOOL_CALL_RESULT lifecycle. This shows the issue is specific to the local Toolbox execution path, not the KB tool.
  • A Databricks Genie tool routed through mcp_call also works correctly.
  • A SharePoint grounding preview emits sharepoint_grounding_preview_call and sharepoint_grounding_preview_call_output, which are both logged as unparsed and produce no AG-UI events. This is secondary evidence because the feature is preview.

Expected behavior

Parse function_call_output into Content.from_function_result(call_id=..., result=event_item.output, ...) so agent_framework_ag_ui emits the matching TOOL_CALL_RESULT. Other supported Responses item types should likewise be handled instead of silently dropped.

Suggested fix location

Add function_call_output handling to agent_framework_openai/_chat_client.py. The SharePoint preview types may need equivalent handling.

Code Sample

Error Messages / Stack Traces

Package Versions

agent-framework-openai==1.14.2, agent-framework-core==1.17.0, agent-framework-ag-ui==1.2.2, agent-framework-foundry==1.12.0

Python Version

Python 3.12

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions