(
params: {
spawnableAgents: AgentTemplateType[]
agentTemplates: Record<string, AgentTemplate>
logger: Logger
} & ParamsExcluding<
typeof getAgentTemplate,
'agentId' | 'localAgentTemplates'
>,
)
| 72 | * These tools allow the model to call agents directly as tool calls. |
| 73 | */ |
| 74 | export async function buildAgentToolSet( |
| 75 | params: { |
| 76 | spawnableAgents: AgentTemplateType[] |
| 77 | agentTemplates: Record<string, AgentTemplate> |
| 78 | logger: Logger |
| 79 | } & ParamsExcluding< |
| 80 | typeof getAgentTemplate, |
| 81 | 'agentId' | 'localAgentTemplates' |
| 82 | >, |
| 83 | ): Promise<ToolSet> { |
| 84 | const { spawnableAgents, agentTemplates } = params |
| 85 | |
| 86 | const toolSet: ToolSet = {} |
| 87 | |
| 88 | for (const agentType of spawnableAgents) { |
| 89 | const agentTemplate = await getAgentTemplate({ |
| 90 | ...params, |
| 91 | agentId: agentType, |
| 92 | localAgentTemplates: agentTemplates, |
| 93 | }) |
| 94 | |
| 95 | if (!agentTemplate) continue |
| 96 | |
| 97 | const toolName = getAgentToolName(agentType) |
| 98 | const inputSchema = ensureJsonSchemaCompatible( |
| 99 | buildAgentToolInputSchema(agentTemplate), |
| 100 | ) |
| 101 | |
| 102 | // Use the same structure as other tools in toolParams |
| 103 | toolSet[toolName] = { |
| 104 | description: |
| 105 | agentTemplate.spawnerPrompt || |
| 106 | `Spawn the ${agentTemplate.displayName} agent`, |
| 107 | inputSchema, |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return toolSet |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Builds the description of a single agent for the system prompt. |
no test coverage detected