Skip to content

Conversation

a-maurice
Copy link
Collaborator

Description

Provide details of the change, and generalize the change in the PR title above.

Add support for the URL Context tool, which lets the model fetch data from given URLs.


Testing

Describe how you've tested these changes.

Running tests locally.


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Copy link
Contributor

Summary of Changes

Hello @a-maurice, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Firebase AI SDK by introducing support for the URL Context tool. This new feature allows generative AI models to browse and incorporate information from specified public web URLs directly into their responses, providing richer and more contextually relevant outputs. The changes involve extending core data models like "Candidate" and "UsageMetadata" to accommodate URL-specific information and token tracking, alongside the creation of new types to manage URL retrieval details. Comprehensive automated tests have been added to ensure the reliability of this new capability.

Highlights

  • URL Context Tool Support: Introduced the "UrlContext" tool, enabling AI models to fetch and utilize data from public web URLs to enhance their responses.
  • New Data Structures: Added "UrlContextMetadata" and "UrlMetadata" classes to represent information about retrieved URLs and their retrieval status (e.g., success, error, paywall, unsafe).
  • API Integration: Integrated "UrlContextMetadata" into the "Candidate" class and extended the "Tool" class to support "UrlContext" as a new tool type for generative models.
  • Enhanced Usage Metadata: Updated "UsageMetadata" to include "ToolUsePromptTokenCount" and "ToolUsePromptTokensDetails" for better tracking of token usage specifically by tools.
  • Automated Testing: Implemented new automated tests ("TestUrlContext", "InternalTestUrlContextMixedValidity") and corresponding test data to validate the URL Context functionality and metadata parsing.
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 adds support for the URL Context tool in Firebase AI, allowing the model to fetch data from provided URLs. The changes include adding new data structures for URL context metadata, integrating it into the Tool and Candidate types, and updating UsageMetadata to account for tool usage tokens. New tests have been added to cover this functionality. The implementation is solid, but I have a few suggestions to improve type safety and code clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary for this PR, and also not sure this will be a breaking change. This file/class starting to more of Tool instead of FunctionCalling, so we might want to looking into rename/refactor sometime.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, because it is a source library now, changing that is a bit complicated...

@a-maurice a-maurice merged commit ecdf1f0 into main Oct 1, 2025
5 checks passed
@a-maurice a-maurice deleted the am-url_context branch October 1, 2025 18:16
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.

3 participants