Skip to content

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

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

[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.

@jacobzhou-oai jacobzhou-oai marked this pull request as ready for review July 7, 2026 15:56
@jacobzhou-oai jacobzhou-oai requested a review from a team as a code owner July 7, 2026 15:56

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea12126f62

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +190
if optional_fields
.iter()
.any(|optional_field| optional_field == "mime_type")
&& let Some(mime_type) = uploaded.mime_type

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.

P1 Badge Update integration tests for schema-aware file payloads

When a Codex Apps file param schema does not declare mime_type/file_name (the existing AppsTestServer fixture only declares file_id), this branch now sends only download_url and file_id, but core/tests/suite/openai_file_mcp.rs still expects uploaded_file() with mime_type, file_name, uri, and file_size_bytes for both the MCP call and the PostToolUse hook. That existing integration suite will fail once it reaches those assertions and no longer documents the intended user-facing payload shape, so please update the suite fixture/expectations alongside this payload change.

AGENTS.md reference: AGENTS.md:L114-L118

Useful? React with 👍 / 👎.

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