Skip to content

fix(core): propagate User-Agent header to setup-phase CodeAssist API calls - #19182

Merged
gsquared94 merged 2 commits into
google-gemini:mainfrom
gsquared94:fix-ua
Feb 16, 2026
Merged

fix(core): propagate User-Agent header to setup-phase CodeAssist API calls#19182
gsquared94 merged 2 commits into
google-gemini:mainfrom
gsquared94:fix-ua

Conversation

@gsquared94

@gsquared94 gsquared94 commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Propagate User-Agent header to setup-phase CodeAssist API calls.

Details

During the setup phase of CodeAssist, certain API calls (loadCodeAssist, onboardUser) were being made without the User-Agent header. This occurred because setupUser was instantiating CodeAssistServer with an empty httpOptions object. This PR updates setupUser to accept httpOptions and pass them when instantiating CodeAssistServer, and ensures createCodeAssistContentGenerator passes its httpOptions to setupUser.

Related Issues

Fixes #19181

How to Validate

Check sherlog traces for missing user-agent header now available. Sample:

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

Pass httpOptions (containing User-Agent) from createCodeAssistContentGenerator
through setupUser to the CodeAssistServer used during the setup phase. Previously,
loadCodeAssist, onboardUser, and getOperation calls had no User-Agent header
because setupUser instantiated CodeAssistServer with empty httpOptions.
@gsquared94
gsquared94 requested a review from a team as a code owner February 16, 2026 02:27
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @gsquared94, 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 addresses an issue where critical CodeAssist API calls during the initial setup phase were missing the User-Agent header. By refactoring the setupUser function and its callers to correctly propagate HTTP options, the system can now properly identify these requests, which is crucial for accurate logging, analytics, and potentially for API compatibility or rate limiting. This change enhances the robustness and observability of the CodeAssist integration.

Highlights

  • User-Agent Header Propagation: Ensured the User-Agent header is correctly propagated to CodeAssist API calls made during the setup phase, specifically for loadCodeAssist, onboardUser, and getOperation.
  • Refactored setupUser function: Modified the setupUser function to accept httpOptions and pass them along when instantiating CodeAssistServer.
  • Updated createCodeAssistContentGenerator: Updated createCodeAssistContentGenerator to correctly pass its httpOptions to the setupUser function.
  • New Test Coverage: Added a new unit test to verify that httpOptions are properly passed from setupUser to the CodeAssistServer.
Changelog
  • packages/core/src/code_assist/codeAssist.test.ts
    • Updated existing test expectations for setupUser calls to include the httpOptions parameter.
  • packages/core/src/code_assist/codeAssist.ts
    • Modified the createCodeAssistContentGenerator function to pass httpOptions to the setupUser function.
  • packages/core/src/code_assist/setup.test.ts
    • Added a new test case to verify that httpOptions are correctly passed from setupUser to the CodeAssistServer constructor.
  • packages/core/src/code_assist/setup.ts
    • Imported the HttpOptions type for better type safety.
    • Updated the setupUser function signature to accept an optional httpOptions parameter with a default empty object.
    • Modified the CodeAssistServer instantiation within setupUser to use the provided httpOptions instead of an empty object.
Activity
  • Tests were added/updated to cover the changes.
  • The changes were validated on MacOS using npm run.
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.

@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 correctly propagates the User-Agent header to setup-phase CodeAssist API calls by passing httpOptions through createCodeAssistContentGenerator and setupUser to the CodeAssistServer. The changes are well-implemented and include updated unit tests and a new test case to validate the fix. The code is clean and effectively addresses the issue. I have no further comments.

@gemini-cli gemini-cli Bot added the area/enterprise Issues related to Telemetry, Policy, Quota / Licensing label Feb 16, 2026
@gsquared94
gsquared94 enabled auto-merge February 16, 2026 03:15
@gsquared94
gsquared94 added this pull request to the merge queue Feb 16, 2026
Merged via the queue into google-gemini:main with commit 8979fc5 Feb 16, 2026
28 of 31 checks passed
@gsquared94
gsquared94 deleted the fix-ua branch February 16, 2026 03:30
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
tripleyoung pushed a commit to tripleyoung/gemini-cli that referenced this pull request Feb 27, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
@sripasg sripasg added the size/s A small PR label Jun 2, 2026
software-0ficial pushed a commit to software-0ficial/gemini-cli that referenced this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/enterprise Issues related to Telemetry, Policy, Quota / Licensing size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User-Agent header missing in setup-phase CodeAssist API calls

4 participants