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

Function fullToolList

packages/agent-runtime/src/tools/prompts.ts:243–293  ·  view source on GitHub ↗
(
  toolNames: readonly string[],
  additionalToolDefinitions: CustomToolDefinitions,
  options?: { availableSkillsXml?: string },
)

Source from the content-addressed store, hash-verified

241}
242
243export const fullToolList = (
244 toolNames: readonly string[],
245 additionalToolDefinitions: CustomToolDefinitions,
246 options?: { availableSkillsXml?: string },
247) => {
248 if (
249 toolNames.length === 0 &&
250 Object.keys(additionalToolDefinitions).length === 0
251 ) {
252 return ''
253 }
254
255 const { availableSkillsXml = '' } = options ?? {}
256
257 // Build tool descriptions, replacing skill placeholder with actual skills
258 const descriptions = [
259 ...(
260 toolNames.filter((toolName) =>
261 toolNames.includes(toolName as ToolName),
262 ) as ToolName[]
263 ).map((name) => {
264 let desc = toolDescriptions[name]
265 // Replace skill placeholder with actual available skills
266 if (name === 'skill' && availableSkillsXml) {
267 desc = desc.replace(AVAILABLE_SKILLS_PLACEHOLDER, availableSkillsXml)
268 } else if (name === 'skill') {
269 // Explicitly state no skills are available
270 desc = desc.replace(
271 AVAILABLE_SKILLS_PLACEHOLDER,
272 'There are no skills available. Do not use this tool because there are no skills to load.',
273 )
274 }
275 return desc
276 }),
277 ...Object.keys(additionalToolDefinitions).map((toolName) => {
278 const toolDef = additionalToolDefinitions[toolName]
279 return buildToolDescription({
280 toolName,
281 schema: ensureZodSchema(toolDef.inputSchema),
282 description: toolDef.description,
283 endsAgentStep: toolDef.endsAgentStep ?? true,
284 exampleInputs: toolDef.exampleInputs,
285 })
286 }),]
287
288 return `## List of Tools
289
290These are the only tools that you can use. The user cannot see these descriptions, so you should not reference any tool names, parameters, or descriptions. Do not try to use any other tools -- even if referenced earlier in the conversation, they are not available to you, instead they may have been previously used by other agents.
291
292${descriptions.join('\n\n')}`.trim()
293}
294
295export const getShortToolInstructions = (
296 toolNames: readonly string[],

Callers 1

getToolsInstructionsFunction · 0.85

Calls 2

buildToolDescriptionFunction · 0.85
ensureZodSchemaFunction · 0.85

Tested by

no test coverage detected