fix: strip unsupported JSON Schema format values for OpenAI compatibility #10198
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.
Summary
Fixes an issue where MCP servers (like
fetch) usingformat: "uri"in their tool schemas would cause OpenAI Native provider to reject requests with:Root Cause
OpenAI's Structured Outputs (strict mode) only supports these JSON Schema
formatvalues:date-time,time,date,durationemail,hostname,ipv4,ipv6,uuidThe
uriformat (and others likeuri-reference,iri, etc.) are not supported.Solution
Updated
normalizeToolSchema()insrc/utils/json-schema.tsto:formatfield handling to the Zod schemaTesting
Added 12 new tests covering:
uri,uri-reference, etc.)All 4857 tests pass.
References
Important
This PR fixes JSON Schema format compatibility with OpenAI and introduces a task-level protocol lock for consistent tool usage.
normalizeToolSchema()injson-schema.tsnow strips unsupported JSON Schemaformatvalues (e.g.,uri) for OpenAI compatibility.Taskclass to ensure consistent tool protocol usage.resolveToolProtocol()to prioritize task-level protocol lock.detectToolProtocolFromHistory()to determine protocol from conversation history.normalizeToolSchema()to verify stripping of unsupported formats.resolveToolProtocol()anddetectToolProtocolFromHistory()to ensure correct protocol resolution and detection.This description was created by
for 132e366. You can customize this summary. It will automatically update as commits are pushed.