Skip to content

feat: add streaming option to provider config to support non-streaming backends - #14719

Closed
poelzi wants to merge 1 commit into
anomalyco:devfrom
poelzi:feat/disable-streaming
Closed

poelzi wants to merge 1 commit into
anomalyco:devfrom
poelzi:feat/disable-streaming

Conversation

@poelzi

@poelzi poelzi commented Feb 22, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #785

Type of change

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

What does this PR do?

  • Adds a streaming boolean option to the provider configuration schema (Provider.options.streaming)
  • When streaming is set to false, uses the AI SDK's simulateStreamingMiddleware() to convert streamText() calls into generateText() + simulated stream responses
  • This enables OpenCode to work with OpenAI-compatible backends that don't support streaming (e.g. custom/self-hosted inference servers)

How did you verify your code works?

Checked against CatGPT

Checklist

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

Usage

{
  "provider": {
    "my-backend": {
      "options": {
        "streaming": false
      }
    }
  }
}

Implementation

The implementation leverages the existing wrapLanguageModel middleware system. When streaming: false is configured for a provider, simulateStreamingMiddleware() from the ai package is added to the middleware chain. This middleware intercepts doStream calls, calls doGenerate instead, and converts the result back into stream events — making it a transparent drop-in that requires no changes to the rest of the codebase.

…g backends

Add a 'streaming' boolean option to the provider configuration schema.
When set to false, the AI SDK's simulateStreamingMiddleware is used to
make non-streaming (doGenerate) requests and convert the response into
a simulated stream, allowing the rest of the processing pipeline to
work unchanged.

This is useful for custom OpenAI-compatible backends that do not
support server-sent events / streaming responses.

Usage in opencode.json:
  {
    "provider": {
      "myprovider": {
        "options": {
          "streaming": false
        }
      }
    }
  }
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 22, 2026
@github-actions

github-actions Bot commented Feb 22, 2026 •

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No "Type of change" checkbox is checked. Please select at least one.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot closed this Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there a way to disable streaming mode?

1 participant