Skip to content

[codex] Make app file payloads schema-aware#31330

Draft
jacobzhou-oai wants to merge 1 commit into
mainfrom
codex/schema-aware-file-param-payloads
Draft

[codex] Make app file payloads schema-aware#31330
jacobzhou-oai wants to merge 1 commit into
mainfrom
codex/schema-aware-file-param-payloads

Conversation

@jacobzhou-oai

Copy link
Copy Markdown

Summary

Codex Apps file parameters are exposed to the model as local paths, then uploaded and rewritten into provided-file payloads during tool execution. The native bridge currently forwards the complete internal upload result, including fields that are not part of the downstream tool schema.

Strict Apps SDK tools reject those extra fields before executing. Adobe Photoshop is one concrete example: uploaded-image calls fail validation because nativeImage receives mime_type, file_name, uri, and file_size_bytes even though its schema accepts only download_url and file_id.

Root cause

The model-visible schema masking step retained only the names declared in openai/fileParams. By execution time, Codex no longer knew which optional provided-file fields the original MCP schema accepted, so it serialized every field returned by the internal upload API.

Changes

  • Derive the optional provided-file fields accepted by each declared file parameter from the raw MCP schema before masking it as a local path.
  • Carry that field information through Codex Apps tool metadata into execution-time argument rewriting.
  • Always emit download_url and file_id.
  • Emit mime_type and file_name only when the target parameter schema explicitly declares them and the upload has a value.
  • Never expose internal-only uri or file_size_bytes.
  • Apply the same behavior to scalar and array file parameters.
  • Keep custom MCP servers unable to opt into openai/fileParams.

The existing Codex Apps cache already stores raw tool schemas. The new optional-field map is derived after cache load, so this does not require invalidating the cache format.

Validation

  • just fmt
  • just test -p codex-mcp (106 tests passed)
  • git diff --check

I also attempted just test -p codex-core mcp_openai_file. The changed Rust compiled, but the local machine ran out of disk during final test-binary linking (errno=28), so that focused test could not complete locally.

Follow-up

This fixes the native Codex schema-validation failure. Adobe Photoshop still needs a separate app-side change for uploaded images: when inputImageType="nativeImage", it should fetch from nativeImage.download_url and use nativeImage.file_id as the stable reference instead of treating originalUploadedImage="/workspace/..." as a fetchable local path.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant