Skip to content

fix: make tool input schemas compatible with JSON Schema draft 2020-12#31

Open
wuxiaoweisjz wants to merge 1 commit into
hypothesi:mainfrom
wuxiaoweisjz:main
Open

fix: make tool input schemas compatible with JSON Schema draft 2020-12#31
wuxiaoweisjz wants to merge 1 commit into
hypothesi:mainfrom
wuxiaoweisjz:main

Conversation

@wuxiaoweisjz

Copy link
Copy Markdown

Summary

Some Claude API relays (e.g. AWS Bedrock-backed) require tool input_schema to conform to JSON Schema draft 2020-12 and reject schemas that don't. This PR fixes three issues found through end-to-end testing:

  1. $schema pointing to draft-07zod-to-json-schema defaults to "http://json-schema.org/draft-07/schema#". Replaced with "https://json-schema.org/draft/2020-12/schema".

  2. Array type valueszod-to-json-schema emits "type": ["string", "number"] for union types. Bedrock rejects array type values; converted to anyOf: [{type: "string"}, {type: "number"}].

  3. Numeric exclusiveMinimum/exclusiveMaximum — draft 2019-09 syntax (numeric) is not accepted; these fields are stripped.

  4. webview_get_styles parameter named properties — this name conflicts with the JSON Schema properties keyword, causing Bedrock's validator to reject the schema. Renamed to cssProperties.

All 20 tool schemas now pass end-to-end validation against the API.

Test Plan

  • All 20 tool schemas validated against live Anthropic-compatible API endpoint
  • TypeScript build passes (npm run build)
  • Pre-commit hooks pass (commitlint + eslint + cargo fmt/clippy)

🤖 Generated with Claude Code

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