feat: ensure codebase investigator uses preview model when main agent does (#14412)

This commit is contained in:
Abhi
2025-12-09 16:07:50 -05:00
committed by GitHub
parent 2800187355
commit aced401071
9 changed files with 55 additions and 14 deletions

View File

@@ -12,7 +12,7 @@ import {
LS_TOOL_NAME,
READ_FILE_TOOL_NAME,
} from '../tools/tool-names.js';
import { DEFAULT_GEMINI_MODEL } from '../config/models.js';
import { GEMINI_MODEL_ALIAS_PRO } from '../config/models.js';
describe('CodebaseInvestigatorAgent', () => {
it('should have the correct agent definition', () => {
@@ -26,7 +26,7 @@ describe('CodebaseInvestigatorAgent', () => {
).toBe(true);
expect(CodebaseInvestigatorAgent.outputConfig?.outputName).toBe('report');
expect(CodebaseInvestigatorAgent.modelConfig?.model).toBe(
DEFAULT_GEMINI_MODEL,
GEMINI_MODEL_ALIAS_PRO,
);
expect(CodebaseInvestigatorAgent.toolConfig?.tools).toEqual([
LS_TOOL_NAME,

View File

@@ -11,7 +11,7 @@ import {
LS_TOOL_NAME,
READ_FILE_TOOL_NAME,
} from '../tools/tool-names.js';
import { DEFAULT_GEMINI_MODEL } from '../config/models.js';
import { GEMINI_MODEL_ALIAS_PRO } from '../config/models.js';
import { z } from 'zod';
// Define a type that matches the outputConfig schema for type safety.
@@ -69,7 +69,7 @@ export const CodebaseInvestigatorAgent: AgentDefinition<
processOutput: (output) => JSON.stringify(output, null, 2),
modelConfig: {
model: DEFAULT_GEMINI_MODEL,
model: GEMINI_MODEL_ALIAS_PRO,
temp: 0.1,
top_p: 0.95,
thinkingBudget: -1,

View File

@@ -72,6 +72,25 @@ describe('AgentRegistry', () => {
`[AgentRegistry] Initialized with ${agentCount} agents.`,
);
});
it('should use preview model for codebase investigator if main model is preview', async () => {
const previewConfig = makeFakeConfig({
model: 'gemini-3-pro-preview',
codebaseInvestigatorSettings: {
enabled: true,
model: 'pro',
},
});
const previewRegistry = new TestableAgentRegistry(previewConfig);
await previewRegistry.initialize();
const investigatorDef = previewRegistry.getDefinition(
'codebase_investigator',
);
expect(investigatorDef).toBeDefined();
expect(investigatorDef?.modelConfig.model).toBe('gemini-3-pro-preview');
});
});
describe('registration logic', () => {

View File

@@ -9,6 +9,11 @@ import type { AgentDefinition } from './types.js';
import { CodebaseInvestigatorAgent } from './codebase-investigator.js';
import { type z } from 'zod';
import { debugLogger } from '../utils/debugLogger.js';
import {
DEFAULT_GEMINI_MODEL_AUTO,
GEMINI_MODEL_ALIAS_PRO,
PREVIEW_GEMINI_MODEL,
} from '../config/models.js';
import type { ModelConfigAlias } from '../services/modelConfigService.js';
/**
@@ -48,13 +53,26 @@ export class AgentRegistry {
// Only register the agent if it's enabled in the settings.
if (investigatorSettings?.enabled) {
let model =
investigatorSettings.model ??
CodebaseInvestigatorAgent.modelConfig.model;
// If the user is using the preview model for the main agent, force the sub-agent to use it too
// if it's configured to use 'pro' or 'auto'.
if (this.config.getModel() === PREVIEW_GEMINI_MODEL) {
if (
model === GEMINI_MODEL_ALIAS_PRO ||
model === DEFAULT_GEMINI_MODEL_AUTO
) {
model = PREVIEW_GEMINI_MODEL;
}
}
const agentDef = {
...CodebaseInvestigatorAgent,
modelConfig: {
...CodebaseInvestigatorAgent.modelConfig,
model:
investigatorSettings.model ??
CodebaseInvestigatorAgent.modelConfig.model,
model,
thinkingBudget:
investigatorSettings.thinkingBudget ??
CodebaseInvestigatorAgent.modelConfig.thinkingBudget,

View File

@@ -888,6 +888,11 @@ describe('Server Config (config.ts)', () => {
expect(SubagentToolWrapperMock).not.toHaveBeenCalled();
});
it('should not set default codebase investigator model in config (defaults in registry)', () => {
const config = new Config(baseParams);
expect(config.getCodebaseInvestigatorSettings()?.model).toBeUndefined();
});
describe('with minified tool class names', () => {
beforeEach(() => {
Object.defineProperty(

View File

@@ -48,7 +48,6 @@ import { tokenLimit } from '../core/tokenLimits.js';
import {
DEFAULT_GEMINI_EMBEDDING_MODEL,
DEFAULT_GEMINI_FLASH_MODEL,
DEFAULT_GEMINI_MODEL,
DEFAULT_THINKING_MODE,
} from './models.js';
import { shouldAttemptBrowserLaunch } from '../utils/browser.js';
@@ -573,7 +572,7 @@ export class Config {
thinkingBudget:
params.codebaseInvestigatorSettings?.thinkingBudget ??
DEFAULT_THINKING_MODE,
model: params.codebaseInvestigatorSettings?.model ?? DEFAULT_GEMINI_MODEL,
model: params.codebaseInvestigatorSettings?.model,
};
this.continueOnFailedApiCall = params.continueOnFailedApiCall ?? true;
this.enableShellOutputEfficiency =