fix(opencode): fail runs when the model stream ends without a finish … - #40061
Open
zhang17-24 wants to merge 1 commit into
Open
fix(opencode): fail runs when the model stream ends without a finish …#40061zhang17-24 wants to merge 1 commit into
zhang17-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
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Found a potential related PR: PR #39970: Why it's related: This PR addresses a similar issue with SSE stream terminations. While PR #40061 focuses on mapping the "other"/undefined finish reason to "error" to fail runs appropriately, PR #39970 appears to handle robustness for silent SSE terminations in long-lived provider streams. Both deal with incomplete/failed upstream connections affecting model streaming behavior. You should check if these PRs are complementary or if one supersedes the other. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #39968
Type of change
What does this PR do?
When an upstream SSE connection dies mid-turn without a finish frame, the AI SDK synthesizes a finish-step with finishReason "other"/undefined. opencode mapped that to the benign "unknown" finish, so the truncated output was persisted as a successful turn and
opencode runexited 0. This maps "other"/undefined to "error" instead, and a step-finish with reason "error" fails the turn, so the run exits non-zero while still keeping the partial output.How did you verify your code works?
Screenshots / recordings
N/A (not a UI change)
Checklist