fix(opencode): fail runs when the model stream ends without a finish frame - #40032
fix(opencode): fail runs when the model stream ends without a finish frame#40032zhang17-24 wants to merge 1 commit into
Conversation
…frame An upstream SSE connection cut mid-turn (EOF with no finish frame, no error event) made the AI SDK emit a synthesized finish-step with finishReason "other"/undefined. opencode mapped that to the benign "unknown" finish, persisted the truncated output as a completed turn, and `opencode run` exited 0 — silently accepting partial generations as success (issue anomalyco#39968). - ai-sdk adapter now maps "other"/undefined finish reasons to "error" instead of "unknown", matching the native runtime's semantics - the session processor fails the turn on an "error" step-finish, publishing a session error so `opencode run` exits non-zero
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
The following comment was made by an LLM, it may be inaccurate: Potential related PRs found:
These PRs appear to be related to the same problem space of handling incomplete/truncated provider streams. PR #39970 in particular seems highly relevant as it also deals with "silent SSE terminations" which is the exact scenario described in #40032 (EOF with no finish frame). |
|
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. |
Summary
An upstream SSE connection cut mid-turn (EOF with no finish frame, no error event) made the AI SDK emit a synthesized finish-step with finishReason "other"/undefined. opencode mapped that to the benign "unknown" finish, persisted the truncated output as a completed turn, and
opencode runexited 0 — silently accepting partial generations as success (issue #39968).Changes
opencode runexits non-zero.Test plan
Human note
I am a 19-year-old independent full-stack developer. I reviewed the full diff and confirmed the change: a model stream that ends without a finish frame now fails the run instead of exiting 0 with truncated output.
Fixes #39968