fix: validate Gemini thinkingLevel against model capabilities and handle empty streams#11303
Merged
hannesrudolph merged 3 commits intomainfrom Feb 8, 2026
Merged
Conversation
…dle empty streams getGeminiReasoning() now validates the selected effort against the model's supportsReasoningEffort array before sending it as thinkingLevel. When a stale settings value (e.g. 'medium' from a different model) is not in the supported set, it falls back to the model's default reasoningEffort. GeminiHandler.createMessage() now tracks whether any text content was yielded during streaming and handles NoOutputGeneratedError gracefully instead of surfacing the cryptic 'No output generated' error.
Contributor
All previously flagged issues have been addressed. No new issues found.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
daniel-lxs
approved these changes
Feb 8, 2026
…TODO The array validation fallback in getGeminiReasoning() now only triggers when the selected effort IS a valid Gemini thinking level but not in the model's supported set. Values like 'none' (explicit no-reasoning signal) are no longer overridden by the model default. Also adds a TODO for moving the empty-stream message to i18n.
…warning Tool-only responses (no text) are valid content. Without this, agentic tool-call responses would incorrectly trigger the empty response warning message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the "Provider ended the request: Gemini generate context stream error: No output generated" error when using
gemini-3-pro-preview(and similar effort-based Gemini models).Two bugs were identified and fixed:
getGeminiReasoning()sent unsupported thinkingLevel values to the API — It readsettings.reasoningEffortdirectly without validating against the model'ssupportsReasoningEffortarray. A stale setting like"medium"from a different model would be forwarded togemini-3-pro-previewwhich only supports["low", "high"], causing the API to return an empty stream.GeminiHandler.createMessage()had no guard against empty streams — When the AI SDK threwNoOutputGeneratedError(fromawait result.usage), it was caught by the generic error handler and surfaced as the cryptic "No output generated" error with no actionable guidance.Changes
src/api/transform/reasoning.ts:getGeminiReasoning()now validatesselectedEffortagainst the model'ssupportsReasoningEffortarray; falls back tomodel.reasoningEffortwhen the user's stored effort isn't in the supported setsrc/api/providers/gemini.ts:GeminiHandler.createMessage()tracks whether text content was yielded (hasContentflag); yields an informative message on empty streams; wrapsawait result.usagein try-catch to handleNoOutputGeneratedErrorgracefullysrc/api/transform/__tests__/reasoning.spec.ts: 5 new test cases covering array validation, fallback behavior, and edge casessrc/api/providers/__tests__/gemini.spec.ts: 3 new test cases covering empty stream handling,NoOutputGeneratedErrorsuppression, and re-throw when content existsImportant
Fixes unsupported thinking levels and empty stream errors in Gemini models by validating efforts and improving error handling.
getGeminiReasoning()inreasoning.tsnow validatesselectedEffortagainstsupportsReasoningEffortand defaults tomodel.reasoningEffortif unsupported.GeminiHandler.createMessage()ingemini.tstracks content withhasContentflag and handlesNoOutputGeneratedErrorby yielding an informative message.reasoning.spec.tsfor effort validation and fallback behavior.gemini.spec.tsfor empty stream handling and error suppression.This description was created by
for 63425e0. You can customize this summary. It will automatically update as commits are pushed.