Bug: streamed tool-call deltas with empty id/name overwrite valid values #1500
starrain1031
started this conversation in
General
Replies: 2 comments
|
这个百炼故障现在可以直接绕开,不需要改 dsh plugin --profile web add pi2dsh
dsh plugin --profile web add pi-provider-alibaba-bailian
export ALIBABA_API_KEY='<your Bailian key>'
dsh web然后选择 我们已经完成两层验证:
请直接按上面步骤试;如果你的地域、模型或账号返回不同错误,把所选模型和错误贴出来,我们继续按真实场景修。 |
0 replies
|
Community mitigation (not an official fix): dsh-llm-gateway-compat sanitizes empty streamed tool-call id/name, and can write 社区缓解,不是官方修复。请自行 review 源码后再安装。 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
When
@deepseek-ai/dsh-llm-deepseekconsumes streamed tool calls from a DashScope OpenAI-compatible endpoint, later argument-only deltas may contain empty-stringidandfunction.namefields.The translator treats these empty strings as authoritative updates and overwrites the valid ID and name received in the first delta.
As a result, the completed tool call has
id: ""andname: "", and tool dispatch fails with:Environment
@deepseek-ai/dsh:0.1.0-rc.6deepseek-official/chat/completionsdeepseek-v4-flashweb_searchtoolObserved stream
The first tool-call delta is correct:
{ "type": "tool-call-delta", "index": 2, "id": "call_example", "name": "web_search", "argumentsDelta": "" }Later argument-only deltas contain empty metadata:
{ "type": "tool-call-delta", "index": 2, "id": "", "name": "", "argumentsDelta": "{" }Additional argument fragments continue with the same empty metadata:
{ "type": "tool-call-delta", "index": 2, "id": "", "name": "", "argumentsDelta": "\"query\": \"example\"}" }The final block is then emitted as:
{ "type": "block-end", "index": 2, "block": { "type": "tool-call", "id": "", "name": "", "arguments": "{\"query\": \"example\"}" } }Harness subsequently attempts to dispatch a tool whose name is an empty string:
The failure occurs before the actual
web_searchimplementation is executed.Root cause
The current translator overwrites stored metadata whenever the incoming field is not
undefined:https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/llm/llm-deepseek/src/translate.ts
For an empty string, both conditions are true. Therefore, a later argument-only delta erases the valid ID and name received earlier.
DashScope streaming behavior
DashScope’s official Function Calling documentation shows that later streamed argument chunks may contain an empty tool-call ID and no new function name.
Consumers are expected to merge tool-call deltas by
index, retain the metadata from the first non-empty delta, and append only the argument fragments:https://www.alibabacloud.com/help/en/model-studio/qwen-function-calling
Semantically, the empty metadata in a later delta means “no update in this chunk,” not “clear the previously received value.”
Proposed fix
Only replace stored metadata when the incoming value is a non-empty string:
The argument fragment should continue to be appended normally:
Missing regression coverage
The current translator tests cover the standard shape where later deltas omit
idandname:https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/llm/llm-deepseek/tests/translate.spec.ts
However, they do not cover the DashScope-compatible shape where later deltas explicitly contain empty strings.
A regression test could use:
The final assertion should verify that the original ID and name are preserved:
Expected behavior
index.idandname.function.argumentsfragments.web_search, rather than an empty tool name.All reactions