feat: implement late-binding tool updates in GeminiChat

This commit is contained in:
Aishanee Shah
2026-02-06 20:28:45 +00:00
parent 2a44cad487
commit 6227ba73a7
2 changed files with 12 additions and 0 deletions

View File

@@ -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 }];

View File

@@ -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;