mirror of
https://github.com/deepseek-ai/awesome-deepseek-integration.git
synced 2026-11-05 00:57:30 +00:00
[GH-ISSUE #606] Claude Code WebSearch broken: deepseek-reasoner does not support tool_choice #176
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/awesome-deepseek-integration#176
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
WebSearchandWebFetchtools fail with the following error:Steps to Reproduce
claude --model deepseek-v4-proor equivalent)WebSearchorWebFetchtooltool_choiceparameterExpected 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_choicesupport.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_choiceparameter in the DeepSeek API when using Anthropic-compatible mode, so that tools like WebSearch and WebFetch can be invoked correctly by Claude Code.Environment
@qyangcv commented on GitHub (May 12, 2026):
I met the same problem and re-install claude code may work: see link.
~/.claude.jsonseems to be the cause, you can tryrm ~/.claude.jsonafter backup.@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_choiceissue. 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) anddeepseek-reasoneronly. We did not testdeepseek-v4-flash, so claims below are V4 Pro-specific unless noted otherwise.1. tool_choice rejection (this issue)
Confirmed on both
deepseek-reasoneranddeepseek-v4-pro(1M variant). WebSearch / WebFetch invocations from Claude Code 400 immediately. The DeepSeek endpoint accepts thetool_choicefield syntactically but the server rejects it. @qyangcv's~/.claude.jsonworkaround 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:Across two projects we had to scan
~/.claude/projects/**/*.jsonland replace 728 such blocks (in 14 files) with placeholder text + originals backed up, before sessions became resumable.3. ANTHROPIC_MODEL routing nuances
deepseek-v4-proworks, butdeepseek-v4-pro[1m]is required to actually activate 1M context (without the suffix the request routes but the window stays at default).-latestalias 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 likeclaude-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.jsonenv block > PowerShell$PROFILE). Anthropic-compat config in one layer is silently overridden by another. We landed on a PowerShell$PROFILEthat reads a.current_modelflag file and invokesUse-ClaudeAnthropic/Use-ClaudeDeepSeekfunctions, plus a Python script that rewrites~/.claude/settings.jsonand 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.jsonworkaround 解决的是 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,立刻:我们跨两个 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-74. Windows 多层 env 注入冲突
Claude Code 在 Windows 上至少读 4 层 env(process env > Windows User-level
setx>settings.jsonenv block > PowerShell$PROFILE注入)。任何一层的 anthropic-compat 配置都可能被另一层静默覆盖。我们最后的方案:PowerShell$PROFILE读.current_modelflag 文件,自动 invokeUse-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 脚本和踩坑记录可以分享。@JcDizzy commented on GitHub (May 14, 2026):
试试这个https://github.com/JcDizzy/CC-Web-MCP
@monabasa commented on GitHub (May 20, 2026):
try this https://github.com/farion1231/cc-switch/issues/2570