AIHubMix provider: streaming completes output but errors near end with ZodError (invalid_union: reason/part/delta) #4489

Open
opened 2026-02-16 17:44:21 -05:00 by yindo · 6 comments
Owner

Originally created by @qiyuanhuakai on GitHub (Jan 9, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

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:
  • Claude Haiku 4.5 (built-in)
  • GPT-5.2 (built-in)
  • glm-4.7 (built-in)
  • grok-4-1-fast-non-reasoning(added by myself)
  • gemini-3-flash-preview (added by myself)

Screenshot and/or share link

Image

Operating System

Ubuntu 24.04, in WSL2

Terminal

Windows Terminal

Originally created by @qiyuanhuakai on GitHub (Jan 9, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description 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: - Claude Haiku 4.5 (built-in) - GPT-5.2 (built-in) - glm-4.7 (built-in) - grok-4-1-fast-non-reasoning(added by myself) - gemini-3-flash-preview (added by myself) ### Screenshot and/or share link <img width="2461" height="1428" alt="Image" src="https://github.com/user-attachments/assets/71c12b68-95e6-412d-8a4d-62cc9a9dbad0" /> ### Operating System Ubuntu 24.04, in WSL2 ### Terminal Windows Terminal
yindo added the windowsbug labels 2026-02-16 17:44:21 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 9, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5981: All Mistral models fail with ZodError: "finish" expected string, received object - Same type of ZodError with streaming validation failures (expected string, received object)
  • #5997: Mistral provider fails: auto-install ENOENT + ZodError on streaming responses - Contains the same ZodError validation pattern during streaming responses
  • #5759: AI_TypeValidationError on Grok Fast 1 (Opencode Zen mode) - Related validation errors with invalid_union patterns

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.

@github-actions[bot] commented on GitHub (Jan 9, 2026): This issue might be a duplicate of existing issues. Please check: - #5981: All Mistral models fail with ZodError: "finish" expected string, received object - Same type of ZodError with streaming validation failures (expected string, received object) - #5997: Mistral provider fails: auto-install ENOENT + ZodError on streaming responses - Contains the same ZodError validation pattern during streaming responses - #5759: AI_TypeValidationError on Grok Fast 1 (Opencode Zen mode) - Related validation errors with invalid_union patterns 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.
Author
Owner

@qiyuanhuakai commented on GitHub (Jan 9, 2026):

cat ~/.cache/opencode/package.json
{
  "dependencies": {
    "opencode-copilot-auth": "0.0.9",
    "opencode-anthropic-auth": "0.0.5",
    "oh-my-opencode": "2.14.0",
    "@aihubmix/ai-sdk-provider": "1.0.1"
  }
}%    
@qiyuanhuakai commented on GitHub (Jan 9, 2026): ``` cat ~/.cache/opencode/package.json { "dependencies": { "opencode-copilot-auth": "0.0.9", "opencode-anthropic-auth": "0.0.5", "oh-my-opencode": "2.14.0", "@aihubmix/ai-sdk-provider": "1.0.1" } }% ```
Author
Owner

@xrh0905 commented on GitHub (Jan 10, 2026):

Can confirm this issue on latest opencode desktop (1.0.152).
Possible duplicated as #7674 .

@xrh0905 commented on GitHub (Jan 10, 2026): Can confirm this issue on latest opencode desktop (1.0.152). Possible duplicated as #7674 .
Author
Owner

@qiyuanhuakai commented on GitHub (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.

@qiyuanhuakai commented on GitHub (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.
Author
Owner

@zguiyang commented on GitHub (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!

@zguiyang commented on GitHub (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!
Author
Owner

@shackra commented on GitHub (Jan 18, 2026):

cat ~/.cache/opencode/package.json
{
  "dependencies": {
    "opencode-copilot-auth": "0.0.9",
    "opencode-anthropic-auth": "0.0.5",
    "oh-my-opencode": "2.14.0",
    "@aihubmix/ai-sdk-provider": "1.0.1"
  }
}%    

In my case, I have this:

{
  "dependencies": {
    "opencode-copilot-auth": "0.0.5",
    "opencode-anthropic-auth": "0.0.2",
    "@ai-sdk/openai-compatible": "latest",
    "@ai-sdk/openai": "latest",
    "@ai-sdk/anthropic": "latest"
  }
}

and I also see those errors.

@shackra commented on GitHub (Jan 18, 2026): > ``` > cat ~/.cache/opencode/package.json > { > "dependencies": { > "opencode-copilot-auth": "0.0.9", > "opencode-anthropic-auth": "0.0.5", > "oh-my-opencode": "2.14.0", > "@aihubmix/ai-sdk-provider": "1.0.1" > } > }% > ``` In my case, I have this: ``` { "dependencies": { "opencode-copilot-auth": "0.0.5", "opencode-anthropic-auth": "0.0.2", "@ai-sdk/openai-compatible": "latest", "@ai-sdk/openai": "latest", "@ai-sdk/anthropic": "latest" } } ``` and I also see those errors.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4489