Fix #777 by handling MCPCall events in RunImpl (#799)

This pull request resolves #777; If you think we should introduce a new
item type for MCP call output, please let me know. As other hosted tools
use this event, I believe using the same should be good to go tho.
This commit is contained in:
Kazuhiro Sera 2025-06-03 00:10:07 +09:00 committed by GitHub
parent cfe9099f3f
commit 3e7b2863e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View file

@ -48,7 +48,7 @@ async def main(verbose: bool, stream: bool):
print(res.final_output) print(res.final_output)
if verbose: if verbose:
for item in result.new_items: for item in res.new_items:
print(item) print(item)

View file

@ -34,7 +34,7 @@ async def main(verbose: bool, stream: bool):
# The repository is primarily written in multiple languages, including Rust and TypeScript... # The repository is primarily written in multiple languages, including Rust and TypeScript...
if verbose: if verbose:
for item in result.new_items: for item in res.new_items:
print(item) print(item)

View file

@ -33,6 +33,7 @@ from openai.types.responses.response_output_item import (
ImageGenerationCall, ImageGenerationCall,
LocalShellCall, LocalShellCall,
McpApprovalRequest, McpApprovalRequest,
McpCall,
McpListTools, McpListTools,
) )
from openai.types.responses.response_reasoning_item import ResponseReasoningItem from openai.types.responses.response_reasoning_item import ResponseReasoningItem
@ -456,6 +457,9 @@ class RunImpl:
) )
elif isinstance(output, McpListTools): elif isinstance(output, McpListTools):
items.append(MCPListToolsItem(raw_item=output, agent=agent)) items.append(MCPListToolsItem(raw_item=output, agent=agent))
elif isinstance(output, McpCall):
items.append(ToolCallItem(raw_item=output, agent=agent))
tools_used.append("mcp")
elif isinstance(output, ImageGenerationCall): elif isinstance(output, ImageGenerationCall):
items.append(ToolCallItem(raw_item=output, agent=agent)) items.append(ToolCallItem(raw_item=output, agent=agent))
tools_used.append("image_generation") tools_used.append("image_generation")