mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-02 01:11:24 -07:00
feat: enable subagents (#22386)
This commit is contained in:
@@ -1246,7 +1246,7 @@ describe('Server Config (config.ts)', () => {
|
||||
const config = new Config(params);
|
||||
|
||||
const mockAgentDefinition = {
|
||||
name: 'codebase-investigator',
|
||||
name: 'codebase_investigator',
|
||||
description: 'Agent 1',
|
||||
instructions: 'Inst 1',
|
||||
};
|
||||
@@ -1294,7 +1294,7 @@ describe('Server Config (config.ts)', () => {
|
||||
it('should register subagents as tools even when they are not in allowedTools', async () => {
|
||||
const params: ConfigParameters = {
|
||||
...baseParams,
|
||||
allowedTools: ['read_file'], // codebase-investigator is NOT here
|
||||
allowedTools: ['read_file'], // codebase_investigator is NOT here
|
||||
agents: {
|
||||
overrides: {
|
||||
codebase_investigator: { enabled: true },
|
||||
@@ -1304,7 +1304,7 @@ describe('Server Config (config.ts)', () => {
|
||||
const config = new Config(params);
|
||||
|
||||
const mockAgentDefinition = {
|
||||
name: 'codebase-investigator',
|
||||
name: 'codebase_investigator',
|
||||
description: 'Agent 1',
|
||||
instructions: 'Inst 1',
|
||||
};
|
||||
|
||||
@@ -948,7 +948,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
this.model = params.model;
|
||||
this.disableLoopDetection = params.disableLoopDetection ?? false;
|
||||
this._activeModel = params.model;
|
||||
this.enableAgents = params.enableAgents ?? false;
|
||||
this.enableAgents = params.enableAgents ?? true;
|
||||
this.agents = params.agents ?? {};
|
||||
this.disableLLMCorrection = params.disableLLMCorrection ?? true;
|
||||
this.planEnabled = params.plan ?? true;
|
||||
@@ -3147,22 +3147,23 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
*/
|
||||
private registerSubAgentTools(registry: ToolRegistry): void {
|
||||
const agentsOverrides = this.getAgentsSettings().overrides ?? {};
|
||||
if (
|
||||
this.isAgentsEnabled() ||
|
||||
agentsOverrides['codebase_investigator']?.enabled !== false ||
|
||||
agentsOverrides['cli_help']?.enabled !== false
|
||||
) {
|
||||
const definitions = this.agentRegistry.getAllDefinitions();
|
||||
const definitions = this.agentRegistry.getAllDefinitions();
|
||||
|
||||
for (const definition of definitions) {
|
||||
try {
|
||||
const tool = new SubagentTool(definition, this, this.messageBus);
|
||||
registry.registerTool(tool);
|
||||
} catch (e: unknown) {
|
||||
debugLogger.warn(
|
||||
`Failed to register tool for agent ${definition.name}: ${getErrorMessage(e)}`,
|
||||
);
|
||||
for (const definition of definitions) {
|
||||
try {
|
||||
if (
|
||||
!this.isAgentsEnabled() ||
|
||||
agentsOverrides[definition.name]?.enabled === false
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const tool = new SubagentTool(definition, this, this.messageBus);
|
||||
registry.registerTool(tool);
|
||||
} catch (e: unknown) {
|
||||
debugLogger.warn(
|
||||
`Failed to register tool for agent ${definition.name}: ${getErrorMessage(e)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user