Skip to content

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

Open
3351163616 wants to merge 1 commit into
anomalyco:devfrom
3351163616:retry-empty-response
Open

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

Conversation

@3351163616

@3351163616 3351163616 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.

@3351163616
3351163616 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. 👍

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

Labels

None yet

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