[codex] Make app file payloads schema-aware#31330
Conversation
|
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. |
There was a problem hiding this comment.
💡 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".
| if optional_fields | ||
| .iter() | ||
| .any(|optional_field| optional_field == "mime_type") | ||
| && let Some(mime_type) = uploaded.mime_type |
There was a problem hiding this comment.
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 👍 / 👎.
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
nativeImagereceivesmime_type,file_name,uri, andfile_size_byteseven though its schema accepts onlydownload_urlandfile_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
download_urlandfile_id.mime_typeandfile_nameonly when the target parameter schema explicitly declares them and the upload has a value.uriorfile_size_bytes.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 fmtjust test -p codex-mcp(106 tests passed)git diff --checkI 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 fromnativeImage.download_urland usenativeImage.file_idas the stable reference instead of treatingoriginalUploadedImage="/workspace/..."as a fetchable local path.