fix(core): Use manual tool description if neither resources or operations exist (#15093)

This commit is contained in:
Charlie Kolb
2025-05-05 11:44:28 +02:00
committed by GitHub
parent 4b5f045281
commit 1d4f63985b
2 changed files with 12 additions and 6 deletions

View File

@@ -68,6 +68,15 @@ describe('createNodeAsTool', () => {
expect(tool.description).toBe('Custom tool description');
});
it('should use toolDescription when descriptionType is absent', () => {
delete node.parameters.descriptionType;
node.parameters.toolDescription = 'Another custom tool description';
const tool = createNodeAsTool(options).response;
expect(tool.description).toBe('Another custom tool description');
});
});
describe('Schema Creation and Parameter Handling', () => {

View File

@@ -90,8 +90,6 @@ function getSchema(node: INode) {
* @returns A string description for the node.
*/
function makeDescription(node: INode, nodeType: INodeType): string {
const manualDescription = node.parameters.toolDescription as string;
if (node.parameters.descriptionType === 'auto') {
const resource = node.parameters.resource as string;
const operation = node.parameters.operation as string;
@@ -104,11 +102,10 @@ function makeDescription(node: INode, nodeType: INodeType): string {
}
return description.trim();
}
if (node.parameters.descriptionType === 'manual') {
return manualDescription ?? nodeType.description.description;
}
return nodeType.description.description;
// Users can define custom descriptions when `descriptionType` is manual or not included
// in the node's properties, e.g. when the node has neither `operation` or `resource`
return (node.parameters.toolDescription as string) ?? nodeType.description.description;
}
export function nodeNameToToolName(node: INode): string {