Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[AI] Finish Reasons#15931

Merged
daymxn merged 38 commits into
mainfirebase/firebase-ios-sdk:mainfrom
pb-finish-reasonfirebase/firebase-ios-sdk:pb-finish-reasonCopy head branch name to clipboard
Apr 28, 2026
Merged

[AI] Finish Reasons#15931
daymxn merged 38 commits into
mainfirebase/firebase-ios-sdk:mainfrom
pb-finish-reasonfirebase/firebase-ios-sdk:pb-finish-reasonCopy head branch name to clipboard

Conversation

@paulb777

@paulb777 paulb777 commented Mar 11, 2026

Copy link
Copy Markdown
Member

PR Review: [AI] Finish Reasons #15931

This pull request, [AI] Finish Reasons #15931, introduces support for expanded FinishReason values and a new finishMessage property within the FirebaseAI SDK. These changes aim to provide more granular feedback when the model stops generating content, particularly for image generation and tool-use scenarios.

Key Changes


1. Enhanced Model Response Metadata

  • New Property: Added finishMessage to the Candidate struct. This is a human-readable string explaining why the model stopped generating.

  • Expanded Enums: The FinishReason enum now includes several new cases:

    • Image-Related: imageSafety, imageProhibitedContent, imageOther, noImage, and imageRecitation.
    • Tool & Logic: unexpectedToolCall, tooManyToolCalls, missingThoughtSignature, and malformedResponse.
    • General: language (for unsupported languages).

2. Testing and Validation

  • Integration Tests: Added a new test generateContent_finishReason_imageSafety to verify that prompts triggering safety violations (e.g., "A graphic image of violence") correctly return the expected imageSafety or noImage reasons.

  • Unit Tests: * Added decoding tests to ensure all new FinishReason strings from the API are mapped correctly.

    • Updated isEmpty logic to ensure a candidate is not considered empty if it contains a finishMessage.

3. Documentation

  • Updated the CHANGELOG.md to reflect these new features, noting the added support for image generation safety reasons and tool-use feedback.

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@paulb777

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds several new FinishReason cases, primarily related to image generation and tool usage, and includes corresponding integration tests. The changes are generally good, but I've identified a minor grammatical error in a documentation comment and a more significant issue in one of the new integration tests. The test for Imagen safety filtering is incorrectly structured and will fail as it doesn't account for an expected error being thrown. I've provided a corrected implementation for the test.

Comment thread FirebaseAI/Tests/TestApp/Tests/Integration/ImagenIntegrationTests.swift Outdated
Comment thread FirebaseAI/Sources/GenerateContentResponse.swift Outdated
@paulb777

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds several new FinishReason cases to the SDK, along with corresponding unit and integration tests. The changes to the FinishReason enum and the new integration test for Gemini models are well-implemented. However, I've identified a logical issue in the new Imagen integration test and an opportunity to improve maintainability in the new unit test for decoding finish reasons. My detailed feedback is in the comments below.

Comment thread FirebaseAI/Tests/TestApp/Tests/Integration/ImagenIntegrationTests.swift Outdated
Comment thread FirebaseAI/Tests/Unit/APITests.swift
@paulb777

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds several new FinishReason cases to handle more scenarios, particularly around image generation and tool calls. The changes include updating the FinishReason enum and its corresponding static properties. New unit tests are added to verify the decoding of these new reasons, and a new integration test is introduced to check the imageSafety finish reason. The changes are well-implemented and tested. I have one minor suggestion to improve the new unit test's maintainability.

Comment thread FirebaseAI/Tests/Unit/APITests.swift
Comment thread FirebaseAI/Sources/GenerateContentResponse.swift
@paulb777
paulb777 marked this pull request as ready for review April 24, 2026 16:52
@paulb777

Copy link
Copy Markdown
Member Author

Integration test failures look like flakes

@paulb777
paulb777 requested a review from daymxn April 24, 2026 18:47
@daymxn
daymxn requested a review from andrewheard April 27, 2026 20:10

@daymxn daymxn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, cc'd andrew incase he wants to double check

note: Integ test failures do seem to be flakes, as paul mentioned above

@andrewheard andrewheard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I did a super quick pass and LGTM. Just noticed the one changelog entry issue.

Comment thread FirebaseAI/CHANGELOG.md
Base automatically changed from pb-image-config to main April 28, 2026 19:04
@daymxn
daymxn requested a review from a team as a code owner April 28, 2026 19:04
@daymxn
daymxn enabled auto-merge (squash) April 28, 2026 19:08
@daymxn
daymxn disabled auto-merge April 28, 2026 19:08
@daymxn
daymxn enabled auto-merge (squash) April 28, 2026 19:08
@daymxn
daymxn merged commit d2ef47c into main Apr 28, 2026
29 checks passed
@daymxn
daymxn deleted the pb-finish-reason branch April 28, 2026 19:09
leojaygoogle pushed a commit that referenced this pull request Jun 29, 2026
Co-authored-by: Andrew Heard <andrewheard@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Daymon <17409137+daymxn@users.noreply.github.com>
Co-authored-by: Daymon <daymxn@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.