mirror of
https://github.com/google-gemini/gemini-cli
synced 2026-04-21 13:37:17 +00:00
Co-authored-by: Abhi <43648792+abhipatel12@users.noreply.github.com> Co-authored-by: Abhi <abhipatel@google.com>
This commit is contained in:
parent
63c6560a38
commit
e88b56bbcb
10 changed files with 63 additions and 11 deletions
|
|
@ -1159,7 +1159,7 @@ their corresponding top-level category object in your `settings.json` file.
|
|||
|
||||
- **`experimental.enableAgents`** (boolean):
|
||||
- **Description:** Enable local and remote subagents.
|
||||
- **Default:** `true`
|
||||
- **Default:** `false`
|
||||
- **Requires restart:** Yes
|
||||
|
||||
- **`experimental.extensionManagement`** (boolean):
|
||||
|
|
|
|||
|
|
@ -325,6 +325,28 @@ describe('loadConfig', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should pass enableAgents to Config constructor', async () => {
|
||||
const settings: Settings = {
|
||||
experimental: {
|
||||
enableAgents: false,
|
||||
},
|
||||
};
|
||||
await loadConfig(settings, mockExtensionLoader, taskId);
|
||||
expect(Config).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
enableAgents: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should default enableAgents to false when not provided', async () => {
|
||||
await loadConfig(mockSettings, mockExtensionLoader, taskId);
|
||||
expect(Config).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
enableAgents: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
describe('interactivity', () => {
|
||||
it('should set interactive true when not headless', async () => {
|
||||
vi.mocked(isHeadlessMode).mockReturnValue(false);
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export async function loadConfig(
|
|||
interactive: !isHeadlessMode(),
|
||||
enableInteractiveShell: !isHeadlessMode(),
|
||||
ptyInfo: 'auto',
|
||||
enableAgents: settings.experimental?.enableAgents ?? false,
|
||||
};
|
||||
|
||||
const fileService = new FileDiscoveryService(workspaceDir, {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ export interface Settings {
|
|||
enableRecursiveFileSearch?: boolean;
|
||||
customIgnoreFilePaths?: string[];
|
||||
};
|
||||
experimental?: {
|
||||
enableAgents?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SettingsError {
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ describe('SettingsSchema', () => {
|
|||
expect(setting).toBeDefined();
|
||||
expect(setting.type).toBe('boolean');
|
||||
expect(setting.category).toBe('Experimental');
|
||||
expect(setting.default).toBe(true);
|
||||
expect(setting.default).toBe(false);
|
||||
expect(setting.requiresRestart).toBe(true);
|
||||
expect(setting.showInDialog).toBe(false);
|
||||
expect(setting.description).toBe('Enable local and remote subagents.');
|
||||
|
|
|
|||
|
|
@ -1838,7 +1838,7 @@ const SETTINGS_SCHEMA = {
|
|||
label: 'Enable Agents',
|
||||
category: 'Experimental',
|
||||
requiresRestart: true,
|
||||
default: true,
|
||||
default: false,
|
||||
description: 'Enable local and remote subagents.',
|
||||
showInDialog: false,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export class AgentRegistry {
|
|||
private readonly agents = new Map<string, AgentDefinition<any>>();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private readonly allDefinitions = new Map<string, AgentDefinition<any>>();
|
||||
private readonly builtInAgents = new Set<string>();
|
||||
|
||||
constructor(private readonly config: Config) {}
|
||||
|
||||
|
|
@ -56,6 +57,13 @@ export class AgentRegistry {
|
|||
await this.loadAgents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the agent is a built-in agent.
|
||||
*/
|
||||
isBuiltIn(name: string): boolean {
|
||||
return this.builtInAgents.has(name);
|
||||
}
|
||||
|
||||
private onModelChanged = () => {
|
||||
this.refreshAgents().catch((e) => {
|
||||
debugLogger.error(
|
||||
|
|
@ -240,15 +248,25 @@ export class AgentRegistry {
|
|||
}
|
||||
|
||||
private loadBuiltInAgents(): void {
|
||||
this.registerLocalAgent(CodebaseInvestigatorAgent(this.config));
|
||||
this.registerLocalAgent(CliHelpAgent(this.config));
|
||||
this.registerLocalAgent(GeneralistAgent(this.config));
|
||||
const codebaseAgent = CodebaseInvestigatorAgent(this.config);
|
||||
this.builtInAgents.add(codebaseAgent.name);
|
||||
this.registerLocalAgent(codebaseAgent);
|
||||
|
||||
const helpAgent = CliHelpAgent(this.config);
|
||||
this.builtInAgents.add(helpAgent.name);
|
||||
this.registerLocalAgent(helpAgent);
|
||||
|
||||
const generalistAgent = GeneralistAgent(this.config);
|
||||
this.builtInAgents.add(generalistAgent.name);
|
||||
this.registerLocalAgent(generalistAgent);
|
||||
|
||||
// Register the browser agent if enabled in settings.
|
||||
// Tools are configured dynamically at invocation time via browserAgentFactory.
|
||||
const browserConfig = this.config.getBrowserAgentConfig();
|
||||
if (browserConfig.enabled) {
|
||||
this.registerLocalAgent(BrowserAgentDefinition(this.config));
|
||||
const browserAgent = BrowserAgentDefinition(this.config);
|
||||
this.builtInAgents.add(browserAgent.name);
|
||||
this.registerLocalAgent(browserAgent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ vi.mock('../agents/registry.js', () => {
|
|||
AgentRegistryMock.prototype.initialize = vi.fn();
|
||||
AgentRegistryMock.prototype.getAllDefinitions = vi.fn(() => []);
|
||||
AgentRegistryMock.prototype.getDefinition = vi.fn();
|
||||
AgentRegistryMock.prototype.isBuiltIn = vi.fn();
|
||||
return { AgentRegistry: AgentRegistryMock };
|
||||
});
|
||||
|
||||
|
|
@ -1262,6 +1263,9 @@ describe('Server Config (config.ts)', () => {
|
|||
AgentRegistryMock.prototype.getAllDefinitions.mockReturnValue([
|
||||
mockAgentDefinition,
|
||||
]);
|
||||
AgentRegistryMock.prototype.isBuiltIn.mockImplementation(
|
||||
(name: string) => name === 'codebase_investigator',
|
||||
);
|
||||
|
||||
const SubAgentToolMock = (
|
||||
(await vi.importMock('../agents/subagent-tool.js')) as {
|
||||
|
|
@ -1317,6 +1321,9 @@ describe('Server Config (config.ts)', () => {
|
|||
AgentRegistryMock.prototype.getAllDefinitions.mockReturnValue([
|
||||
mockAgentDefinition,
|
||||
]);
|
||||
AgentRegistryMock.prototype.isBuiltIn.mockImplementation(
|
||||
(name: string) => name === 'codebase_investigator',
|
||||
);
|
||||
|
||||
const SubAgentToolMock = (
|
||||
(await vi.importMock('../agents/subagent-tool.js')) as {
|
||||
|
|
|
|||
|
|
@ -951,7 +951,7 @@ export class Config implements McpContext, AgentLoopContext {
|
|||
this.model = params.model;
|
||||
this.disableLoopDetection = params.disableLoopDetection ?? false;
|
||||
this._activeModel = params.model;
|
||||
this.enableAgents = params.enableAgents ?? true;
|
||||
this.enableAgents = params.enableAgents ?? false;
|
||||
this.agents = params.agents ?? {};
|
||||
this.disableLLMCorrection = params.disableLLMCorrection ?? true;
|
||||
this.planEnabled = params.plan ?? true;
|
||||
|
|
@ -3196,7 +3196,8 @@ export class Config implements McpContext, AgentLoopContext {
|
|||
for (const definition of definitions) {
|
||||
try {
|
||||
if (
|
||||
!this.isAgentsEnabled() ||
|
||||
(!this.isAgentsEnabled() &&
|
||||
!this.agentRegistry.isBuiltIn(definition.name)) ||
|
||||
agentsOverrides[definition.name]?.enabled === false
|
||||
) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1971,8 +1971,8 @@
|
|||
"enableAgents": {
|
||||
"title": "Enable Agents",
|
||||
"description": "Enable local and remote subagents.",
|
||||
"markdownDescription": "Enable local and remote subagents.\n\n- Category: `Experimental`\n- Requires restart: `yes`\n- Default: `true`",
|
||||
"default": true,
|
||||
"markdownDescription": "Enable local and remote subagents.\n\n- Category: `Experimental`\n- Requires restart: `yes`\n- Default: `false`",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"extensionManagement": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue