Description
When using an OpenAI-compatible API (DashScope token-plan endpoint with GLM-5.2), tool calls fail with:
OpenAI Chat tool call delta is missing id or name
The root cause is that some OpenAI-compatible APIs send empty strings ("") for id and function.name on subsequent tool call deltas instead of omitting them or sending null. For example:
delta 1: {"id":"call_8c1f...","function":{"name":"calculator","arguments":"{"}}
delta 2: {"id":"","function":{"name":"","arguments":"\"expression\": "}}
delta 3: {"id":"","function":{"name":"","arguments":"\"2"}}
In ToolStream.appendOrStart, the nullish coalescing operator (??) does not treat "" as absent, so the fallback to accumulated values never triggers. The !id check then fails on the empty string.
OpenCode version
v2 branch (also affects published opencode2 next builds)
Steps to reproduce
- Configure an OpenAI-compatible provider pointing to DashScope token-plan endpoint (
token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1)
- Add a model like
glm-5.2 with tool_call: true
- Send a prompt that triggers a tool call
- The streaming response fails on the second tool call delta
Operating System
Linux (x86_64)
Description
When using an OpenAI-compatible API (DashScope token-plan endpoint with GLM-5.2), tool calls fail with:
The root cause is that some OpenAI-compatible APIs send empty strings (
"") foridandfunction.nameon subsequent tool call deltas instead of omitting them or sendingnull. For example:In
ToolStream.appendOrStart, the nullish coalescing operator (??) does not treat""as absent, so the fallback to accumulated values never triggers. The!idcheck then fails on the empty string.OpenCode version
v2 branch (also affects published opencode2 next builds)
Steps to reproduce
token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1)glm-5.2withtool_call: trueOperating System
Linux (x86_64)