GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider): default a stream-idle timeout for openai-compatible providers by beatakouchnir · Pull Request #46741 · anomalyco/opencode

Conversation

@beatakouchnir

@beatakouchnir beatakouchnir commented Sep 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Fixes #46581

Type of change

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

What does this PR do?

Custom @ai-sdk/openai-compatible providers never got a chunkTimeout or headerTimeout default. wrapSSE() is a no-op when chunkTimeout is unset (if (typeof ms !== "number" || ms <= 0) return res), so these providers stream with no idle guard at all — a backend that stalls mid-stream hangs the session indefinitely. Named providers (openai, anthropic) already default a timeout; this gives openai-compatible providers the same protection via an overridable chunkTimeout default (300s, matching the header-timeout default).

I moved the existing inline includeUsage defaulting into a small exported applyOpenAICompatibleDefaults() and added the chunkTimeout default there. includeUsage behavior is unchanged.

This covers the stream-stall mode (no SSE bytes for the timeout window). The other mode in #46581 — the stream closing on [DONE] while the AI SDK's fullStream still awaits a usage chunk — is not addressed here, because a byte-idle timeout can't fire once the final byte has arrived; that one needs a change at the AI-SDK adapter and I'd rather keep it separate.

I hit this running unattended opencode run sessions against a local llama.cpp server; a couple stalled and hung until an external timeout. Forensics are in the comment on #46581.

How did you verify your code works?

  • New test/provider/openai-compatible-defaults.test.ts: default applied for openai-compatible, not applied to other providers, never overrides an explicit chunkTimeout, preserves includeUsage: false.
  • test/provider/header-timeout.test.ts already verifies that a set chunkTimeout turns a stalled SSE stream into a ResponseStreamError; this change makes that apply by default.
  • Full test/provider/ suite passes (593 tests). typecheck and prettier clean.

Screenshots / recordings

n/a — no UI change.

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@beatakouchnir @claude
fix(provider): default a stream-idle timeout for openai-compatible pr…
24980b7
…oviders

Custom @ai-sdk/openai-compatible providers received no chunkTimeout or
headerTimeout default, so wrapSSE ran unwrapped and a backend that stalled
mid-stream would hang the session indefinitely (issue anomalyco#46581). Named providers
(openai, anthropic) already default a timeout; this extends the same protection
to openai-compatible providers via an overridable chunkTimeout default.

The openai-compatible option defaulting (previously an inline includeUsage
assignment) is extracted into a pure, exported applyOpenAICompatibleDefaults()
so the behavior is unit-testable in isolation. includeUsage handling is
unchanged; the chunkTimeout default is additive and overridable via
provider options.

The end-to-end "stall raises ResponseStreamError" behavior is already covered by
test/provider/header-timeout.test.ts; the new unit test covers that the default
is applied for openai-compatible, not applied to other providers, and never
overrides an explicit value.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions github-actions Bot added the needs:issue label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@beatakouchnir beatakouchnir mentioned this pull request Sep 2, 2026
OpenCode hangs indefinitely with @ai-sdk/openai-compatible although backend completes successfully #46581
Closed
@github-actions github-actions Bot removed the needs:issue label Sep 2, 2026
holny
holny reviewed Sep 2, 2026
View reviewed changes

@holny holny left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nice catch — the ai-sdk layer already had the machinery, it just never got a default for custom openai-compatible providers. The no-op guard in wrapSSE makes an unset timeout a silent gap, so this is a real fix; the includeUsage extraction preserves behavior and the explicit-chunkTimeout override is covered by tests.

Context that's relevant here: the V2 native route path (packages/ai) has no chunk-idle guard at all — not just a missing default. That's tracked in #46692 (being worked separately), so no overlap with this PR; just noting the ai-sdk layer won't be the only surface needing this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@beatakouchnir

beatakouchnir commented Sep 3, 2026

Copy link
Copy Markdown
Author

Thanks for the review @holny. Looks like #46890 has since landed a global chunkTimeout default (also 5 min, disable-per-provider via chunkTimeout: false), which covers the openai-compatible case here and then some — so this PR is redundant now. Closing in favor of it. Glad the stall gap is addressed; the [DONE]-without-usage variant from #46581 is a separate mode that a byte-idle timeout won't catch, so that one's still open.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@beatakouchnir beatakouchnir closed this Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@holny holny holny left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

OpenCode hangs indefinitely with @ai-sdk/openai-compatible although backend completes successfully

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@beatakouchnir @holny
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.