Enable & disable agents (#16225)

This commit is contained in:
Sehoon Shon
2026-01-14 19:30:17 -05:00
committed by GitHub
parent 42c26d1e1b
commit 4b2e9f7954
9 changed files with 800 additions and 13 deletions
@@ -64,7 +64,7 @@ export class A2AClientManager {
agentCardUrl: string,
authHandler?: AuthenticationHandler,
): Promise<AgentCard> {
if (this.clients.has(name)) {
if (this.clients.has(name) && this.agentCards.has(name)) {
throw new Error(`Agent with name '${name}' is already loaded.`);
}
+13 -4
View File
@@ -69,6 +69,7 @@ export class AgentRegistry {
*/
async reload(): Promise<void> {
A2AClientManager.getInstance().clearCache();
await this.config.reloadAgents();
this.agents.clear();
await this.loadAgents();
coreEvents.emitAgentsRefreshed();
@@ -143,9 +144,14 @@ export class AgentRegistry {
private loadBuiltInAgents(): void {
const investigatorSettings = this.config.getCodebaseInvestigatorSettings();
const cliHelpSettings = this.config.getCliHelpAgentSettings();
const agentsSettings = this.config.getAgentsSettings();
const agentsOverrides = agentsSettings.overrides ?? {};
// Only register the agent if it's enabled in the settings.
if (investigatorSettings?.enabled) {
// Only register the agent if it's enabled in the settings and not explicitly disabled via overrides.
if (
investigatorSettings?.enabled &&
!agentsOverrides[CodebaseInvestigatorAgent.name]?.disabled
) {
let model;
const settingsModel = investigatorSettings.model;
// Check if the user explicitly set a model in the settings.
@@ -189,8 +195,11 @@ export class AgentRegistry {
this.registerLocalAgent(agentDef);
}
// Register the CLI help agent if it's explicitly enabled.
if (cliHelpSettings.enabled) {
// Register the CLI help agent if it's explicitly enabled and not explicitly disabled via overrides.
if (
cliHelpSettings.enabled &&
!agentsOverrides[CliHelpAgent.name]?.disabled
) {
this.registerLocalAgent(CliHelpAgent(this.config));
}
}
+15 -1
View File
@@ -387,6 +387,7 @@ export interface ConfigParameters {
onReload?: () => Promise<{
disabledSkills?: string[];
adminSkillsEnabled?: boolean;
agents?: AgentSettings;
}>;
}
@@ -518,11 +519,12 @@ export class Config {
| (() => Promise<{
disabledSkills?: string[];
adminSkillsEnabled?: boolean;
agents?: AgentSettings;
}>)
| undefined;
private readonly enableAgents: boolean;
private readonly agents: AgentSettings;
private agents: AgentSettings;
private readonly skillsSupport: boolean;
private disabledSkills: string[];
private readonly adminSkillsEnabled: boolean;
@@ -1634,6 +1636,18 @@ export class Config {
await this.updateSystemInstructionIfInitialized();
}
/**
* Reloads agent settings.
*/
async reloadAgents(): Promise<void> {
if (this.onReload) {
const refreshed = await this.onReload();
if (refreshed.agents) {
this.agents = refreshed.agents;
}
}
}
isInteractive(): boolean {
return this.interactive;
}