Replies: 2 comments
|
I verified the reported chain against rc.8 ( Two source-level details make the diagnosis especially strong:
The published guide now includes the reported control matrix (non-streaming Bailian, official DeepSeek, and Bailian Qwen), the empty-string fixture plus the earlier null-continuation fixture, safe route fallback, and acceptance gates. One important operator boundary: do not allow an empty tool name or weaken policy, and avoid patching generated global |
|
这个百炼故障现在可以直接绕开,不需要改 dsh plugin --profile web add pi2dsh
dsh plugin --profile web add pi-provider-alibaba-bailian
export ALIBABA_API_KEY='<your Bailian key>'
dsh web然后选择 我们已经完成两层验证:
请直接按上面步骤试;如果你的地域、模型或账号返回不同错误,把所选模型和错误贴出来,我们继续按真实场景修。 |
Uh oh!
There was an error while loading. Please reload this page.
[Bug Report] DSH 接入阿里云百炼 deepseek-v4-flash 时所有工具调用失败(UNKNOWN_TOOL / unknown tool "")
摘要 / Summary
在 DeepSeek Harness(
@deepseek-ai/dsh-base系)中,将 LLM provider 配置为阿里云百炼 OpenAI 兼容端点(https://dashscope.aliyuncs.com/compatible-mode/v1)、模型选择deepseek-v4-flash后:UNKNOWN_TOOL,错误信息为unknown tool ""(工具名是空字符串);对照实验:同一 DSH 使用 DeepSeek 官方 API(
api.deepseek.com)或百炼 qwen 模型(如qwen3.7-flash)时,工具调用全部正常。问题稳定复现,指向 LLM 端点侧的流式协议差异。环境 / Environment
@deepseek-ai/dsh-base、@deepseek-ai/dsh-llm-deepseek等(安装于~/.dsh/profiles/node_modules/@deepseek-ai/)https://dashscope.aliyuncs.com/compatible-mode/v1deepseek-v4-flash(全小写 ID;百炼能力表标注支持 Function Calling)现象 / Symptom
read工具)都失败:Error: unknown tool "";{command, description}等参数,缺少 name 字段;排查过程 / Investigation
1. 排除工具侧与解析器
pwsh工具在 DSH 中注册名正确(name: "pwsh"),工具本身健康;read/write/edit/glob/grep全部成功,说明 DSH 解析器与官方协议兼容良好。2. 模型名验证
百炼对模型 ID 区分大小写:
DSH 配置(
~/.dsh/settings.yaml)中使用的为全小写 IDdeepseek-v4-flash,模型名无问题。3. 百炼接口直测(关键证据)
用 curl 分别以非流式与流式调用百炼
deepseek-v4-flash,请求体相同(含tools与tool_choice: "auto"):非流式(
stream缺省)→ 完全正常:{ "choices": [{ "message": { "content": "", "role": "assistant", "tool_calls": [{ "function": { "arguments": "{\"command\": \"Get-ChildItem\"}", "name": "pwsh" }, "id": "call_fe0aed254fba43f9a54a89f4", "index": 0, "type": "function" }] }, "finish_reason": "tool_calls" }] }流式(
"stream": true)→ 增量 chunk 中name/id为显式空字符串:第一个 chunk 携带完整的
name: "pwsh"与id,但后续增量 chunk 将name/id显式序列化为""(而非省略字段)。4. 源码定位
DSH 的 LLM 适配器
@deepseek-ai/dsh-llm-deepseek在解析 SSE 增量 chunk 时(lib/index.js第 321-322 行):适配器用
!== void 0(即非undefined)判断字段是否存在,这是按 OpenAI / 官方 DeepSeek API 的行为编写的:官方增量 chunk 省略name/id字段(undefined),因此首个 chunk 写入的pwsh会被保留。百炼返回的是
""(空字符串),而"" !== void 0为true,于是block.name被覆盖为空字符串 → 最终工具调用对象name: ""→ 分发时报UNKNOWN_TOOL。另:DSH 适配器强制流式输出(README:"只支持流式输出(
stream_options.include_usage始终开启)"),因此无法通过关闭流式规避;且适配器不发送tool_choice(README:"未映射 tool_choice")。根因 / Root Cause
百炼 deepseek-v4-flash 直供模型在流式工具调用时,增量 chunk 将
name/id序列化为显式空字符串"";而 OpenAI 兼容规范(及官方 DeepSeek API)在增量 chunk 中省略这些字段(undefined)。DSH 适配器按
!== void 0判断字段存在,把空字符串当作有效新值采纳,覆盖了首个 chunk 中的有效name/id,最终工具调用对象name为空 →UNKNOWN_TOOL。百炼 qwen 系列不受影响:其对 qwen 的流式增量 chunk 行为与官方一致(省略字段)。
修复 / Fix
在
dsh-llm-deepseek/lib/index.js第 321-322 行忽略空字符串(与"字段缺失保留旧值"语义一致):验证:重启 DSH 后,
deepseek-v4-flash模型工具调用恢复正常。复现 / Reproduction
观察 SSE chunk:首个 chunk 带
name:"pwsh",后续增量 chunkname:""/id:""。建议 / Suggestion
undefined同等对待(按字段有无而非值是否为undefined判断),以兼容更多 OpenAI 兼容提供商;附注 / Notes
node_modules内文件,DSH 升级(重新安装依赖)后需重新应用;原文件备份为index.js.bak;fix_pwsh_bug.md(其早期"模型漏写 name"的结论已被本报告推翻,以本文为准)。All reactions