fix: make tool input schemas compatible with JSON Schema draft 2020-12#31
Open
wuxiaoweisjz wants to merge 1 commit into
Open
fix: make tool input schemas compatible with JSON Schema draft 2020-12#31wuxiaoweisjz wants to merge 1 commit into
wuxiaoweisjz wants to merge 1 commit into
Conversation
- Add fixSchema() to strip draft-07 $schema, convert array type values to anyOf, and remove numeric exclusiveMinimum/Maximum (draft 2019-09 syntax not supported by Bedrock) - Set $schema to https://json-schema.org/draft/2020-12/schema on all tool input schemas, as required by Bedrock via the relay - Rename webview_get_styles parameter 'properties' -> 'cssProperties' to avoid conflict with the JSON Schema 'properties' keyword, which caused Bedrock's validator to reject the schema Co-Authored-By: claude-opus-4-8 <noreply@anthropic.com>
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
Some Claude API relays (e.g. AWS Bedrock-backed) require tool
input_schemato conform to JSON Schema draft 2020-12 and reject schemas that don't. This PR fixes three issues found through end-to-end testing:$schemapointing to draft-07 —zod-to-json-schemadefaults to"http://json-schema.org/draft-07/schema#". Replaced with"https://json-schema.org/draft/2020-12/schema".Array
typevalues —zod-to-json-schemaemits"type": ["string", "number"]for union types. Bedrock rejects array type values; converted toanyOf: [{type: "string"}, {type: "number"}].Numeric
exclusiveMinimum/exclusiveMaximum— draft 2019-09 syntax (numeric) is not accepted; these fields are stripped.webview_get_stylesparameter namedproperties— this name conflicts with the JSON Schemapropertieskeyword, causing Bedrock's validator to reject the schema. Renamed tocssProperties.All 20 tool schemas now pass end-to-end validation against the API.
Test Plan
npm run build)🤖 Generated with Claude Code