Skip to content

fix: blank assistant text with MCP enabled after AI SDK v6 migration#20467

Open
kkugot wants to merge 1 commit intoanomalyco:devfrom
kkugot:fix/mcp-finish-reason-20050-20465
Open

fix: blank assistant text with MCP enabled after AI SDK v6 migration#20467
kkugot wants to merge 1 commit intoanomalyco:devfrom
kkugot:fix/mcp-finish-reason-20050-20465

Conversation

@kkugot
Copy link
Copy Markdown

@kkugot kkugot commented Apr 1, 2026

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.

Two interacting problems:

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

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

The fix adds other to both loop continue sets and transforms all three v6 param shapes in the middleware.

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 test test/session/llm.test.ts — 14 pass
  • bun typecheck — no new errors

Screenshots / recordings

N/A — not a UI change, the fix restores existing expected behavior.

Checklist

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

@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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

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"

  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"

@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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

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

@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 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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

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

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.

Additionally, the LLM middleware still targeted legacy 'prompt' param key
while v6 Responses requests use 'messages' or 'input', causing
ProviderTransform.message() to be silently skipped.

Fixes anomalyco#20050
Fixes anomalyco#20465
@kkugot kkugot force-pushed the fix/mcp-finish-reason-20050-20465 branch from 49cc60e to 8c1272b Compare April 8, 2026 09:51
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.

Blank assistant text with MCP enabled after v1.3.4 (AI SDK v6 finish-reason regression)

1 participant