510
}
511
if (runSubagentTool) {
513
>
if (!this._enabledSubagents || this._enabledSubagents.includes('*')) {
514
>
return (agent: ICustomAgent) => agent.visibility.agentInvocable && matchesSessionType(agent.sessionTypes, currentSessionType);
515
>
} else {
516
const subagents = this._enabledSubagents;
517
return (agent: ICustomAgent) => subagents.includes(agent.name) && matchesSessionType(agent.sessionTypes, currentSessionType);
518
}
520
>
const agents = (await this._promptsService.getCustomAgents(token)).filter(a => a.enabled);
521
>
522
>
if (agents.length > 0) {
523
>
entries.push('<agents>');
524
>
entries.push('Here is a list of agents that can be used when running a subagent.');
525
>
entries.push('Each agent has optionally a description with the agent\'s purpose and expertise. When asked to run a subagent, choose the most appropriate agent from this list.');
526
>
entries.push(`Use the ${runSubagentTool.variable} tool with the agent name to run the subagent.`);
527
>
528
>
for (const agent of agents) {
529
>
if (canUseAgent(agent)) {
530
>
entries.push('<agent>');
531
>
entries.push(`<name>${agent.name}</name>`);
532
>
if (agent.description) {
533
>
entries.push(`<description>${agent.description}</description>`);
534
>
}
535
>
if (agent.argumentHint) {
536
entries.push(`<argumentHint>${agent.argumentHint}</argumentHint>`);
537
}
539
>
debugInfo.debugDetails.push({ category: 'custom-agent', name: agent.name, uri: agent.uri });
540
>
if (isInClaudeAgentsFolder(agent.uri)) {
541
telemetryEvent.claudeAgentsCount++;
542
}
544
debugInfo.debugDetails.push({ category: 'skipped', name: agent.name, uri: agent.uri, reason: localize('debugDetail.agentNotInvocable', 'not invocable by model') });
545
}
547
>
entries.push('</agents>', '', ''); // add trailing newline
548
>
}
549
>
}
550
if (entries.length === 0) {
551
return undefined;