Skip to content

fix(tui): suppress AI SDK warnings before provider imports#20583

Open
aaron-he-zhu wants to merge 2 commits intoanomalyco:devfrom
aaron-he-zhu:fix/tui-console-warn-bleed
Open

fix(tui): suppress AI SDK warnings before provider imports#20583
aaron-he-zhu wants to merge 2 commits intoanomalyco:devfrom
aaron-he-zhu:fix/tui-console-warn-bleed

Conversation

@aaron-he-zhu
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #20047

Type of change

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

What does this PR do?

AI SDK warnings from providers like OpenRouter appeared as raw text in the TUI because AI_SDK_LOG_WARNINGS was only set in server.ts and prompt.ts, which load after provider initialization. Moved the flag to the top of the CLI entry point so it takes effect before any provider module is imported.

The same pattern already exists in server.ts line 21.

How did you verify your code works?

Tested with OpenRouter provider configured. Warnings no longer appear as raw text in the TUI.

Checklist

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

AI SDK warnings from providers like OpenRouter were appearing as raw
text in the TUI because AI_SDK_LOG_WARNINGS was only set in server.ts
and prompt.ts, which load after provider initialization. Move the flag
to the top of the CLI entry point so it takes effect before any
provider module is imported.

Closes anomalyco#20047
@rekram1-node
Copy link
Copy Markdown
Collaborator

Openrouter sdk doesnt respect AI_SDK_LOG_WARNINGS

OpenRouter SDK calls console.warn directly and does not respect the
AI_SDK_LOG_WARNINGS flag, so the previous approach of setting that
global was insufficient.

Instead, redirect console.warn and console.error to the Log service
when the TUI starts. This catches warnings from all third-party SDKs,
not just Vercel AI SDK. The originals are restored on exit.

Closes anomalyco#20047
@aaron-he-zhu
Copy link
Copy Markdown
Contributor Author

Good point — updated the approach. Instead of relying on AI_SDK_LOG_WARNINGS (which OpenRouter ignores), the fix now redirects console.warn and console.error to the Log service when the TUI starts, and restores the originals on exit. This catches warnings from any third-party SDK, not just Vercel AI SDK.

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.

[openrouter] console.warn bleeds through TUI as raw text

2 participants