Skip to content

Gemini: raise a NON-retryable error on a deterministically answer-less generation. - #760

Closed
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_969538244
Closed

Gemini: raise a NON-retryable error on a deterministically answer-less generation.#760
copybara-service[bot] wants to merge 1 commit into
mainfrom
test_969538244

Conversation

@copybara-service

Copy link
Copy Markdown

Gemini: raise a NON-retryable error on a deterministically answer-less generation.

When a Gemini candidate returns no answer content because thinking consumed the decode budget (finishReason=MAX_TOKENS) or because the model stopped having emitted nothing (finishReason=STOP with candidatesTokenCount=0), the result is a function of the request, not of server health: re-sending the identical prompt reproduces it. Today that empty text reaches LanguageModel.sample(), which raises the retryable lf.EmptyGenerationError and re-sends the full prompt up to max_attempts times before failing with an opaque error.

Gemini.result() now detects exactly those two signatures and raises the new GeminiEmptyGenerationError, an lf.LMError (deliberately not an lf.EmptyGenerationError / lf.RetryableLMError), so it escapes the retry wrappers on the first attempt carrying the model, finish reason, token counts, and the knobs to change. All other answer-less cases keep their existing behavior.

…s generation.

When a Gemini candidate returns no answer content because thinking consumed the decode budget (finishReason=MAX_TOKENS) or because the model stopped having emitted nothing (finishReason=STOP with candidatesTokenCount=0), the result is a function of the request, not of server health: re-sending the identical prompt reproduces it. Today that empty text reaches LanguageModel.sample(), which raises the retryable lf.EmptyGenerationError and re-sends the full prompt up to max_attempts times before failing with an opaque error.

Gemini.result() now detects exactly those two signatures and raises the new GeminiEmptyGenerationError, an lf.LMError (deliberately not an lf.EmptyGenerationError / lf.RetryableLMError), so it escapes the retry wrappers on the first attempt carrying the model, finish reason, token counts, and the knobs to change. All other answer-less cases keep their existing behavior.

PiperOrigin-RevId: 969538244
@copybara-service copybara-service Bot closed this Aug 24, 2026
@copybara-service
copybara-service Bot deleted the test_969538244 branch August 24, 2026 02:32
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.

1 participant