Repository navigation
Streaming tool calls fail when later deltas send an empty name #3955
Replies: 3 comments
|
Yes — empty continuation Workarounds that do not need a checkout patch:
The truthy guard you suggested is the right upstream fix; it is not in |
|
Yes, tolerate it — but the truthy guard on Why the empty if (payload === DONE) {
for (const block of order) {
yield { type: 'block-end', index: block.index, block: closeBlock(block) }
}built from the same overwritten accumulator, case 'tool-call': return {
type: 'tool-call',
id: CallId(block.callId ?? ''),
name: block.name ?? '',
arguments: block.text,
}and private assemble(partial: PartialBlock, index: number): ContentBlock {
if (partial.block) return partial.blockSo on this adapter the assembler's own guards and its The part your patch misses. Your repro frames carry no if (sourceRecord['kind'] !== 'tool'
|| typeof sourceRecord['callId'] !== 'string'
|| sourceRecord['callId'] === '') {
throw new Error(`${subject} message must have tool source`)
}Fix the name only and you trade a per-turn if (call.id) block.callId = call.id
if (call.function?.name) block.name = call.function.nameTruthy, not A gateway that never sends an Not fixable from user config. There is no setting that changes these guards; it needs either a patched |
|
The We fault-injected the real pi-ai openai-completions accumulator (client/SSE parser/assembly unmodified; only the wire bytes synthetic) with this exact delta family — empty-string id/name continuations, late identity, parallel calls with no ids at all (index-keyed interleave), and index-less id-keyed deltas: all assemble correctly. The semantics that make it immune: blocks are keyed by That measured rule (index-first keying + first-non-empty-wins) is a ready-made semantic for the |
Uh oh!
There was an error while loading. Please reload this page.
Summary
A local Web session on
dsh webfails every model tool call with:The browser connection and tool catalog are healthy:
/api/host.describereturns 200 and the request header contains the expected tool names (bash,read,grep, etc.). The persistedtool/callevents, however, containname: ""for the failed calls.Reproduction
The upstream DeepSeek-compatible streaming response can emit tool-call deltas like:
{"tool_calls":[{"index":0,"function":{"name":"bash","arguments":""}}]} {"tool_calls":[{"index":0,"function":{"name":"","arguments":"{\\"command\\":\\"pwd\\"}"}}]}The first delta supplies the valid name; a later delta repeats an empty name.
In
packages/llm/llm-deepseek/src/translate.ts, the translator currently does:The empty later value overwrites
bash, so the executor receives an empty tool name and reportsunknown tool "".Suggested fix
Only update the accumulated name for a non-empty value:
A regression test should cover a
bashname followed by an empty-name delta.Is this empty repeated
nameexpected behavior from the compatible gateway, and should the adapter tolerate it as above?All reactions