GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: treat "other" as a continue stop reason by kkugot · Pull Request #20467 · anomalyco/opencode

Conversation

@kkugot

@kkugot kkugot commented Apr 1, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Issue for this PR

Closes #20465

Type of change

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

What does this PR do?

Fixes blank assistant text in TUI when MCP servers are enabled, a regression introduced in v1.3.4 by the AI SDK 5 -> 6 upgrade.

Root cause: The v6 finish-reason adapter changed the default unmapped reason from unknown to other. The prompt loop continue sets in prompt.ts had unknown removed but other was never added as a replacement. This causes the loop to exit after MCP tool calls before the model produces final text. MCP amplifies this because tool-enabled requests hit this code path far more often.

Additional fix: The TUI AssistantMessage component rendered empty space for intermediate assistant messages whose parts were all hidden (completed tools with details off, empty text). Added a reactive visible memo that hides the entire message when no parts would render.

How did you verify your code works?

  • Tested locally with MCP enabled: assistant text renders correctly, symptom gone
  • Tested with MCP disabled: no behavior change
  • bun typecheck — no new errors (only pre-existing ripgrep.ts errors on dev)

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brownmike, dlangerenken, andriy-dmytruk, bwendell, and 0xsarawut reacted with thumbs up emoji
All reactions
  • 👍 5 reactions
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 1, 2026
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

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

Potential Related PRs Found:

  1. PR fix(opencode): run transformParams middleware unconditionally for all call types #19558 - "fix(opencode): run transformParams middleware unconditionally for all call types"

    • fix(opencode): run transformParams middleware unconditionally for all call types #19558
    • Why related: This PR addresses middleware execution issues with request transformation, similar to the LLM middleware fix in the current PR that handles v6 request param shapes (messages, input, prompt).
  2. PR fix(core): prevent agent loop from stopping after tool calls with OpenAI-compatible providers #14973 - "fix(core): prevent agent loop from stopping after tool calls with OpenAI-compatible providers"

    • fix(core): prevent agent loop from stopping after tool calls with OpenAI-compatible providers #14973
    • Why related: This PR addresses the prompt loop exit issue after tool calls, which relates to the finish-reason mapping changes in the current PR.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 1, 2026
@github-actions

github-actions Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 6 times, most recently from df65986 to bf4dbc9 Compare April 2, 2026 07:51
@kkugot kkugot mentioned this pull request Apr 2, 2026
Blank assistant text with AI SDK v6 and MCP on: finish-reason regression when using responses api with @ai-sdk/openai #20465
Closed
@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 5 times, most recently from 5d6eef9 to 49cc60e Compare April 7, 2026 18:50
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 7, 2026
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 2 times, most recently from 8c1272b to 36d92e3 Compare April 10, 2026 10:52
@kkugot kkugot changed the title fix: blank assistant text with MCP enabled after AI SDK v6 migration fix: blank assistant text - finish-reason regression after AI SDK v6 migration Apr 10, 2026
@github-actions github-actions Bot mentioned this pull request Apr 11, 2026
fix(opencode): ensure tool-call/tool-result pairing after normalizeMessages #22001
Closed
3 of 6 tasks
@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 2 times, most recently from a060a89 to 4e4878b Compare April 13, 2026 13:44
@kkugot kkugot mentioned this pull request Apr 13, 2026
fix(core): prevent agent loop from stopping after tool calls with OpenAI-compatible providers #14973
Merged
3 of 6 tasks
@kkugot

kkugot commented Apr 13, 2026

Copy link
Copy Markdown
Author

I am keeping this branch up-to date with dev, would be thankful if this can be merged. engineers using Oracle Code Assist could not use opencode with Open AI models with responses API because of this bug. This is since version 1.3.4

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node

rekram1-node commented Apr 13, 2026

Copy link
Copy Markdown
Member

@kkugot let me look over this

kkugot reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rekram1-node
rekram1-node reviewed Apr 13, 2026
View reviewed changes
Comment thread packages/opencode/src/session/llm.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node

rekram1-node commented Apr 13, 2026

Copy link
Copy Markdown
Member

The LLM middleware in llm.ts targeted args.params.prompt for applying ProviderTransform.message(), but v6 Responses requests use messages or input. This meant message normalization was silently skipped on Responses requests.

Im not sure this is accurate

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 3 times, most recently from cb401dc to c2caf33 Compare April 18, 2026 14:45
kkugot
kkugot commented Apr 18, 2026
View reviewed changes
Comment thread packages/opencode/src/cli/cmd/tui/routes/session/index.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 3 times, most recently from 6ea89bd to d0971aa Compare April 18, 2026 15:12
@kkugot

kkugot commented Apr 18, 2026

Copy link
Copy Markdown
Author

this pr has so many unrelated changes, i thought it'd be a 2 line pr?

Ready for your review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node

rekram1-node commented Apr 19, 2026

Copy link
Copy Markdown
Member

Alr thanks, ill double check this logic tmr I just need to make sure failure cases dont infinitely loop from this (its almost 1am here rn so too late for me to merge if im not 100% confident)

kkugot reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot

kkugot commented Apr 21, 2026

Copy link
Copy Markdown
Author

@rekram1-node no pressure here, if I can help with tesing this - let me know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch 2 times, most recently from 03c4e62 to 8dc2a25 Compare April 25, 2026 09:15
@kkugot kkugot changed the title fix: blank assistant text - finish-reason regression after AI SDK v6 migration fix: blank assistant text - finish-reason regression after AI SDK v6 migration when any MCP is on Apr 25, 2026
@kkugot

kkugot commented Apr 25, 2026

Copy link
Copy Markdown
Author

@rekram1-node I have checked with the recent code changes on dev and we are able to reproduce this issue only when any of the MCPs are enabled. With the proposed fix everything works correctly.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pedantilva

pedantilva commented Apr 28, 2026

Copy link
Copy Markdown

Hi @rekram1-node any idea when this will be merged? This is driving people out of OpenCode tool due to this issue.

dlangerenken, kkugot, tsaeger, and viswana reacted with thumbs up emoji
All reactions
  • 👍 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch from 8dc2a25 to f54a21b Compare May 3, 2026 21:11
@rekram1-node rekram1-node changed the title fix: blank assistant text - finish-reason regression after AI SDK v6 migration when any MCP is on fix: treat "other" as a continue stop reason May 4, 2026
@rekram1-node

rekram1-node commented May 4, 2026

Copy link
Copy Markdown
Member

/review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

github-actions[bot]
github-actions Bot reviewed May 4, 2026
View reviewed changes
Comment thread packages/opencode/src/session/prompt.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch from f54a21b to 1d793dc Compare May 5, 2026 23:17
kostiantyn-kugot added 2 commits May 7, 2026 13:52
kostiantyn-kugot
fix: blank assistant text with MCP enabled after AI SDK v6 migration
ae7bf9c
The v6 upgrade changed the default unmapped finish reason from "unknown"
to "other", but the prompt loop continue sets were not updated to match.
This caused premature loop exit after MCP tool calls, before the model
produced final assistant text.

Fixes #20050
Fixes #20465
kostiantyn-kugot
fix: stop on other finish without tool calls
32d5a37
@kkugot
kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch from 43b7797 to 32d5a37 Compare May 7, 2026 11:54
@rekram1-node

rekram1-node commented May 8, 2026

Copy link
Copy Markdown
Member

This was tested and works? Im just noticing that the only test seems to assert other as a stop reason to stop rather than continue which i would have assumed was not ur intent?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot

kkugot commented May 16, 2026

Copy link
Copy Markdown
Author

Our provider emits OpenAI Responses-style structural completion events, but not enough SDK-friendly finish classification for opencode’s current parser. OpenAI Responses itself does not require finish_reason; the client must derive a finish classification from the event stream. The change in this PR works because it treats the unmapped completed function-call step as "other" instead of leaving it undefined.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot

kkugot commented May 16, 2026

Copy link
Copy Markdown
Author

To the OCA users of opencode:
I found an OCA upstream Responses streaming issue while debugging OpenCode visibility failures. For some /v1/responses stream=true post-tool requests, upstream returns HTTP 200 but then closes the SSE stream with no useful output, sometimes only lifecycle events or even bytes:0. This happens intermittently across endpoints, so it does not look like a single bad endpoint or issue with opencode. The workaround in this PR was forcing opencode to do a retry. I added OCA proxy-side protection to hide those broken attempts from the client and retry before committing downstream SSE, which resolved the OpenCode rendering issue in my local testing. We need to bring this issue to OCA team now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kkugot kkugot closed this May 16, 2026
@kkugot
kkugot deleted the fix/mcp-finish-reason-20050-20465 branch May 16, 2026 23:43
@github-actions github-actions Bot mentioned this pull request May 17, 2026
📊 AI CLI 工具社区动态日报 2026-05-17 zx0828/big_model_radar#60
Open
0xsarawut
0xsarawut reviewed May 31, 2026
View reviewed changes

@0xsarawut 0xsarawut left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chackour bank user

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@github-actions github-actions[bot] github-actions[bot] left review comments
@rekram1-node rekram1-node rekram1-node left review comments
+1 more reviewer
@0xsarawut 0xsarawut 0xsarawut left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Blank assistant text with AI SDK v6 and MCP on: finish-reason regression when using responses api with @ai-sdk/openai

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@kkugot @rekram1-node @pedantilva @0xsarawut
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.