Summary
MCP servers that expose tool schemas with anyOf/oneOf keywords (e.g. Unusual Whales) cause all LLM requests to fail with 400 Invalid schema when the provider is DeepSeek. The gateway registers tools natively without stripping anyOf, and DeepSeek rejects them.
Error
400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': "date" is not valid under any of the schemas listed in the 'anyOf' keyword
Full gateway log entry
{
"error": "LLM request failed: provider rejected the request schema or tool payload.",
"failoverReason": "format",
"model": "deepseek-v4-pro",
"provider": "deepseek",
"rawErrorPreview": "400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': 'date' is not valid under any of the schemas listed in the 'anyOf' keyword",
"providerRuntimeFailureKind": "schema"
}
Happens in any session/context that has UW MCP tools registered -- cron jobs, direct chat, sub-agent runs. 48/48 crons affected.
Root Cause
The Unusual Whales MCP server exposes optional fields as anyOf unions (e.g. "date": {"anyOf": [{"type": "string"}, {"type": "integer"}]}). This is valid JSON Schema and accepted by Anthropic/OpenAI, but DeepSeek's API rejects schemas with anyOf/oneOf at the tool schema level.
The userland workaround is a strip_nullable_unions() function that collapses anyOf: [T, "null"] to {type: T, nullable: true}, but this only works if it runs in the agent process before schemas reach the LLM. The gateway registers MCP tools natively and sends raw schemas to the provider.
Proposed Fix
Add a lightweight schema sanitization step when registering MCP tools at the gateway level:
- Walk all tool schemas for
anyOf/oneOf keywords at registration time
- Collapse nullable unions (
anyOf: [T, "null"] -> {type: T, nullable: true})
- For multi-branch
anyOf (e.g. date as string|integer), collapse to first non-null variant
- This is safe because MCP tool handlers re-validate arguments server-side
Environment
- OpenClaw 2026.5.12-beta.6 (c4292e0)
- DeepSeek v4 Flash + Pro providers
- Node v22.22.2
- Linux arm64
Summary
MCP servers that expose tool schemas with
anyOf/oneOfkeywords (e.g. Unusual Whales) cause all LLM requests to fail with400 Invalid schemawhen the provider is DeepSeek. The gateway registers tools natively without strippinganyOf, and DeepSeek rejects them.Error
Full gateway log entry
{ "error": "LLM request failed: provider rejected the request schema or tool payload.", "failoverReason": "format", "model": "deepseek-v4-pro", "provider": "deepseek", "rawErrorPreview": "400 Invalid schema for function 'unusual-whales__get_balance_sheet_screener': 'date' is not valid under any of the schemas listed in the 'anyOf' keyword", "providerRuntimeFailureKind": "schema" }Happens in any session/context that has UW MCP tools registered -- cron jobs, direct chat, sub-agent runs. 48/48 crons affected.
Root Cause
The Unusual Whales MCP server exposes optional fields as
anyOfunions (e.g."date": {"anyOf": [{"type": "string"}, {"type": "integer"}]}). This is valid JSON Schema and accepted by Anthropic/OpenAI, but DeepSeek's API rejects schemas withanyOf/oneOfat the tool schema level.The userland workaround is a
strip_nullable_unions()function that collapsesanyOf: [T, "null"]to{type: T, nullable: true}, but this only works if it runs in the agent process before schemas reach the LLM. The gateway registers MCP tools natively and sends raw schemas to the provider.Proposed Fix
Add a lightweight schema sanitization step when registering MCP tools at the gateway level:
anyOf/oneOfkeywords at registration timeanyOf: [T, "null"]->{type: T, nullable: true})anyOf(e.g. date as string|integer), collapse to first non-null variantEnvironment