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

Function buildToolDescription

packages/agent-runtime/src/tools/prompts.ts:106–135  ·  view source on GitHub ↗
(params: {
  toolName: string
  schema: z.ZodType
  description?: string
  endsAgentStep: boolean
  exampleInputs?: any[]
})

Source from the content-addressed store, hash-verified

104
105// Helper function to build the full tool description markdown
106export function buildToolDescription(params: {
107 toolName: string
108 schema: z.ZodType
109 description?: string
110 endsAgentStep: boolean
111 exampleInputs?: any[]
112}): string {
113 const {
114 toolName,
115 schema,
116 description = '',
117 endsAgentStep,
118 exampleInputs = [],
119 } = params
120 const descriptionWithExamples = buildArray(
121 description,
122 exampleInputs.length > 0
123 ? `${pluralize(exampleInputs.length, 'Example')}:`
124 : '',
125 ...exampleInputs.map((example) =>
126 getToolCallString(toolName, example, endsAgentStep),
127 ),
128 ).join('\n\n')
129 return buildArray([
130 `### ${toolName}`,
131 schema.description || '',
132 paramsSection({ schema, endsAgentStep }),
133 descriptionWithExamples,
134 ]).join('\n\n')
135}
136
137export const toolDescriptions = Object.fromEntries(
138 Object.entries(toolParams).map(([name, config]) => [

Callers 3

prompts.tsFile · 0.85
fullToolListFunction · 0.85

Calls 4

buildArrayFunction · 0.90
pluralizeFunction · 0.90
getToolCallStringFunction · 0.90
paramsSectionFunction · 0.85

Tested by

no test coverage detected