feat(AI Agent Tool Node): Add Agent Tool (#17108)

This commit is contained in:
Mutasem Aldmour
2025-07-09 11:41:58 +02:00
committed by GitHub
parent 3be5823b97
commit f67581b74d
14 changed files with 500 additions and 116 deletions

View File

@@ -143,3 +143,14 @@ export const textFromPreviousNode: INodeProperties = {
},
disabledOptions: { show: { promptType: ['auto'] } },
};
export const toolDescription: INodeProperties = {
displayName: 'Description',
name: 'toolDescription',
type: 'string',
default: 'AI Agent that can call other tools',
required: true,
typeOptions: { rows: 2 },
description:
'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often',
};

View File

@@ -75,16 +75,16 @@ export function isToolsInstance(model: unknown): model is Tool {
}
export function getPromptInputByType(options: {
ctx: IExecuteFunctions;
ctx: IExecuteFunctions | ISupplyDataFunctions;
i: number;
promptTypeKey: string;
inputKey: string;
}) {
const { ctx, i, promptTypeKey, inputKey } = options;
const prompt = ctx.getNodeParameter(promptTypeKey, i) as string;
const promptType = ctx.getNodeParameter(promptTypeKey, i, 'define') as string;
let input;
if (prompt === 'auto') {
if (promptType === 'auto') {
input = ctx.evaluateExpression('{{ $json["chatInput"] }}', i) as string;
} else {
input = ctx.getNodeParameter(inputKey, i) as string;
@@ -186,7 +186,7 @@ export function escapeSingleCurlyBrackets(text?: string): string | undefined {
}
export const getConnectedTools = async (
ctx: IExecuteFunctions | IWebhookFunctions,
ctx: IExecuteFunctions | IWebhookFunctions | ISupplyDataFunctions,
enforceUniqueNames: boolean,
convertStructuredTool: boolean = true,
escapeCurlyBrackets: boolean = false,

View File

@@ -1,4 +1,4 @@
import type { IExecuteFunctions } from 'n8n-workflow';
import type { IExecuteFunctions, ISupplyDataFunctions } from 'n8n-workflow';
import { NodeConnectionTypes } from 'n8n-workflow';
import { N8nItemListOutputParser } from './N8nItemListOutputParser';
@@ -13,7 +13,7 @@ export type N8nOutputParser =
export { N8nOutputFixingParser, N8nItemListOutputParser, N8nStructuredOutputParser };
export async function getOptionalOutputParser(
ctx: IExecuteFunctions,
ctx: IExecuteFunctions | ISupplyDataFunctions,
index: number = 0,
): Promise<N8nOutputParser | undefined> {
let outputParser: N8nOutputParser | undefined;