Skip to content

fix(opencode): stop a turn when the provider stream goes silent - #54015

Closed
moritzWa wants to merge 1 commit into
anomalyco:devfrom
moritzWa:stream-idle-timeout
Closed

moritzWa wants to merge 1 commit into
anomalyco:devfrom
moritzWa:stream-idle-timeout

Conversation

@moritzWa

@moritzWa moritzWa commented Oct 8, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #54014

Type of change

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

What does this PR do?

If the provider stream sends nothing for 30 minutes, the processor stops the turn with an error: "No response from the provider for 30 minutes. The turn was stopped; send a message to retry." The session goes idle with that error instead of showing as working forever.

  • The clock pauses while a tool is executing (from tool-call until its tool-result/tool-error). Subagents, long commands and permission prompts can legitimately keep the stream silent for hours. Silence while the model is still writing a tool's input does count, since that is where a stalled stream shows up.
  • The error is not retried. A retry against the same stalled provider would usually wait out the same 30 minutes again.
  • OPENCODE_STREAM_IDLE_TIMEOUT_MS changes the limit; 0 turns it off. 30 minutes stays well above long but legitimate silences, like a provider buffering a large tool call (cursor-opencode-provider allows 20 minutes for that).
  • It races a watchdog against the stream drain, so the stream's scope closes and the provider request is aborted when it fires.

How did you verify your code works?

Two tests in test/session/processor-effect.test.ts with a 400 ms limit: a stream that sends one chunk and hangs stops with the error and the session goes idle (it times out without this change); a tool that runs 1.5 s does not trip it. bun typecheck and the session tests pass. prompt.test.ts has load-dependent 5 s timeouts that fail intermittently on dev too.

Screenshots / recordings

No UI change: the error shows in the transcript like any other provider error.

Checklist

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

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent

opencode-agent Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for tracking this down and including tests, @moritzWa!

The dev branch (v1) only takes critical fixes: data loss, security problems, or crashes and breakage with no workaround. A turn that hangs on a silent provider stream can be aborted and retried, and for HTTP providers the existing chunkTimeout provider option already ends idle SSE streams. So this doesn't meet that bar, and I'm closing the PR.

If v2 has the same gap (a custom provider stream going silent with no idle timeout), a pull request against the v2 branch would be the right place for this. v2 is a separate implementation, so the change would need to be redone there rather than ported.

@opencode-agent opencode-agent Bot mentioned this pull request Oct 12, 2026
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.

Session shows 'working' forever when a provider stream goes silent

1 participant