Pull contentGenerator out of GeminiClient and into Config.#7825
Pull contentGenerator out of GeminiClient and into Config.#7825
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and well-executed refactoring by moving the ContentGenerator from GeminiClient to the Config class. This change improves the architecture by decoupling the GeminiClient's lifecycle from authentication, allowing auth to be refreshed without losing chat history. The implementation is consistent across the codebase, with related classes and tests updated to reflect the new structure. The refactoring of the test suites, particularly moving to mock internal abstractions rather than the external SDK, is a notable improvement in test quality and robustness. The changes align with the pull request's goals and I have no major concerns.
15d6305 to
35baa93
Compare
35baa93 to
4c8e43e
Compare
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
|
The Check Bundle Size error is a preexisting bug that will be fixed by #7833 |
bfe90fd to
03f2ae4
Compare
abhipatel12
left a comment
There was a problem hiding this comment.
LGTM! Just a couple of questions. Thanks again for doing this! Makes my refactor so much easier ❤️
0562e96 to
6f3bb2c
Compare
| getContentGenerator(): ContentGenerator { | ||
| if (!this.contentGenerator) { | ||
| private getContentGeneratorOrFail(): ContentGenerator { | ||
| if (!this.config.getContentGenerator()) { |
There was a problem hiding this comment.
optional nit: add a local variable to avoid calling config.getContentGenerator() twice.
6f3bb2c to
2f15683
Compare
|
Size Change: -376 B (0%) Total Size: 12.5 MB ℹ️ View Unchanged
|
e441e88 to
0135134
Compare

TLDR
Move ContentGenerator from
config.geminiClient.contenGeneratortoconfig.contentGenerator.Dive Deeper
Necessary for #4544 which requires that we refreshAuth before loading the mcp servers.
Config.refreshAuth()and intoConfig.initialize(). You still need to call both before getting started but now you can call them in either order.GeminiClientis now created exactly once in theConfigconstructor and is never reset (instead of a new GeminiClient being built every time we callrefreshAuth()).stripThoughtsFromHistorycode intoGeminiChat(where the history lives).Reviewer Test Plan
Testing Matrix
Linked issues / bugs
Contributes to #4544