Skip to content

Invalid schema for function 'web_search': Claude Code

Quick fix

Upgrade cc-switch to v3.17.0 or later. If upgrading is not possible, use the native DeepSeek Anthropic-compatible API.

Error output
API Error: 400 Error from provider (DeepSeek): Invalid schema for function 'web_search': schema must be a JSON Schema of 'type: "object"', got 'type: null'.

When Claude Code connects to OpenCode Go/DeepSeek through the cc-switch OpenAI Chat Completions conversion layer, the Anthropic `input_schema` for client tools may omit the root-level `type`. Older versions of `clean_schema` passed this structure through unchanged, leaving the converted `parameters` without a `type`; strict gateways such as DeepSeek interpret this as `type: null` and return 400. This may also cause missing parameters or invocation failures for parameterized tools such as Bash, Write, Edit, and Agent, while parameterless tools and MCP tools using a separate protocol channel may be unaffected.

Issue #3844 suggested that a missing `required` array or nested schema might also contribute, but the fix confirmed by the maintainer in Issue #3439 was to default only a root schema missing `type` to `"object"` and add an empty object when `properties` is also missing. Nested schemas are not modified this way. The fix was released in v3.17.0. Issue #3844 was later closed after no new reproduction details were provided before the timeout, with a recommendation to retest using the latest version after the 4.0 refactor.

  1. Upgrade cc-switch from affected v3.16.0 or v3.16.1 to v3.17.0 or later.

  2. Continue using OpenCode Go, DeepSeek, and the OpenAI Chat Completions format. Restart Claude Code and trigger WebSearch to confirm that `type: null` no longer appears.

  3. If upgrading is not currently possible, use the native DeepSeek Anthropic-compatible API directly. Comparative testing in Issue #3439 and the report in Issue #3844 confirm that bypassing this conversion path resolves the problem.

  4. If the issue still occurs on the latest version, record the current CC Switch version, system, complete reproduction steps, and updated error logs or screenshots, then reopen or submit an issue.

ToolClaude Code
Version受影响:3.16.0 - 3.16.1;已修复:3.17.0
PlatformsmacOSWindows
Why does the error not occur when using the Anthropic-compatible format directly?
Comparative testing in Issue #3439 shows that WebSearch works when connecting directly to the native DeepSeek Anthropic base URL. This path bypasses the affected OpenAI Chat Completions schema conversion layer.
Why do parameterless tools and MCP tools still work?
Issue #3844 reports that parameterless tools such as TaskList and CronList do not depend on the same parameter schema, while MCP tools use a separate protocol channel and do not pass through Anthropic→OpenAI format conversion.
What should I do if `type: null` still appears after upgrading?
The maintainer requested retesting with the latest version. If the issue persists, report it again with the CC Switch version, operating system, complete reproduction steps, and relevant logs or screenshots.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.