Skip to content

Support Images as MCP Tool Outputs - #4391

Closed
KKcorps wants to merge 2 commits into
openai:mainfrom
KKcorps:image_tool_support
Closed

KKcorps wants to merge 2 commits into
openai:mainfrom
KKcorps:image_tool_support

Conversation

@KKcorps

@KKcorps KKcorps commented Sep 28, 2025 •

Copy link
Copy Markdown
  • Teach MCP response handling to understand OpenAI’s new “array of items” format so image tool outputs flow through as actual images instead of opaque base64 strings. That lets the CLI
    and any other consumer render them directly.
  • Extend FunctionCallOutputPayload with tiny helpers that translate MCP ContentBlocks into input_text and input_image items, falling back to the old plain-string shape whenever it’s just
    text so nothing regresses.
  • Wire the core MCP tool-call path into that helper, keeping shell/custom tool failures text-only, and add protocol tests that cover both the new serialization and round-trip parsing of
    image arrays.

Tests:

  • cargo test -p codex-protocol
  • cargo test -p codex-core

Fixes #4819

@github-actions

github-actions Bot commented Sep 28, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@KKcorps KKcorps changed the title Image-capable tool outputs now flow through as proper MCP image items Support Images as Tool Outputs Sep 28, 2025
@KKcorps KKcorps changed the title Support Images as Tool Outputs Support Images as MCP Tool Outputs Sep 28, 2025
@KKcorps

KKcorps commented Sep 28, 2025

Copy link
Copy Markdown
Author

recheck

@KKcorps

KKcorps commented Sep 28, 2025

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Sep 28, 2025
@KKcorps
KKcorps marked this pull request as ready for review September 29, 2025 18:02

@gpeal gpeal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this and sorry for the delay reviewing this. Could you merge main, fix conflicts and update this PR. I would like to help you get this across the finish line.

}
}

if saw_image { Some(items) } else { None }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you return None if saw_image is false?

@gpeal

gpeal commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

@KKcorps Let me know if you're able to get this across the finish line with me this week. I want to make sure you get credit for this if it lands. However, I'd like to get this in this week so if you're unable to work on it this week, I may take this over since it unlocks valuable MCP use cases.

@gpeal

gpeal commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

Superceeded by #5600

@gpeal gpeal closed this Oct 27, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image Responses from MCP tool calls

2 participants