diff --git a/packages/core/src/agents/codebase-investigator.ts b/packages/core/src/agents/codebase-investigator.ts index 5036bd2823..5527edc1cf 100644 --- a/packages/core/src/agents/codebase-investigator.ts +++ b/packages/core/src/agents/codebase-investigator.ts @@ -53,7 +53,7 @@ export const CodebaseInvestigatorAgent = ( ): LocalAgentDefinition => { // Use Preview Flash model if the main model supports modern features. // If the main model is not a modern model, use the default pro model. - const model = supportsModernFeatures(config.getModel()) + const model = supportsModernFeatures(config.getModel(), config) ? PREVIEW_GEMINI_FLASH_MODEL : DEFAULT_GEMINI_MODEL; @@ -97,7 +97,7 @@ export const CodebaseInvestigatorAgent = ( generateContentConfig: { temperature: 0.1, topP: 0.95, - thinkingConfig: supportsModernFeatures(model) + thinkingConfig: supportsModernFeatures(model, config) ? { includeThoughts: true, thinkingLevel: ThinkingLevel.HIGH, diff --git a/packages/core/src/config/models.ts b/packages/core/src/config/models.ts index 2c6b98aae2..1a3cdd5a20 100644 --- a/packages/core/src/config/models.ts +++ b/packages/core/src/config/models.ts @@ -397,11 +397,21 @@ export function isCustomModel( * This includes Gemini 3 models and any custom models. * * @param model The model name to check. + * @param config Optional config object for dynamic model configuration. * @returns True if the model supports modern features like thoughts. */ -export function supportsModernFeatures(model: string): boolean { +export function supportsModernFeatures( + model: string, + config?: ModelCapabilityContext, +): boolean { + if (config?.getExperimentalDynamicModelConfiguration?.() === true) { + const definition = config.modelConfigService.getModelDefinition(model); + if (definition?.features?.thinking !== undefined) { + return definition.features.thinking; + } + } if (isGemini3Model(model)) return true; - return isCustomModel(model); + return isCustomModel(model, config); } /** diff --git a/packages/core/src/core/geminiChat.ts b/packages/core/src/core/geminiChat.ts index f7fece6c33..dbdde8c13b 100644 --- a/packages/core/src/core/geminiChat.ts +++ b/packages/core/src/core/geminiChat.ts @@ -569,7 +569,10 @@ export class GeminiChat { abortSignal, }; - let contentsToUse: Content[] = supportsModernFeatures(modelToUse) + let contentsToUse: Content[] = supportsModernFeatures( + modelToUse, + this.context.config, + ) ? [...contentsForPreviewModel] : [...requestContents]; @@ -613,7 +616,10 @@ export class GeminiChat { ); lastModelToUse = modelToUse; // Re-evaluate contentsToUse based on the new model's feature support - contentsToUse = supportsModernFeatures(modelToUse) + contentsToUse = supportsModernFeatures( + modelToUse, + this.context.config, + ) ? [...contentsForPreviewModel] : [...requestContents]; } diff --git a/packages/core/src/prompts/promptProvider.ts b/packages/core/src/prompts/promptProvider.ts index 36d08c7e74..aa6492920e 100644 --- a/packages/core/src/prompts/promptProvider.ts +++ b/packages/core/src/prompts/promptProvider.ts @@ -69,7 +69,7 @@ export class PromptProvider { context.config.getHasAccessToPreviewModel?.() ?? true, context.config, ); - const isModernModel = supportsModernFeatures(desiredModel); + const isModernModel = supportsModernFeatures(desiredModel, context.config); const activeSnippets = isModernModel ? snippets : legacySnippets; const contextFilenames = getAllGeminiMdFilenames(); @@ -280,7 +280,7 @@ export class PromptProvider { context.config.getHasAccessToPreviewModel?.() ?? true, context.config, ); - const isModernModel = supportsModernFeatures(desiredModel); + const isModernModel = supportsModernFeatures(desiredModel, context.config); const activeSnippets = isModernModel ? snippets : legacySnippets; return activeSnippets.getCompressionPrompt( context.config.getApprovedPlanPath(),