anomalyco / anomalyco/opencode
[Bug] Stream silently returns empty when calling Zhipu via Anthropic-compatible provider (`/api/anthropic`)
@jlongster is already working on this.
Since Aug 13, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
When configuring OpenCode to call Zhipu GLM (智谱) via the Anthropic-compatible endpoint (https://open.bigmodel.cn/api/anthropic) with @ai-sdk/anthropic, the LLM stream silently returns empty:
- Stream starts (
message=stream ... agent=build mode=primary) - Within ~200–300ms the loop exits with
step=1→exiting loop - No chunks, no error, no warning, exit code 0
- Output is completely blank — the user sees nothing
This is the "SSE parser silently swallows error" pattern already referenced in #33888, but happening at the provider protocol level even when provider.npm is correctly applied (the catalog shows package: @ai-sdk/anthropic, so the npm field IS taking effect — this is not the npm-ignored case).
Environment
- OpenCode: 1.18.18 (installed via
npm install -g opencode-ai) - OS: macOS Darwin 25.5.0 (arm64)
- Provider config:
{
"provider": {
"zhipu": {
"npm": "@ai-sdk/anthropic",
"name": "智谱 GLM",
"options": {
"baseURL": "https://open.bigmodel.cn/api/anthropic",
"apiKey": "..."
},
"models": {
"glm-5.2": { "name": "GLM-5.2", "reasoning": true, "tool_call": true }
}
}
},
"model": "zhipu/glm-5.2"
}
Reproduction
- Configure Zhipu via the Anthropic-compatible endpoint as shown above.
- Run
opencode run "测试". - Observe: blank stdout, exit 0, no error in logs.
Expected
Either:
- A successful streamed response, OR
- A visible error explaining what the SDK failed to parse.
Actual
Stream silently aborts. Debug log (--print-logs --log-level DEBUG) timeline:
T+0 loop step=0
T+0 stream providerID=zhipu modelID=glm-5.2 agent=build mode=primary
T+0 llm runtime selected llm.runtime=ai-sdk llm.provider=zhipu
T+250ms loop step=1
T+250ms exiting loop
T+254ms disposing instance
No chunk, no error, no warn between stream and exiting loop. The 250ms duration is far shorter than a real API call (~3–4s), so the SDK is returning an empty stream rather than failing loudly.
Evidence that the upstream API is healthy
Direct curl against the same endpoint returns valid SSE chunks:
curl -sN -X POST "https://open.bigmodel.cn/api/anthropic/v1/messages" \
-H "x-api-key: $KEY" -H "anthropic-version: 2023-06-01" \
-d '{"model":"glm-5.2","max_tokens":50,"stream":true,"messages":[{"role":"user","content":"hi"}]}'
Returns standard message_start / content_block_delta / message_stop events. The failure is not at the API layer — it's somewhere in the @ai-sdk/anthropic ↔ Zhipu anthropic-compat boundary.
Workaround
Switch to Zhipu's OpenAI-compatible endpoint — it works flawlessly:
{
"provider": {
"zhipu": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://open.bigmodel.cn/api/paas/v4",
"apiKey": "..."
},
"models": { "glm-5.2": { ... } }
}
}
}
Same opencode run "测试" then returns the expected response immediately. This matches what community members recommended in #2431.
What I'd like OpenCode to improve
- Don't silently swallow stream errors. If the SSE parser hits something it can't handle, emit at least a WARN-level log line. The current behavior (zero diagnostic output, exit 0) makes this category of bug nearly impossible to diagnose without source-level debugging.
- Document the Zhipu anthropic-compat incompatibility — either fix the SDK path, or add a config-time warning that for Zhipu, the OpenAI-compatible endpoint is the recommended one.
Related issues
- #33888 — Provider-level
npmfield silently ignored (different root cause, similar silent-failure surface) - #2431, #2383 — Community already recommending OpenAI-compatible for Zhipu
- #33280 — GLM-5.2 + OpenAI-compatible has separate "Empty message content sanitised" issue (orthogonal)
Diagnostics
Happy to provide full debug logs, opencode debug v2 output, or run any experimental builds if it helps narrow down where the stream is being dropped.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.