Skip to content

fix: default unknown tool schemas to empty schemas#22380

Merged
celia-oai merged 2 commits into
mainfrom
dev/cc/new-default
May 18, 2026
Merged

fix: default unknown tool schemas to empty schemas#22380
celia-oai merged 2 commits into
mainfrom
dev/cc/new-default

Conversation

@celia-oai

@celia-oai celia-oai commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Why

Some tool providers, especially MCP servers and dynamic tool sources, can supply schema nodes that omit type and have no recognized JSON Schema shape hints. Previously, sanitize_json_schema filled those unknown nodes in as string, 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

  • Changed the no-hints fallback in codex-rs/tools/src/json_schema.rs to clear unrecognized object schema nodes to {}.
  • Empty schemas now remain {} rather than becoming type: "string".
  • Description-only or otherwise metadata-only nested property schemas now become {} while surrounding object/array/string/number inference still applies when recognized hints are present.
  • Updated codex-tools and codex-core tests to cover top-level empty schemas, nested empty schemas, metadata-only malformed schemas, dynamic tools, and MCP tool specs.

Verification

  • cargo test -p codex-tools
  • cargo test -p codex-core test_mcp_tool_property_missing_type_defaults_to_empty_schema
  • Manually verified the real Responses API behavior for both empty-schema positions:
    • Top-level function parameters: {} is accepted and echoed back as {"type":"object","properties":{}}; when forced to call the tool, Responses emitted empty object arguments: "arguments": "{}".
    • Nested property schema {} is accepted and preserved as {}; when forced to call a tool with metadata.extra, Responses emitted "arguments": "{\"metadata\":{\"extra\":\"codex schema sanitizer behavior\"}}".

@celia-oai celia-oai changed the title changes Default unknown tool schemas to open objects May 12, 2026
@celia-oai celia-oai changed the title Default unknown tool schemas to open objects fix: default unknown tool schemas to open objects May 12, 2026
@celia-oai celia-oai force-pushed the dev/cc/new-default branch from 7aefdf6 to 9d3746f Compare May 12, 2026 22:09
@celia-oai celia-oai marked this pull request as ready for review May 12, 2026 22:13
@celia-oai celia-oai requested review from jif-oai and pakrym-oai May 12, 2026 22:13

@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: 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".

Comment thread codex-rs/tools/src/json_schema.rs Outdated
Comment thread codex-rs/tools/src/json_schema.rs Outdated
@celia-oai celia-oai requested a review from a team as a code owner May 12, 2026 22:50
@celia-oai celia-oai requested a review from pakrym-oai May 12, 2026 22:53
@celia-oai celia-oai force-pushed the dev/cc/new-default branch from 253e787 to eb448be Compare May 13, 2026 18:56
@celia-oai celia-oai marked this pull request as draft May 13, 2026 19:43
@celia-oai celia-oai force-pushed the dev/cc/new-default branch from eb448be to e7e5d48 Compare May 18, 2026 18:52
@celia-oai celia-oai force-pushed the dev/cc/new-default branch from e7e5d48 to 9100923 Compare May 18, 2026 18:59
@celia-oai celia-oai changed the title fix: default unknown tool schemas to open objects fix: default unknown tool schemas to empty schemas May 18, 2026
@celia-oai celia-oai marked this pull request as ready for review May 18, 2026 19:13
@celia-oai celia-oai merged commit 4dbca61 into main May 18, 2026
31 checks passed
@celia-oai celia-oai deleted the dev/cc/new-default branch May 18, 2026 19:41
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
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.

3 participants