Skip to content

Aborted provider stream recorded as clean stop (finish=unknown, zero usage, no text) — subagent returns empty with no error #37852

Description

@fernanDOTdo

Description

When a provider stream terminates mid-generation without a finish reason or usage chunk, opencode records the assistant message with finish=unknown, zero tokens, and no text part, then exits the agent loop as if the turn completed normally. No error is logged or surfaced.

For a subagent this means the parent receives an empty task result with no error signal — it cannot distinguish "provider dropped the stream" from "agent finished with nothing to say."

Observed on 1.18.3 with a subagent on fireworks-ai/accounts/fireworks/models/deepseek-v4-flash: 6 healthy tool-call turns, then a ~34.5s stream that emitted ~15.8 KB of reasoning and simply ended — no text, zero recorded usage, finish=unknown, nothing in the logs. The loop exited cleanly and the parent's task tool returned an empty <task_result>.

Expected: a stream that ends without a finish reason (or with zero content and zero usage) is treated as an error and retried — or at minimum surfaced as a distinct truncated finish state so callers can react (e.g. a subagent's parent retrying or failing the task explicitly).

Plugins

superpowers@git+https://github.com/obra/superpowers.git

OpenCode version

1.18.3

Steps to reproduce

Intermittent by nature (depends on the provider dropping the stream mid-generation):

  1. Run an agent on a model/provider combination that streams long reasoning segments (observed: Fireworks deepseek-v4-flash).
  2. Have the provider connection terminate mid-turn, after reasoning deltas but before any text/tool call and before the usage chunk.
  3. Observe the assistant message persisted with finish=unknown and zero tokens; the loop exits; no error anywhere.

Operating System

macOS 26.5.2

Terminal

supacode

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