You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AIHubMix provider: streaming completes output but errors near end with ZodError (invalid_union: reason/part/delta) #7439
When using the built-in AIHubMix provider, OpenCode can stream most of the assistant output, but near the end of the stream it throws a ZodError and marks the request as failed.
The error is an invalid_union with fields like:
path ["reason"]: expected string, received object
path ["part"]: expected object, received undefined
path ["delta"]: expected string, received undefined
I use the built-in provider XIAOMI now, and it just works well.
Plugins
at first with oh-my-opencode, and it can be reproduced with none
OpenCode version
1.1.8, and can be reproduced in 1.1.6 and 1.1.1
Steps to reproduce
Use the bulit-in AIHubMix provider:
Select an AIHubMix model.
Send any prompt (e.g. hello / 你好?).
Observe streaming output appears, then near completion OpenCode throws ZodError.
Model tested:
These issues all involve streaming response validation failures where the expected types don't match the actual API response formats. If your issue is specific to AIHubMix provider or involves different API response structures, feel free to ignore these references.
After switching the provider from @aihubmix/ai-sdk-provider to @ai-sdk/openai-compatible, everything works fine.
Since aihubmix is already OpenAI-compatible, there might be some compatibility issues in the dedicated provider implementation. This might be worth investigating.
I was wondering if there are any updates or a tentative timeline for a fix? I rely heavily on this service for my daily workflow, so I’m looking forward to getting it back up and running. > Thanks for all your hard work on this!
Experiencing the same issue with a custom OpenAI-compatible provider.
I'm building a provider using @ai-sdk/openai-compatible (v2.0.30). Streaming works fine—text renders correctly—but validation fails at the end with:
[{"expected":"string","code":"invalid_type","path":["reason"],"message":"Invalid input: expected string, received object"}]
Environment
OpenCode: 1.2.10
OS: macOS (Darwin 25.2.0)
Provider: Custom via @ai-sdk/openai-compatible
Backend: Qwen3-32B on vLLM
What I've ruled out
Server response is clean — returns {"type":"completion"} with no reason field
SSE format is correct — "finish_reason":"stop" as a string, matching the OpenAI spec exactly
AI SDK works standalone — using the same provider with streamText directly passes without issues
Only fails inside OpenCode — the ["reason"] path in the validation error doesn't exist in @ai-sdk/openai-compatible's schema (which uses finish_reason), so this appears to be OpenCode's own validation layer expecting a different shape
This is blocking adoption of custom providers. Happy to provide logs or a minimal repro—any workaround or timeline for a fix would be appreciated. @rekram1-node
Activity
github-actions commentedon Jan 9, 2026
This issue might be a duplicate of existing issues. Please check:
These issues all involve streaming response validation failures where the expected types don't match the actual API response formats. If your issue is specific to AIHubMix provider or involves different API response structures, feel free to ignore these references.
qiyuanhuakai commentedon Jan 9, 2026
xrh0905 commentedon Jan 11, 2026
Can confirm this issue on latest opencode desktop (1.0.152).
Possible duplicated as #7674 .
qiyuanhuakai commentedon Jan 11, 2026
将 provider 从 @aihubmix/ai-sdk-provider 切换到 @ai-sdk/openai-compatible 后,一切就正常工作了。
既然 aihubmix 本身就是 OpenAI 兼容的,可能是专属的 provider 实现本身存在某些兼容性问题。建议排查一下。
After switching the provider from @aihubmix/ai-sdk-provider to @ai-sdk/openai-compatible, everything works fine.
Since aihubmix is already OpenAI-compatible, there might be some compatibility issues in the dedicated provider implementation. This might be worth investigating.
zguiyang commentedon Jan 17, 2026
Hi team,
I was wondering if there are any updates or a tentative timeline for a fix? I rely heavily on this service for my daily workflow, so I’m looking forward to getting it back up and running. > Thanks for all your hard work on this!
elzorrorebelde commentedon Jan 18, 2026
In my case, I have this:
and I also see those errors.
Update Nix dependencies and opencode configuration
Rakan-AlZagha commentedon Feb 22, 2026
Experiencing the same issue with a custom OpenAI-compatible provider.
I'm building a provider using
@ai-sdk/openai-compatible(v2.0.30). Streaming works fine—text renders correctly—but validation fails at the end with:Environment
@ai-sdk/openai-compatibleWhat I've ruled out
{"type":"completion"}with noreasonfield"finish_reason":"stop"as a string, matching the OpenAI spec exactlystreamTextdirectly passes without issues["reason"]path in the validation error doesn't exist in@ai-sdk/openai-compatible's schema (which usesfinish_reason), so this appears to be OpenCode's own validation layer expecting a different shapeThis is blocking adoption of custom providers. Happy to provide logs or a minimal repro—any workaround or timeline for a fix would be appreciated. @rekram1-node
github-actions commentedon Apr 24, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.