Skip to content

Conversation

@hsubox76
Copy link
Contributor

Add thinking levels feature.

API proposal (internal): https://docs.google.com/document/d/16cdWurhdLDuNIDj0eJWNnL00any0tL_DjI-lAg7miP8/edit?tab=t.0

Added the param, plus an error if both thinkingLevel and thinkingBudget are set. This validation function may be used in the future to validate other common config issues.

Docs notes:

  • Copied text of documentation from Swift comments in API proposal doc (see above)
  • Some of the "removed" text in the md files is actually just removing them from the toc table at the top of the page, where they are unnecessary, and most of the text still remains in the entries below.

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2025

🦋 Changeset detected

Latest commit: d035951

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@firebase/ai Minor
firebase Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hsubox76, 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 enhances the AI model configuration by introducing a thinkingLevel parameter, offering a simplified way to control the model's internal reasoning process. It ensures proper configuration through client-side validation and provides comprehensive documentation for the new feature.

Highlights

  • New thinkingLevel Parameter: Introduced a new thinkingLevel parameter within ThinkingConfig to allow users to specify a preset level for the model's 'thinking' process, with options like MINIMAL, LOW, MEDIUM, and HIGH.
  • Mutual Exclusivity Validation: Implemented client-side validation to prevent the simultaneous setting of both thinkingBudget and thinkingLevel in the GenerationConfig, throwing an AIErrorCode.UNSUPPORTED error if both are provided.
  • Documentation Updates: Updated API documentation and devsite markdown files to reflect the new ThinkingLevel type, its usage, and the updated ThinkingConfig interface, including notes on its interaction with thinkingBudget and model support.
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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

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 introduces the thinkingLevel parameter to the thinkingConfig, providing users with presets to control the model's thinking process. The changes include updates to the ThinkingConfig interface, new type definitions for ThinkingLevel, and comprehensive documentation updates. A key addition is the client-side validation that prevents thinkingLevel and thinkingBudget from being set simultaneously, which is a great way to prevent invalid configurations. The associated test case for this validation is also well-implemented. Overall, the changes are solid. I have one minor suggestion to improve the readability of the validation logic.

@google-oss-bot
Copy link
Collaborator

google-oss-bot commented Dec 12, 2025

Size Report 1

Affected Products

  • @firebase/ai

    TypeBase (2ecf78b)Merge (dada300)Diff
    browser68.7 kB69.1 kB+406 B (+0.6%)
    main73.0 kB73.5 kB+483 B (+0.7%)
    module68.7 kB69.1 kB+406 B (+0.6%)
  • firebase

    TypeBase (2ecf78b)Merge (dada300)Diff
    firebase-ai.js53.4 kB53.7 kB+312 B (+0.6%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/VS7FtazwtQ.html

@google-oss-bot
Copy link
Collaborator

google-oss-bot commented Dec 12, 2025

Size Analysis Report 1

Affected Products

  • @firebase/ai

    • GenerativeModel

      Size

      TypeBase (2ecf78b)Merge (dada300)Diff
      size26.5 kB26.7 kB+209 B (+0.8%)
      size-with-ext-deps44.3 kB44.6 kB+211 B (+0.5%)

      Dependency

      TypeBase (2ecf78b)Merge (dada300)Diff
      functions

      39 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      callCloudOrDevice
      chromeAdapterFactory
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      factory
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      initApiSettings
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      40 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      callCloudOrDevice
      chromeAdapterFactory
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      factory
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      initApiSettings
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory
      validateGenerationConfig

      + validateGenerationConfig

    • ThinkingLevel

      Size

      TypeBase (2ecf78b)Merge (dada300)Diff
      size?7.01 kB? (?)
      size-with-ext-deps?24.6 kB? (?)

      Dependency

      TypeBase (2ecf78b)Merge (dada300)Diff
      functions?

      chromeAdapterFactory
      decodeInstanceIdentifier
      factory
      registerAI

      ?
      classes?

      AIError
      AIService
      Backend
      ChromeAdapterImpl
      GoogleAIBackend
      VertexAIBackend

      ?
      variables?

      12 dependencies

      AIErrorCode
      AI_TYPE
      Availability
      BackendType
      DEFAULT_API_VERSION
      DEFAULT_LOCATION
      InferenceMode
      ThinkingLevel
      defaultExpectedInputs
      logger
      name
      version

      ?
      enums??

      External Dependency

      ModuleBase (2ecf78b)Merge (dada300)Diff
      @firebase/app?

      _registerComponent
      registerVersion

      ?
      @firebase/component?

      Component

      ?
      @firebase/logger?

      Logger

      ?
      @firebase/util?

      FirebaseError

      ?
    • getGenerativeModel

      Size

      TypeBase (2ecf78b)Merge (dada300)Diff
      size26.9 kB27.1 kB+209 B (+0.8%)
      size-with-ext-deps44.7 kB44.9 kB+211 B (+0.5%)

      Dependency

      TypeBase (2ecf78b)Merge (dada300)Diff
      functions

      40 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      callCloudOrDevice
      chromeAdapterFactory
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      factory
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getGenerativeModel
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      initApiSettings
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory

      41 dependencies

      addHelpers
      aggregateResponses
      assignRoleToPartsAndValidateSendMessageRequest
      callCloudOrDevice
      chromeAdapterFactory
      countTokens
      countTokensOnCloud
      createEnhancedContentResponse
      decodeInstanceIdentifier
      factory
      formatBlockErrorMessage
      formatGenerateContentInput
      formatNewContent
      formatSystemInstruction
      generateContent
      generateContentOnCloud
      generateContentStream
      generateContentStreamOnCloud
      generateResponseSequence
      getClientHeaders
      getFunctionCalls
      getGenerativeModel
      getHeaders
      getInlineDataParts
      getResponsePromise
      getResponseStream
      getText
      hadBadFinishReason
      hasValidCandidates
      initApiSettings
      makeRequest
      mapCountTokensRequest
      mapGenerateContentCandidates
      mapGenerateContentRequest
      mapGenerateContentResponse
      mapPromptFeedback
      processGenerateContentResponse
      processStream
      registerAI
      validateChatHistory
      validateGenerationConfig

      + validateGenerationConfig

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/4fIEPDm8Z0.html

@hsubox76 hsubox76 marked this pull request as ready for review January 5, 2026 18:20
@hsubox76 hsubox76 requested review from a team as code owners January 5, 2026 18:20
@hsubox76 hsubox76 requested a review from DellaBitta January 5, 2026 18:22
If you don't specify a budget, the model will determine the appropriate amount of thinking based on the complexity of the prompt.
The range of supported thinking budget values depends on the model.

<ul> <li>To use the default thinking budget or thinking level for a model, leave this value undefined.</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this is describing thinkingBudget? If so, I'm not sure if we should be talking about thinking levels in this section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed thinking levels from this sentence but kept the line below that says you cannot set both.


<li>To disable thinking, when supported by the model, set this value to `0`<!-- -->.</li>

<li>To use dynamic thinking, allowing the model to decide on the thinking budget based on the task, set this value to `-1`<!-- -->.</li> </ul>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<li>To use dynamic thinking, allowing the model to decide on the thinking budget based on the task, set this value to `-1`<!-- -->.</li> </ul>
<li>To use dynamic thinking, which allows the model to decide on the thinking budget based on the task, set this value to `-1`<!-- -->.</li> </ul>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@hsubox76 hsubox76 merged commit 5579b38 into main Jan 12, 2026
38 checks passed
@hsubox76 hsubox76 deleted the ch-thinking-levels branch January 12, 2026 18:41
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.

4 participants