Skip to content

fix: default unknown tool schemas to open objects#22380

Open
celia-oai wants to merge 2 commits into
mainfrom
dev/cc/new-default
Open

fix: default unknown tool schemas to open objects#22380
celia-oai wants to merge 2 commits into
mainfrom
dev/cc/new-default

Conversation

@celia-oai
Copy link
Copy Markdown
Collaborator

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

Why

Some tool providers, especially MCP servers, can supply input schemas that omit a type and do not include enough structural hints for Codex to infer one. Previously, sanitize_json_schema treated those unknown schema nodes as strings. That made the schema valid, but it also degraded permissive or object-like tool contracts into scalar guidance, which can cause the model to lose the real argument shape and produce connector calls that fail later.

Responses currently still rejects some malformed function schemas even when strict: false, so Codex needs a short-term best-effort sanitizer instead of passing every raw provider schema through unchanged. The intended fallback is now an open JSON object: not any JSON value, but an object that can carry arbitrary named fields.

What Changed

  • Changed the no-hints fallback in codex-rs/tools/src/json_schema.rs from string to an open object schema.
  • The fallback emits type: "object" with empty properties and explicit additionalProperties: true, allowing arbitrary named fields when Codex cannot infer a narrower schema.
  • This fallback is recursive: nested no-hints property schemas, such as description-only MCP fields, also become open objects. That is intentional for this short-term compatibility path.
  • Updated codex-tools and codex-core tests for empty schemas, nested empty schemas, dynamic tools, and MCP tool specs so the recursive fallback behavior is explicit.

Verification

  • cargo test -p codex-tools
  • cargo test -p codex-core test_mcp_tool_property_missing_type_defaults_to_open_object

@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
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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
schema_types.push(JsonSchemaPrimitiveType::String);
// With no schema hints, fall back to an open object so unknown
// tool argument shapes can still carry arbitrary named fields.
schema_types.push(JsonSchemaPrimitiveType::Object);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean any in JsonSchema speak?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels we are changing from one incorrect schema to another

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, any is any value, and this is any json object (a subset of any value). we don't want to support any value because it will error out for some responses api checks

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think the concern stands: for nested property schemas with only metadata, we’re not preserving an unknown shape.. we’re forcing a scalar-looking argument like query into an object

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

3 participants