( toolNames: readonly string[], additionalToolDefinitions: CustomToolDefinitions, )
| 293 | } |
| 294 | |
| 295 | export const getShortToolInstructions = ( |
| 296 | toolNames: readonly string[], |
| 297 | additionalToolDefinitions: CustomToolDefinitions, |
| 298 | ) => { |
| 299 | if ( |
| 300 | toolNames.length === 0 && |
| 301 | Object.keys(additionalToolDefinitions).length === 0 |
| 302 | ) { |
| 303 | return '' |
| 304 | } |
| 305 | |
| 306 | const toolDescriptionsList = [ |
| 307 | ...( |
| 308 | toolNames.filter( |
| 309 | (name) => (name as keyof typeof toolParams) in toolParams, |
| 310 | ) as (keyof typeof toolParams)[] |
| 311 | ).map((name) => { |
| 312 | const tool = toolParams[name] |
| 313 | return buildShortToolDescription({ |
| 314 | toolName: name, |
| 315 | schema: tool.inputSchema, |
| 316 | endsAgentStep: tool.endsAgentStep, |
| 317 | }) |
| 318 | }), |
| 319 | ...Object.keys(additionalToolDefinitions).map((name) => { |
| 320 | const { inputSchema, endsAgentStep } = additionalToolDefinitions[name] |
| 321 | return buildShortToolDescription({ |
| 322 | toolName: name, |
| 323 | schema: ensureZodSchema(inputSchema), |
| 324 | endsAgentStep: endsAgentStep ?? true, |
| 325 | }) |
| 326 | }), |
| 327 | ] |
| 328 | |
| 329 | return `## Tools |
| 330 | Use the tools below to complete the user request, if applicable. |
| 331 | |
| 332 | Tool calls use a specific XML and JSON-like format. Adhere *precisely* to this nested element structure: |
| 333 | |
| 334 | ${getToolCallString( |
| 335 | 'tool_name', |
| 336 | { |
| 337 | parameter1: 'value1', |
| 338 | parameter2: 123, |
| 339 | }, |
| 340 | false, |
| 341 | )} |
| 342 | |
| 343 | Important: You only have access to the tools below. Do not use any other tools -- they are not available to you, instead they may have been previously used by other agents. |
| 344 | |
| 345 | ${toolDescriptionsList.join('\n\n')} |
| 346 | `.trim() |
| 347 | } |
| 348 | |
| 349 | export async function getToolSet(params: { |
| 350 | toolNames: string[] |
nothing calls this directly
no test coverage detected