feat(core): add google credentials provider for remote agents#21024
feat(core): add google credentials provider for remote agents#21024adamfweidman merged 7 commits intomainfrom
Conversation
|
Hi there! Thank you for your contribution to Gemini CLI. To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md. This pull request is being closed because it is not currently linked to an issue. Once you have updated the description of this PR to link an issue (e.g., by adding How to link an issue: Thank you for your understanding and for being a part of our community! |
|
Hi @adamfweidman, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this. We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines. Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed. Thank you for your understanding and for being a part of our community! |
|
Size Change: +4.76 kB (+0.02%) Total Size: 26.6 MB
ℹ️ View Unchanged
|
…tials # Conflicts: # packages/core/src/agents/agentLoader.ts # packages/core/src/agents/auth-provider/factory.ts # packages/core/src/agents/registry.ts # packages/core/src/agents/remote-invocation.test.ts # packages/core/src/agents/remote-invocation.ts
… provider - Cache access tokens alongside ID tokens for consistent retry behavior - Add targetUrl to registry test assertion after merge - Add tests for cache hits, 403 retry, and retry exhaustion
Summary of ChangesHello, 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 authentication capabilities for remote agents by introducing a dedicated Google Credentials provider. This change allows agents to leverage Google Application Default Credentials for seamless authentication, automatically handling the complexities of obtaining both access and identity tokens based on the target service. The integration into the existing authentication factory and schema ensures a consistent and extensible approach to securing remote agent interactions. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a GoogleCredentialsAuthProvider to handle authentication for remote agents using Google's Application Default Credentials (ADC). This new provider replaces the existing ADCHandler and adds support for automatically selecting between access tokens and identity tokens based on the target service's hostname. The implementation includes token caching with expiry and a retry mechanism for authentication failures. The necessary changes to the agent definition schemas, auth provider factory, and agent loading logic have been made to integrate this new provider. The changes are accompanied by a comprehensive set of unit tests for the new provider. I have reviewed the changes and found no issues of high or critical severity.
There was a problem hiding this comment.
Code Review
The pull request successfully introduces the GoogleCredentialsAuthProvider to handle authentication for remote agents using Google Application Default Credentials (ADC). The implementation correctly distinguishes between access tokens and identity tokens based on the target URL, incorporates caching with proper invalidation, and includes retry logic for authentication failures. The refactoring to replace the ad-hoc ADCHandler with the new provider via the authentication factory pattern is a positive change, centralizing authentication logic. The new test file google-credentials-provider.test.ts provides good coverage for the added functionality. Overall, the changes enhance the authentication capabilities for remote agents in a robust and maintainable way.
Summary
Adds a
GoogleCredentialsAuthProviderfor remote agent authentication using Google Application Default Credentials (ADC). Supports both access tokens (for*.googleapis.com) and identity tokens (for*.run.app).Details
GoogleCredentialsAuthProviderusinggoogle-auth-libraryto automatically discover and use ADC.google-credentialsauth type to the frontmatter Zod schema and discriminated union.ADCHandlerinremote-invocation.tswith the new provider via the auth factory pattern.targetUrltoCreateAuthProviderOptionsfor hostname-based token type decisions.Related Issues
Fixes #17664
How to Validate
Run unit tests for the core package:
npm test -w @google/gemini-cli-core -- src/agents/auth-provider/google-credentials-provider.test.tsPre-Merge Checklist