fix: default unknown tool schemas to empty schemas#22380
Merged
Conversation
7aefdf6 to
9d3746f
Compare
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d3746f0c5
ℹ️ 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".
pakrym-oai
reviewed
May 12, 2026
253e787 to
eb448be
Compare
eb448be to
e7e5d48
Compare
e7e5d48 to
9100923
Compare
pakrym-oai
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Some tool providers, especially MCP servers and dynamic tool sources, can supply schema nodes that omit
typeand have no recognized JSON Schema shape hints. Previously,sanitize_json_schemafilled those unknown nodes in asstring, which made the schema parseable but invented a scalar constraint that the provider did not specify. For description-only fields, that could incorrectly steer tool arguments away from the provider's actual accepted shape.The Responses API accepts permissive empty schemas such as
{}at nested property positions, so Codex should preserve that permissive meaning instead of coercing unknown schema nodes into a misleading scalar type.What Changed
codex-rs/tools/src/json_schema.rsto clear unrecognized object schema nodes to{}.{}rather than becomingtype: "string".{}while surrounding object/array/string/number inference still applies when recognized hints are present.codex-toolsandcodex-coretests to cover top-level empty schemas, nested empty schemas, metadata-only malformed schemas, dynamic tools, and MCP tool specs.Verification
cargo test -p codex-toolscargo test -p codex-core test_mcp_tool_property_missing_type_defaults_to_empty_schemaparameters: {}is accepted and echoed back as{"type":"object","properties":{}}; when forced to call the tool, Responses emitted empty object arguments:"arguments": "{}".{}is accepted and preserved as{}; when forced to call a tool withmetadata.extra, Responses emitted"arguments": "{\"metadata\":{\"extra\":\"codex schema sanitizer behavior\"}}".