refactor(core): model-dependent tool definitions (#18563)

This commit is contained in:
Aishanee Shah
2026-02-09 15:46:23 -05:00
committed by GitHub
parent 07056c8f16
commit 3fb1937247
16 changed files with 550 additions and 102 deletions
+13 -2
View File
@@ -312,8 +312,15 @@ export interface ToolBuilder<
/**
* Function declaration schema from @google/genai.
* @param modelId Optional model identifier to get a model-specific schema.
*/
schema: FunctionDeclaration;
getSchema(modelId?: string): FunctionDeclaration;
/**
* Function declaration schema for the default model.
* @deprecated Use getSchema(modelId) for model-specific schemas.
*/
readonly schema: FunctionDeclaration;
/**
* Whether the tool's output should be rendered as markdown.
@@ -355,7 +362,7 @@ export abstract class DeclarativeTool<
readonly extensionId?: string,
) {}
get schema(): FunctionDeclaration {
getSchema(_modelId?: string): FunctionDeclaration {
return {
name: this.name,
description: this.description,
@@ -363,6 +370,10 @@ export abstract class DeclarativeTool<
};
}
get schema(): FunctionDeclaration {
return this.getSchema();
}
/**
* Validates the raw tool parameters.
* Subclasses should override this to add custom validation logic