fix(opencode): retry empty unknown responses - #41466
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, here are the related PRs: Related/Previous Work:
Note: PR #41466 (the current PR) appears in the results because the search returns it, but this is expected since it's the current PR being checked. The key relationship is with #40531, which is the original implementation that this PR rebases. As noted in the PR description, #41466 applies the same fix to the current |
4682075 to
544dd5a
Compare
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
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 #41469
Type of change
What does this PR do?
When a provider returns an empty completion (0 tokens, no text/reasoning/tool output, finish reason maps to
unknown), opencode records it as a normal completed turn and the session loop exits silently — no error surfaced, no retry. The conversation appears to stop mid-task.This PR makes the processor treat such turns as transient failures:
packages/opencode/src/session/processor.ts: track whether the stream generated any text/reasoning/tool output; iffinish === "unknown"and nothing was generated, throwSessionRetry.EmptyResponseError.packages/opencode/src/session/retry.ts: addEmptyResponseErrorand retry it like other transient failures (existing backoff policy).This is a rebased port of #40531 (same fix, currently conflicting with
dev) so it is mergeable as-is.How did you verify your code works?
bun test session/processor-effect.test.ts -t "retry empty"bun test session/processor-effect.test.ts— 16 pass / 1 fail (the failure is the pre-existingmidstream server errorstest, failing ondevwithout this change too)bun typecheckpassesChecklist