anomalyco / anomalyco/opencode
OpenCode hangs indefinitely with @ai-sdk/openai-compatible although backend completes successfully
@neriousy is already working on this.
Since Sep 1, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Environment
- OS: Windows
- OpenCode: 1.18.25
- Provider: 9router (@ai-sdk/openai-compatible)
- 9router: 0.5.59
Problem
OpenCode never finishes responding.
The UI remains in the loading state forever.
However, the backend successfully completes the request.
Reproduction
- Configure OpenCode to use 9router.
- Send a simple prompt ("Hello").
- Wait.
Result:
- Spinner never stops.
- No error appears.
- No response is rendered.
Backend evidence
9router logs show:
- request received
- model fallback works
- final model succeeds
- DONE
So the backend successfully finishes the request.
Investigation
I inspected OpenCode source code.
Relevant findings:
- provider/provider.ts
- session/llm.ts
- session/llm/ai-sdk.ts
- session/processor.ts
Spinner is not stopped when the "finish" event arrives.
Instead it only stops after:
Stream.runDrain()
→ cleanup()
→ Runner.onIdle()
→ status = idle
Therefore if fullStream never finishes, the UI remains loading forever.
Possible cause
For @ai-sdk/openai-compatible providers, OpenCode automatically injects:
includeUsage = true
If the backend stream does not produce the expected usage event (or produces it in an incompatible format), fullStream may never complete.
This matches the observed behavior:
Backend:
DONE
Frontend:
Loading forever.
Expected
OpenCode should exit loading once the backend has completed the stream.
Additional information
I already confirmed:
- backend receives request
- backend completes request
- backend is reachable
- issue persists with different models
Therefore the issue appears to be in the OpenCode streaming lifecycle rather than request dispatch.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
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.