fix(opencode): fail runs when the model stream ends without a finish … - #40061
fix(opencode): fail runs when the model stream ends without a finish …#40061zhang17-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
|
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. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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