Skip to content

fix(opencode): stop looping after unknown finish with text - #44031

Closed
razectp wants to merge 1 commit into
anomalyco:devfrom
razectp:settle-unknown-output
Closed

razectp wants to merge 1 commit into
anomalyco:devfrom
razectp:settle-unknown-output

Conversation

@razectp

@razectp razectp commented Aug 22, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #43939

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

#43892 keeps the prompt loop running on every unknown finish so an empty dropped stream can recover. Providers also label complete text turns as unknown. Those turns then start another generation, and if the next one is unknown too the loop never ends.

This treats unknown as done when the assistant already produced text and has no pending tool calls. Empty unknown still continues. Reasoning-only unknown still continues so a later text turn can arrive.

How did you verify your code works?

  • bun test ./test/session/prompt.test.ts -t unknown (empty unknown still recovers; text unknown settles; reasoning-only continues)
  • bun test ./test/cli/run/run-process.test.ts -t unknown including the existing continuation tests and a new opencode run case that must not consume a follow-up reply
  • bun typecheck in packages/opencode

Screenshots / recordings

Not a UI change.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a highly related PR:

Related PR:

  • #43881 - fix(session): retry empty unknown-finish streams instead of stopping

This PR is directly related because it also addresses unknown finish behavior in the prompt loop. PR #43881 specifically handles retrying empty unknown-finish streams, while PR #44031 extends this logic to differentiate between empty unknowns (which should continue) and unknowns with text output (which should settle). They're complementary fixes to the same issue (#43939).

Other potentially related PRs addressing prompt loop and stream handling:

  • #43300 - Recovery polling for missed SSE events
  • #40142 - Surface truncated turns instead of ending the loop

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

v1.18.21 repeatedly continues complete responses with finish=unknown

1 participant