Skip to content

fix(opencode): retry empty unknown responses - #41466

Closed
a3339530357 wants to merge 1 commit into
anomalyco:devfrom
a3339530357:retry-empty-response
Closed

fix(opencode): retry empty unknown responses#41466
a3339530357 wants to merge 1 commit into
anomalyco:devfrom
a3339530357:retry-empty-response

Conversation

@a3339530357

@a3339530357 a3339530357 commented Aug 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #41469

Type of change

  • Bug fix

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; if finish === "unknown" and nothing was generated, throw SessionRetry.EmptyResponseError.
  • packages/opencode/src/session/retry.ts: add EmptyResponseError and retry it like other transient failures (existing backoff policy).
  • Test added covering the empty-response retry path.

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?

  • New test passes: bun test session/processor-effect.test.ts -t "retry empty"
  • Full suite: bun test session/processor-effect.test.ts — 16 pass / 1 fail (the failure is the pre-existing midstream server errors test, failing on dev without this change too)
  • bun typecheck passes

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

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 dev state and should be mergeable.

@a3339530357
a3339530357 force-pushed the retry-empty-response branch from 4682075 to 544dd5a Compare August 10, 2026 02:39
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions

Copy link
Copy Markdown
Contributor

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:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session silently stops on empty LLM response (finish: unknown, 0 tokens)

1 participant