Skip to content

Fix #777 by handling MCPCall events in RunImpl #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/hosted_mcp/approvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def main(verbose: bool, stream: bool):
print(res.final_output)

if verbose:
for item in result.new_items:
for item in res.new_items:
print(item)


Expand Down
2 changes: 1 addition & 1 deletion examples/hosted_mcp/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def main(verbose: bool, stream: bool):
# The repository is primarily written in multiple languages, including Rust and TypeScript...

if verbose:
for item in result.new_items:
for item in res.new_items:
print(item)


Expand Down
4 changes: 4 additions & 0 deletions src/agents/_run_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ImageGenerationCall,
LocalShellCall,
McpApprovalRequest,
McpCall,
McpListTools,
)
from openai.types.responses.response_reasoning_item import ResponseReasoningItem
Expand Down Expand Up @@ -456,6 +457,9 @@ def process_model_response(
)
elif isinstance(output, McpListTools):
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):
items.append(ToolCallItem(raw_item=output, agent=agent))
tools_used.append("image_generation")
Expand Down