feat: enable subagents (#22386)

This commit is contained in:
Abhi
2026-03-16 14:40:12 -04:00
committed by GitHub
parent 56e0865a7b
commit d43ec6c8f3
13 changed files with 111 additions and 59 deletions

View File

@@ -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',
};

View File

@@ -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)}`,
);
}
}
}