fix: strip unsupported JSON Schema format values for OpenAI compatibility#10198
Merged
fix: strip unsupported JSON Schema format values for OpenAI compatibility#10198
Conversation
Contributor
Sync review completed. No new issues found. 1 previously flagged issue remains unresolved.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
…lity When using OpenAI Native provider with MCP servers (like fetch), the API rejects schemas containing format values not supported by Structured Outputs. OpenAI only supports: date-time, time, date, duration, email, hostname, ipv4, ipv6, uuid This change updates normalizeToolSchema() to strip unsupported format values (like 'uri', 'uri-reference') while preserving supported ones. Fixes PostHog issue: 019b3341-35fb-76b1-8aba-ef36d698f9a2
132e366 to
a92fb7c
Compare
Merged
cte
approved these changes
Dec 19, 2025
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.