Skip to content

Conversation

@stneng
Copy link

@stneng stneng commented Dec 26, 2025

#1898 adds support for image outputs in functions; the existing fallback logic in MCP tools below is outdated.

# Fall back to regular text content processing
# The MCP tool result is a list of content items, whereas OpenAI tool
# outputs are a single string. We'll try to convert.
if len(result.content) == 1:
tool_output = result.content[0].model_dump_json()
elif len(result.content) > 1:
tool_results = [item.model_dump(mode="json") for item in result.content]
tool_output = json.dumps(tool_results)
else:
# Empty content is a valid result (e.g., "no results found")
tool_output = "[]"

Resolves #2148 and https://community.openai.com/t/image-response-from-an-mcp-server-with-agents-sdk/1269441

@seratch
Copy link
Member

seratch commented Dec 27, 2025

Thanks for sending this. Indeed, this could work well now. I will do thorough testing early next year.

@seratch seratch added the enhancement New feature or request label Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support returning multimodal content such as images from MCP tool calls.

2 participants