Skip to content

Conversation

paulb777
Copy link
Member

@paulb777 paulb777 commented Sep 24, 2025

Follow on to #15262 now that urlContext tool support has been added

Summary of Changes

This pull request refines the isEmpty logic within the Candidate struct of the Firebase AI SDK. It specifically updates the isEmpty computed property to account for urlContextMetadata, preventing Candidate objects from being incorrectly identified as empty when they contain relevant URL context information. This change ensures more accurate content generation responses and is accompanied by new unit tests to validate the updated behavior.

Highlights

  • Candidate.isEmpty logic update: The isEmpty computed property in the Candidate struct has been updated to include urlContextMetadata in its evaluation, ensuring that candidates with this metadata are no longer considered empty.
  • Test coverage for Candidate.isEmpty: New unit tests have been added to verify the correctness of the Candidate.isEmpty property, specifically covering scenarios where urlContextMetadata is present or absent.
  • @testable import for testing: The test file GenerateContentResponseTests.swift now uses @testable import FirebaseAI to allow access to internal types for comprehensive testing.
Changelog
  • FirebaseAI/Sources/GenerateContentResponse.swift
    • Modified the isEmpty computed property in the Candidate struct to include urlContextMetadata in its check.
  • FirebaseAI/Tests/Unit/Types/GenerateContentResponseTests.swift
    • Added @testable import FirebaseAI to enable testing of internal types.
    • Introduced new test cases (testCandidateIsEmpty_allEmpty_isTrue and testCandidateIsEmpty_withURLContextMetadata_isFalse) to thoroughly validate the updated Candidate.isEmpty logic.
Activity
  • gemini-code-assist[bot] provided information regarding its usage.
  • google-oss-bot issued a warning about a missing changelog entry.
  • paulb777 requested a review from Gemini Code Assist.
  • gemini-code-assist[bot] provided a review comment suggesting the use of try XCTUnwrap for robust URL handling in tests.
  • paulb777 requested a summary from Gemini Code Assist.

Copy link
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.

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

@paulb777
Copy link
Member Author

/gemini review

Copy link
Contributor

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

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 correctly updates the Candidate.isEmpty check to also consider urlContextMetadata. The logic is sound, and the change is accompanied by new unit tests that validate the updated behavior. The code quality is good. I have one minor suggestion to improve the robustness of the new test case.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@paulb777
Copy link
Member Author

/gemini summary

@firebase firebase deleted a comment from gemini-code-assist bot Sep 24, 2025
@paulb777 paulb777 merged commit 63083d8 into main Sep 25, 2025
50 of 51 checks passed
@paulb777 paulb777 deleted the pb-empty-with-urlcontentmetadata branch September 25, 2025 15:03
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