MCPcopy
hub / github.com/CodebuffAI/codebuff / buildAgentToolSet

Function buildAgentToolSet

packages/agent-runtime/src/templates/prompts.ts:74–112  ·  view source on GitHub ↗
(
  params: {
    spawnableAgents: AgentTemplateType[]
    agentTemplates: Record<string, AgentTemplate>
    logger: Logger
  } & ParamsExcluding<
    typeof getAgentTemplate,
    'agentId' | 'localAgentTemplates'
  >,
)

Source from the content-addressed store, hash-verified

72 * These tools allow the model to call agents directly as tool calls.
73 */
74export 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.

Callers 2

loopAgentStepsFunction · 0.90

Calls 4

getAgentTemplateFunction · 0.90
getAgentToolNameFunction · 0.85

Tested by

no test coverage detected