Skip to content

Silent stream truncation persisted as complete response + TUI desync after mid-stream provider errors #44210

Closed as not planned

Description

@federico-fabiani

Description

TUI responses get cut off mid-generation: mid-text, mid-reasoning, or before/during tool calls. UI stays blocked until I manually type "resume". Happens dozens of times per day.

Dug through ~/.local/share/opencode/log/opencode.log and SQLite storage (opencode.db). Provider fails in two ways; opencode's handling leaves the user stuck in both.

Failure mode 1: loud stream errors, then TUI desync

level=ERROR message="stream error" providerID=opencode modelID=x-preview-f-free
error.error="AI_APICallError: Upstream request failed: Endpoint is unavailable."
error.error="AI_APICallError: Service Unavailable"

Errors are logged and sometimes auto-retried (~3s retry observed). That part works. But in one incident the backend retried, completed every loop step, logged clean exiting loop, while the TUI stayed locked on a spinner for ~40 minutes (log silent between 15:36:47Z and 16:15:31Z, until I nudged it). The recovered response never rendered client-side either.

So: mid-stream error + successful server-side retry = TUI can stay desynced permanently even though the backend finished.

Failure mode 2: silent truncation persisted as complete response

Provider closes the SSE stream early, no error event. AI SDK seems to treat end-of-stream as normal completion. opencode then:

  1. persists partial text to storage
  2. logs nothing
  3. exits the loop cleanly

Evidence from 2026-08-22:

UTC Event
16:20:50 stream starts (x-preview-f-free)
16:21:24.820 partial text part written to DB
16:21:24.862 exiting loop, 42 ms later
(none) no ERROR or WARN logged

Stored part ends mid-word:

part msg_02a466164001QEP4TCIt5B1QXx (session ses_fd5f975f3ffeGcbaIQY7uioPOj)
type=text, 1448 chars
tail: "...## Cosa fare\n\n- **Subito**: `/models` per passare a un modello stabile nelle"

No error reaches the user here either. Response stops mid-sentence; backend considers the turn complete; nothing gets retried. This is why the failures are invisible.

Expected behavior

  • Detect incomplete generations (stream ends without a proper finish): show an error or retry instead of silently saving partial output.
  • After error + successful auto-retry: unlock the TUI and render the completed response instead of staying stuck.

Environment

  • opencode version: 1.18.18
  • Platform: Windows 11, PowerShell 7.6 (pwsh), TUI
  • Model/provider: opencode / x-preview-f-free
  • Incidents date: 2026-08-22 (8x "Endpoint is unavailable", 3x "Service Unavailable", multiple silent truncations across several sessions)

Activity

  1. github-actions commented on Aug 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues and add any unique details from your report as comments there if they add new information. If your report covers distinct aspects not addressed in those issues, a maintainer can clarify.

  2. federico-fabiani commented on Aug 22, 2026

    @federico-fabiani
    Author

    Consolidated into #44044 (evidence posted there). See also #38747, #32366, #40146.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions