mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 15:40:57 -07:00
feat: implement late-binding tool updates in GeminiChat
This commit is contained in:
@@ -256,7 +256,14 @@ export class GeminiClient {
|
||||
this.forceFullIdeContext = true;
|
||||
}
|
||||
|
||||
private lastUsedModelId?: string;
|
||||
|
||||
async setTools(modelId?: string): Promise<void> {
|
||||
if (modelId && modelId === this.lastUsedModelId) {
|
||||
return;
|
||||
}
|
||||
this.lastUsedModelId = modelId;
|
||||
|
||||
const toolRegistry = this.config.getToolRegistry();
|
||||
const toolDeclarations = toolRegistry.getFunctionDeclarations(modelId);
|
||||
const tools: Tool[] = [{ functionDeclarations: toolDeclarations }];
|
||||
|
||||
@@ -240,6 +240,7 @@ export class GeminiChat {
|
||||
private sendPromise: Promise<void> = Promise.resolve();
|
||||
private readonly chatRecordingService: ChatRecordingService;
|
||||
private lastPromptTokenCount: number;
|
||||
private lastUsedModel?: string;
|
||||
|
||||
constructor(
|
||||
private readonly config: Config,
|
||||
@@ -581,6 +582,10 @@ export class GeminiChat {
|
||||
}
|
||||
|
||||
// Track final request parameters for AfterModel hooks
|
||||
if (modelToUse !== this.lastUsedModel) {
|
||||
await this.config.getGeminiClient().setTools(modelToUse);
|
||||
this.lastUsedModel = modelToUse;
|
||||
}
|
||||
lastModelToUse = modelToUse;
|
||||
lastConfig = config;
|
||||
lastContentsToUse = contentsToUse;
|
||||
|
||||
Reference in New Issue
Block a user