[bug]llm-deepseek: SSE tool_calls id/name overwritten by empty-string deltas #879
godkillerwy
started this conversation in
General
Replies: 2 comments
|
已定位根因: |
0 replies
|
Here’s a workaround that worked for me: use the same endpoint through a Custom Provider instead of "<custom-provider-section>":
providers:
"<provider-id>":
displayName: Custom DeepSeek
apiKeyEnv: DEEPSEEK_API_KEY
api: openai-completions # or openai-responses / anthropic-messages
baseURL: https://your-endpoint.example/v1
compat: # only needed for OpenAI Chat Completions
thinkingFormat: deepseek
models:
- id: deepseek-v4-flash
name: DeepSeek V4 Flash
contextWindow: 262144
maxTokens: 32768The existing API key can be reused, and I didn’t need to change DSH or the gateway. One small gotcha: create a new session after switching providers. Existing sessions keep the provider they started with. |
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.
Version
@deepseek-ai/dsh@0.1.0-rc.6(bundleddsh-llm-deepseek).Environment
An OpenAI-compatible chat-completions gateway whose streaming SSE emits
tool_calls[].idandtool_calls[].function.nameas empty strings""in every chunk after the first one, instead of omitting them.
This deviates from OpenAI's official spec (which only sends
id/nameinthe opening chunk and elides them afterwards), but such gateways exist in
the wild and
dshcurrently mis-handles them, making tool calls unusableend-to-end.
Repro (illustrative SSE chunks)
Expected
Final assembled tool-call block:
id="call_xxx",name="ls".Actual
Block collapses to
id=""andname="". Downstream:tool/callwith emptyname.ToolNotFoundError: unknown tool "".assistant.tool_calls[].function.name = "",which strict validators reject with HTTP 400:
invalid input messages format. 'name'.Net user-visible effect: tools never work on this gateway; each turn
either fails to invoke a tool or 400s on the follow-up request.
Root cause
packages/llm/deepseek/.../adapter.ts(published asdsh-llm-deepseek/lib/index.jsaround lines 321–322):""satisfies!== undefined, so each subsequent delta chunk overwritesthe good values captured from chunk 1.
Suggested fix
Treat empty strings as absent, matching the intent of "only present on the
first chunk":
Verified locally: after this one-liner, tool calls work as expected on the
same gateway/model/session. Happy to open a PR if maintainers prefer.
Additional context
id/nameonly on the opening chunk, so this fixalso stays correct for compliant providers.
argumentsaccumulator already tolerates empty string via?? ""++=, so no change is needed there.All reactions