{{ message }}
fix(opencode): sanitize MCP tool schemas for Anthropic root combinators - #47542
Open
jelloeater-agent wants to merge 1 commit into
Open
fix(opencode): sanitize MCP tool schemas for Anthropic root combinators#47542jelloeater-agent wants to merge 1 commit into
jelloeater-agent wants to merge 1 commit into
Conversation
Contributor
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
Contributor
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.

Issue for this PR
Closes #47543
Type of change
What does this PR do?
Anthropic rejects a tool
input_schemathat usesanyOf/oneOf/allOfat the root level; these combinators are only accepted nested insideproperties. MCP servers commonly emit "exactly one of these fields" patterns as root-level combinators, which then fail Anthropic validation with a 400 and take the whole tool down.This adds a targeted
sanitizeAnthropicSchemaalongside the existing OpenAI sanitizer (#32489). It folds root-level combinators into the root object schema:allOf(an intersection): memberpropertiesare merged andrequiredare unioned into the root.anyOf/oneOf(exclusive alternatives Anthropic can't represent): dropped so the root object stays valid without being over-constrained.properties— is preserved verbatim.The Anthropic family is detected by the AI SDK adapter (
@ai-sdk/anthropic,@ai-sdk/google-vertex/anthropic) plus GitHub Copilot only when it proxies a Claude model (Copilot also proxies GPT models, which must stay on the OpenAI path).How did you verify your code works?
Added a focused test suite in
packages/opencode/test/provider/transform.test.ts:anyOf/oneOf/allOfare removed.allOfbranch content (properties.c) survives merged into the root.propertiessurvive unchanged.pattern, etc.) and non-combinator content are preserved.Checklist