[GH-ISSUE #606] Claude Code WebSearch broken: deepseek-reasoner does not support tool_choice #176

Open
opened 2026-10-26 09:54:46 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @inertia on GitHub (May 4, 2026).
Original GitHub issue: https://github.com/deepseek-ai/awesome-deepseek-integration/issues/606

Description

When using DeepSeek as the backend model for Claude Code, the WebSearch and WebFetch tools fail with the following error:

API Error: 400 {"error":{"message":"deepseek-reasoner does not support this tool_choice","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

Steps to Reproduce

  1. Configure Claude Code to use DeepSeek as the provider (via claude --model deepseek-v4-pro or equivalent)
  2. Trigger any query that causes Claude Code to invoke the built-in WebSearch or WebFetch tool
  3. The API returns a 400 error because DeepSeek's API rejects the tool_choice parameter

Expected Behavior

WebSearch/WebFetch should work, as these are core capabilities of Claude Code. DeepSeek's API documentation claims compatibility with the Anthropic API format, which includes tool_choice support.

Impact

This effectively disables web search — one of the most important capabilities of an AI coding assistant. Without it, the assistant cannot verify facts, search documentation, or fetch current information from the web. This breaks roughly half of the assistant's practical utility.

Proposed Fix

Support the tool_choice parameter in the DeepSeek API when using Anthropic-compatible mode, so that tools like WebSearch and WebFetch can be invoked correctly by Claude Code.

Environment

  • Claude Code CLI (latest)
  • Model: deepseek-reasoner / deepseek-v4-pro
  • Date tested: 2026-05-04
Originally created by @inertia on GitHub (May 4, 2026). Original GitHub issue: https://github.com/deepseek-ai/awesome-deepseek-integration/issues/606 ## Description When using DeepSeek as the backend model for Claude Code, the `WebSearch` and `WebFetch` tools fail with the following error: ``` API Error: 400 {"error":{"message":"deepseek-reasoner does not support this tool_choice","type":"invalid_request_error","param":null,"code":"invalid_request_error"}} ``` ## Steps to Reproduce 1. Configure Claude Code to use DeepSeek as the provider (via `claude --model deepseek-v4-pro` or equivalent) 2. Trigger any query that causes Claude Code to invoke the built-in `WebSearch` or `WebFetch` tool 3. The API returns a 400 error because DeepSeek's API rejects the `tool_choice` parameter ## Expected Behavior WebSearch/WebFetch should work, as these are core capabilities of Claude Code. DeepSeek's API documentation claims compatibility with the Anthropic API format, which includes `tool_choice` support. ## Impact This effectively disables web search — one of the most important capabilities of an AI coding assistant. Without it, the assistant cannot verify facts, search documentation, or fetch current information from the web. This breaks roughly half of the assistant's practical utility. ## Proposed Fix Support the `tool_choice` parameter in the DeepSeek API when using Anthropic-compatible mode, so that tools like WebSearch and WebFetch can be invoked correctly by Claude Code. ## Environment - Claude Code CLI (latest) - Model: deepseek-reasoner / deepseek-v4-pro - Date tested: 2026-05-04
Author
Owner

@qyangcv commented on GitHub (May 12, 2026):

I met the same problem and re-install claude code may work: see link.

~/.claude.json seems to be the cause, you can try rm ~/.claude.json after backup.

<!-- gh-comment-id:4430504567 --> @qyangcv commented on GitHub (May 12, 2026): I met the same problem and re-install claude code may work: see [link](https://www.xiaohongshu.com/explore/69f45bc6000000001a02d0df?xsec_token=ABxBXe0-Uje_VJt3DmunkYIMc3rcs_0lbwISA8XLgVFBE=&xsec_source=pc_like). `~/.claude.json` seems to be the cause, you can try `rm ~/.claude.json` after backup.
Author
Owner

@scvince1 commented on GitHub (May 13, 2026):

Hello! We've been running Claude Code on DeepSeek V4 Pro extensively on Windows over the past 22 hours and hit this exact tool_choice issue. Sharing a fuller picture of what we found in case it helps inform the broader Anthropic-compatible compatibility work.

Scope: our testing covered deepseek-v4-pro (1M variant) and deepseek-reasoner only. We did not test deepseek-v4-flash, so claims below are V4 Pro-specific unless noted otherwise.

1. tool_choice rejection (this issue)

Confirmed on both deepseek-reasoner and deepseek-v4-pro (1M variant). WebSearch / WebFetch invocations from Claude Code 400 immediately. The DeepSeek endpoint accepts the tool_choice field syntactically but the server rejects it. @qyangcv's ~/.claude.json workaround addresses a different layer (Claude Code-side config caching) and doesn't unblock the underlying API rejection in our testing.

2. Thinking block signatures don't survive provider transitions

Sessions created via DeepSeek's Anthropic-compat endpoint accumulate assistant messages containing {"type":"thinking", "signature":"..."} blocks where the signature is DeepSeek-generated. Switching back to native Anthropic (e.g., unset ANTHROPIC_BASE_URL) and resuming any such session immediately produces:

API Error: 400 messages.N.content.M: Invalid `signature` in `thinking` block

Across two projects we had to scan ~/.claude/projects/**/*.jsonl and replace 728 such blocks (in 14 files) with placeholder text + originals backed up, before sessions became resumable.

3. ANTHROPIC_MODEL routing nuances

  • deepseek-v4-pro works, but deepseek-v4-pro[1m] is required to actually activate 1M context (without the suffix the request routes but the window stays at default).
  • The -latest alias pattern (claude-sonnet-4-latest / claude-opus-4-latest) does not resolve at runtime in Claude Code, even though it nominally exists. Must use concrete versions like claude-sonnet-4-6 / claude-opus-4-7.

4. Windows-specific multi-layer env injection

Claude Code on Windows reads env from at least 4 layers (process env > Windows User-level setx > settings.json env block > PowerShell $PROFILE). Anthropic-compat config in one layer is silently overridden by another. We landed on a PowerShell $PROFILE that reads a .current_model flag file and invokes Use-ClaudeAnthropic / Use-ClaudeDeepSeek functions, plus a Python script that rewrites ~/.claude/settings.json and the flag together. Single source of truth, clean restart.

Suggestion

A "Claude Code Integration Known Limitations" section in DeepSeek's Anthropic-compat docs would save users a lot of cycles. Could cover: (a) tool_choice not supported on reasoner-class models, (b) thinking block signatures are non-portable across providers, (c) recommended Windows env var setup pattern, (d) [1m] suffix for 1M context. Happy to share our workaround scripts and retrospective notes if useful.


你好!我们最近 22 小时在 Windows 上密集测试 Claude Code 跑 DeepSeek V4 Pro,刚好撞上这个 tool_choice 问题,把我们发现的相关坑一起整理一下,希望对 DeepSeek Anthropic-compatible 接口的兼容性工作有帮助。

测试范围:仅覆盖 deepseek-v4-pro (1M variant) 和 deepseek-reasoner,未测 deepseek-v4-flash,所以下面所有结论默认是 V4 Pro specific 范围。

1. tool_choice 拒绝(本 issue)

deepseek-reasoner 和 deepseek-v4-pro (1M variant) 上都确认。Claude Code 发 WebSearch / WebFetch 立即 400。DeepSeek 端点接受 tool_choice 字段语法但 server 拒绝执行。@qyangcv 的 ~/.claude.json workaround 解决的是 Claude Code 端 config 缓存层的问题,跟 API 层的 tool_choice 拒绝不是同一个 root cause。

2. Thinking block 签名跨 provider 不兼容

用 DeepSeek 的 Anthropic-compatible 端点跑出来的 session 里,assistant message 含 {"type":"thinking", "signature":"..."} block,签名是 DeepSeek 生成的。切回 Anthropic 原生(比如 unset ANTHROPIC_BASE_URL)后 resume 任何这样的 session,立刻:

API Error: 400 messages.N.content.M: Invalid `signature` in `thinking` block

我们跨两个 project 扫 ~/.claude/projects/**/*.jsonl,替换了 14 个文件里 728 个这种 block 成 placeholder text + 备份原文件,session 才能恢复 resume。

3. ANTHROPIC_MODEL 路由细节

  • deepseek-v4-pro 能跑,但真正激活 1M context 必须 deepseek-v4-pro[1m] 后缀(没后缀请求虽然路由成功但 context window 还是默认)
  • claude-sonnet-4-latest / claude-opus-4-latest 这类 -latest 后缀在 Claude Code runtime 读不到,必须显式 claude-sonnet-4-6 / claude-opus-4-7

4. Windows 多层 env 注入冲突

Claude Code 在 Windows 上至少读 4 层 env(process env > Windows User-level setx > settings.json env block > PowerShell $PROFILE 注入)。任何一层的 anthropic-compat 配置都可能被另一层静默覆盖。我们最后的方案:PowerShell $PROFILE 读 .current_model flag 文件,自动 invoke Use-ClaudeAnthropic / Use-ClaudeDeepSeek 函数 + Python 脚本同时改 ~/.claude/settings.json 和 flag。单一可信源,重启即生效。

建议

DeepSeek 的 Anthropic-compatible 文档加一节 "Claude Code 集成已知限制" 会帮用户省很多踩坑时间。可以覆盖:(a) reasoner-class 模型不支持 tool_choice,(b) thinking block 签名跨 provider 不可转移,(c) Windows env var 推荐配置 pattern,(d) [1m] suffix for 1M context。如果对你们 transition 工作有用,我们的 workaround 脚本和踩坑记录可以分享。

<!-- gh-comment-id:4435847271 --> @scvince1 commented on GitHub (May 13, 2026): Hello! We've been running Claude Code on DeepSeek V4 Pro extensively on Windows over the past 22 hours and hit this exact `tool_choice` issue. Sharing a fuller picture of what we found in case it helps inform the broader Anthropic-compatible compatibility work. **Scope: our testing covered `deepseek-v4-pro` (1M variant) and `deepseek-reasoner` only. We did not test `deepseek-v4-flash`, so claims below are V4 Pro-specific unless noted otherwise.** **1. tool_choice rejection (this issue)** Confirmed on both `deepseek-reasoner` and `deepseek-v4-pro` (1M variant). WebSearch / WebFetch invocations from Claude Code 400 immediately. The DeepSeek endpoint accepts the `tool_choice` field syntactically but the server rejects it. @qyangcv's `~/.claude.json` workaround addresses a different layer (Claude Code-side config caching) and doesn't unblock the underlying API rejection in our testing. **2. Thinking block signatures don't survive provider transitions** Sessions created via DeepSeek's Anthropic-compat endpoint accumulate assistant messages containing `{"type":"thinking", "signature":"..."}` blocks where the signature is DeepSeek-generated. Switching back to native Anthropic (e.g., `unset ANTHROPIC_BASE_URL`) and resuming any such session immediately produces: ``` API Error: 400 messages.N.content.M: Invalid `signature` in `thinking` block ``` Across two projects we had to scan `~/.claude/projects/**/*.jsonl` and replace 728 such blocks (in 14 files) with placeholder text + originals backed up, before sessions became resumable. **3. ANTHROPIC_MODEL routing nuances** - `deepseek-v4-pro` works, but `deepseek-v4-pro[1m]` is required to actually activate 1M context (without the suffix the request routes but the window stays at default). - The `-latest` alias pattern (`claude-sonnet-4-latest` / `claude-opus-4-latest`) does not resolve at runtime in Claude Code, even though it nominally exists. Must use concrete versions like `claude-sonnet-4-6` / `claude-opus-4-7`. **4. Windows-specific multi-layer env injection** Claude Code on Windows reads env from at least 4 layers (process env > Windows User-level `setx` > `settings.json` env block > PowerShell `$PROFILE`). Anthropic-compat config in one layer is silently overridden by another. We landed on a PowerShell `$PROFILE` that reads a `.current_model` flag file and invokes `Use-ClaudeAnthropic` / `Use-ClaudeDeepSeek` functions, plus a Python script that rewrites `~/.claude/settings.json` and the flag together. Single source of truth, clean restart. **Suggestion** A "Claude Code Integration Known Limitations" section in DeepSeek's Anthropic-compat docs would save users a lot of cycles. Could cover: (a) tool_choice not supported on reasoner-class models, (b) thinking block signatures are non-portable across providers, (c) recommended Windows env var setup pattern, (d) `[1m]` suffix for 1M context. Happy to share our workaround scripts and retrospective notes if useful. --- 你好!我们最近 22 小时在 Windows 上密集测试 Claude Code 跑 DeepSeek V4 Pro,刚好撞上这个 `tool_choice` 问题,把我们发现的相关坑一起整理一下,希望对 DeepSeek Anthropic-compatible 接口的兼容性工作有帮助。 **测试范围:仅覆盖 `deepseek-v4-pro` (1M variant) 和 `deepseek-reasoner`,未测 `deepseek-v4-flash`,所以下面所有结论默认是 V4 Pro specific 范围。** **1. tool_choice 拒绝(本 issue)** `deepseek-reasoner` 和 `deepseek-v4-pro` (1M variant) 上都确认。Claude Code 发 WebSearch / WebFetch 立即 400。DeepSeek 端点接受 `tool_choice` 字段语法但 server 拒绝执行。@qyangcv 的 `~/.claude.json` workaround 解决的是 Claude Code 端 config 缓存层的问题,跟 API 层的 tool_choice 拒绝不是同一个 root cause。 **2. Thinking block 签名跨 provider 不兼容** 用 DeepSeek 的 Anthropic-compatible 端点跑出来的 session 里,assistant message 含 `{"type":"thinking", "signature":"..."}` block,签名是 DeepSeek 生成的。切回 Anthropic 原生(比如 `unset ANTHROPIC_BASE_URL`)后 resume 任何这样的 session,立刻: ``` API Error: 400 messages.N.content.M: Invalid `signature` in `thinking` block ``` 我们跨两个 project 扫 `~/.claude/projects/**/*.jsonl`,替换了 14 个文件里 728 个这种 block 成 placeholder text + 备份原文件,session 才能恢复 resume。 **3. ANTHROPIC_MODEL 路由细节** - `deepseek-v4-pro` 能跑,但真正激活 1M context 必须 `deepseek-v4-pro[1m]` 后缀(没后缀请求虽然路由成功但 context window 还是默认) - `claude-sonnet-4-latest` / `claude-opus-4-latest` 这类 `-latest` 后缀在 Claude Code runtime 读不到,必须显式 `claude-sonnet-4-6` / `claude-opus-4-7` **4. Windows 多层 env 注入冲突** Claude Code 在 Windows 上至少读 4 层 env(process env > Windows User-level `setx` > `settings.json` env block > PowerShell `$PROFILE` 注入)。任何一层的 anthropic-compat 配置都可能被另一层静默覆盖。我们最后的方案:PowerShell `$PROFILE` 读 `.current_model` flag 文件,自动 invoke `Use-ClaudeAnthropic` / `Use-ClaudeDeepSeek` 函数 + Python 脚本同时改 `~/.claude/settings.json` 和 flag。单一可信源,重启即生效。 **建议** DeepSeek 的 Anthropic-compatible 文档加一节 "Claude Code 集成已知限制" 会帮用户省很多踩坑时间。可以覆盖:(a) reasoner-class 模型不支持 tool_choice,(b) thinking block 签名跨 provider 不可转移,(c) Windows env var 推荐配置 pattern,(d) `[1m]` suffix for 1M context。如果对你们 transition 工作有用,我们的 workaround 脚本和踩坑记录可以分享。
Author
Owner

@JcDizzy commented on GitHub (May 14, 2026):

试试这个https://github.com/JcDizzy/CC-Web-MCP

<!-- gh-comment-id:4448597997 --> @JcDizzy commented on GitHub (May 14, 2026): 试试这个https://github.com/JcDizzy/CC-Web-MCP
Author
Owner

@monabasa commented on GitHub (May 20, 2026):

try this https://github.com/farion1231/cc-switch/issues/2570

<!-- gh-comment-id:4498945240 --> @monabasa commented on GitHub (May 20, 2026): try this https://github.com/farion1231/cc-switch/issues/2570
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/awesome-deepseek-integration#176
No description provided.