Skip to content

feat(opencode): respect provider/model streaming: false to disable response streaming#31357

Open
sebdanielsson wants to merge 2 commits into
anomalyco:devfrom
sebdanielsson:feat/disable-streaming-option
Open

feat(opencode): respect provider/model streaming: false to disable response streaming#31357
sebdanielsson wants to merge 2 commits into
anomalyco:devfrom
sebdanielsson:feat/disable-streaming-option

Conversation

@sebdanielsson
Copy link
Copy Markdown

@sebdanielsson sebdanielsson commented Jun 8, 2026

Issue for this PR

Closes #785

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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.streaming config 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's simulateStreamingMiddleware, which calls doGenerate (stream: false on 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 experimentalNativeLlm runtime is a separate path and isn't handled here.

How did you verify your code works?

  • Added a test in test/session/llm.test.ts that sets streaming: false and 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 asserts body.stream isn't true.
  • bun test test/session/llm.test.ts -> 27 pass, plus typecheck and oxlint clean.

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copilot AI review requested due to automatic review settings June 8, 2026 12:30
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 when options.streaming === false.
  • Add a test asserting that provider requests are not made with stream: true when 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.

Comment thread packages/opencode/src/session/llm.ts
Comment thread packages/opencode/test/session/llm.test.ts
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

sebdanielsson and others added 2 commits June 8, 2026 15:40
…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>
@sebdanielsson sebdanielsson force-pushed the feat/disable-streaming-option branch from 0da9544 to fda049c Compare June 8, 2026 13:40
@sebdanielsson
Copy link
Copy Markdown
Author

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. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there a way to disable streaming mode?

2 participants