feat(opencode): respect provider/model streaming: false to disable response streaming - #31357
sebdanielsson wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds a configuration-based way to disable true provider streaming while keeping the rest of the pipeline streaming-compatible by simulating a stream.
Changes:
- Add
simulateStreamingMiddleware()to opt out of on-the-wire streaming whenoptions.streaming === false. - Add a test asserting that provider requests are not made with
stream: truewhen streaming is disabled.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/opencode/src/session/llm.ts | Adds streaming opt-out logic and conditionally injects simulated streaming middleware. |
| packages/opencode/test/session/llm.test.ts | Adds coverage to confirm provider requests are non-streaming when configured. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
0da9544 to
fda049c
Compare
|
Just this version in a GitHub Action workflow, and it worked without the stream-stripping proxy we're currently using to get around this limitation. 👍 |
|
We hit the Bedrock side of this. Meta's Llama models on Bedrock reject tool use over One Bedrock-specific gap I ran into: the prompt-transform middleware only runs for |
fda049c to
b96bf57
Compare
Feel free to send it, thanks for testing!👍 |
|
+1 this, we're also dealing with an internal gateway without stream support, and would be great to have an opencode level shim for that. |
b3a6005 to
b8f9017
Compare
…ponse streaming Some OpenAI-compatible backends don't support streaming or return broken streamed output (e.g. self-hosted vLLM corrupting streamed tool-call args). The existing options.streaming config wasn't consumed, so there was no way to opt out. Honor options.streaming:false (per-model or per-provider) by adding the AI SDK's simulateStreamingMiddleware, which calls doGenerate (stream:false on the wire) and replays the result as a simulated stream, leaving the rest of the pipeline unchanged. Defaults to streaming on. Fixes anomalyco#785 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… stream values Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b8f9017 to
2a1004a
Compare
|
FYI: For those of you having problem using Gemma 4 31B on vLLM with OpenCode. Updating vLLM to 0.24.0 and using the vLLM example template solved all of our issues. |
|
@sebdanielsson so the same thing with E2B/E4B? Is it really just a bad template/parsing issue on Google's side, or (local) inference engine, or harness/scaffold side? NousResearch/hermes-agent#6626 (comment) NousResearch/hermes-agent#19887 |
Not my area of expertise but I think both. Many fixes for Gemma 4 landed in the latest 0.24.0 release. Have you tried it + using the vLLM provided template? This is the arguments we start vLLM with: Might be worth testing with the smaller MoW models. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
|
This should be merged its blocking AWS Bedrock support for LLama models. Please consider |
Issue for this PR
Closes #785
Type of change
What does this PR do?
Some OpenAI-compatible backends either don't support streaming or return broken streamed output. In my case a self-hosted vLLM (Gemma) corrupts streamed tool-call arguments (duplicates characters), so every edit comes back garbled. The existing
options.streamingconfig wasn't actually consumed, so there was no way to opt out.This makes
options.streaming: false(per-model or per-provider) actually work. When set, it adds the AI SDK'ssimulateStreamingMiddleware, which callsdoGenerate(stream: falseon the wire) and replays the result as a simulated stream — so the rest of the pipeline is unchanged. Defaults to streaming on, so existing behavior is untouched.{ "provider": { "vllm": { "options": { "streaming": false } } } }Only covers the default AI SDK path. The experimental
experimentalNativeLlmruntime is a separate path and isn't handled here.How did you verify your code works?
test/session/llm.test.tsthat setsstreaming: falseand has the mock server return a non-streaming JSON completion. It only parses if the request was non-streaming (a streamed request expects SSE and fails), and assertsbody.streamisn'ttrue.bun test test/session/llm.test.ts-> 27 pass, plus typecheck and oxlint clean.Screenshots / recordings
No UI changes.
Checklist