Skip to content

fix: preserve empty JSON schemas for tool parameters#21854

Open
celia-oai wants to merge 2 commits intomainfrom
dev/cc/new-schema
Open

fix: preserve empty JSON schemas for tool parameters#21854
celia-oai wants to merge 2 commits intomainfrom
dev/cc/new-schema

Conversation

@celia-oai
Copy link
Copy Markdown
Collaborator

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

Why

MCP and dynamic tool schemas can use an empty JSON Schema object ({}) to mean an unconstrained value. The tool schema sanitizer previously inferred string when no schema keywords were present, which narrowed {} into { "type": "string" }.

That misrepresents schemas for tools such as Notion page creation, where fields like body.parent may be object-shaped payloads even when the upstream schema leaves the field unconstrained. Advertising those fields as strings gives the model and any downstream schema validation the wrong contract.

What changed

  • Preserve exact empty schema objects in sanitize_json_schema instead of inferring string.
  • Add an explicit JsonSchema::any constructor for the internal unconstrained schema representation.
  • Update JSON schema tests so top-level {} and nested property schemas such as body.parent: {} remain unconstrained.

@celia-oai celia-oai changed the title changes Preserve empty JSON schemas for tool parameters May 9, 2026
@celia-oai celia-oai changed the title Preserve empty JSON schemas for tool parameters fix: preserve empty JSON schemas for tool parameters May 9, 2026
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