fix(anthropic): omit incompatible tool schemas - #2338
Conversation
🦋 Changeset detectedLatest commit: 4e9ffbb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e9ffbb74e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ? undefined | ||
| : { ...config.providerOptions.metadata }, | ||
| hooks: composeAnthropicHooks(traits), | ||
| filterUnsupportedRootSchemas: traits.length === 0 ? undefined : false, |
There was a problem hiding this comment.
Enable filtering for registry-created Anthropic providers
In the v2 path this option is forced to false for every provider created through ProtocolAdapterRegistry, including plain Anthropic, because resolveAdapterIdentity always appends the synthetic CONFIG_DEFAULT_HEADERS_TRAIT to traits before the contrib factory sees it. As a result, the production v2 Anthropic provider still sends root oneOf/anyOf/allOf MCP schemas to api.anthropic.com and hits the same 400 this change is meant to prevent; base the opt-out on real vendor traits/provider identity rather than traits.length.
Useful? React with 👍 / 👎.
Related Issue
Resolve #2328
Problem
Anthropic rejects a request when any MCP tool has
oneOf,anyOf, orallOfat the root of its input schema. Because the complete tool list is sent with
each request, one such tool prevents even an unrelated prompt from running.
What changed
the current and legacy provider paths.
of rewriting their JSON Schema; compatible tools remain available, while
Kimi compositions and custom compatible endpoints are unchanged.
retention, Kimi/custom endpoint scoping, and input immutability.
Test verification (RED → GREEN)
Real upstream provider-boundary RED; the issue also confirms that omitting the
offending tool makes the same Anthropic session work:
Full affected suite on exact
origin/main, with both new tests appliedbut no production changes:
pnpm exec vitest run \ packages/agent-core-v2/test/kosong/provider/composition.test.ts \ packages/kosong/test/anthropic.test.tsPatched GREEN:
pnpm exec vitest run \ packages/agent-core-v2/test/kosong/provider/composition.test.ts \ packages/kosong/test/anthropic.test.tsAlso passed:
pnpm --filter @moonshot-ai/agent-core-v2 lint:domainpnpm --filter @moonshot-ai/agent-core-v2 typecheckpnpm --filter @moonshot-ai/kosong typecheckChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.