first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,102 @@
import { NodeConnectionTypes } from 'n8n-workflow';
import type {
IExecuteFunctions,
INodeExecutionData,
INodeType,
INodeTypeDescription,
INodeTypeBaseDescription,
ISupplyDataFunctions,
} from 'n8n-workflow';
import { textInput, toolDescription } from '@utils/descriptions';
import { getInputs } from './utils';
import { getToolsAgentProperties } from '../agents/ToolsAgent/V2/description';
import { toolsAgentExecute } from '../agents/ToolsAgent/V2/execute';
export class AgentToolV2 implements INodeType {
description: INodeTypeDescription;
constructor(baseDescription: INodeTypeBaseDescription) {
this.description = {
...baseDescription,
version: [2.2],
defaults: {
name: 'AI Agent Tool',
color: '#404040',
},
inputs: `={{
((hasOutputParser, needsFallback) => {
${getInputs.toString()};
return getInputs(false, hasOutputParser, needsFallback)
})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true, $parameter.needsFallback !== undefined && $parameter.needsFallback === true)
}}`,
outputs: [NodeConnectionTypes.AiTool],
builderHint: {
...baseDescription.builderHint,
inputs: {
ai_languageModel: { required: true },
ai_memory: { required: false },
ai_tool: { required: false },
ai_outputParser: {
required: false,
displayOptions: { show: { hasOutputParser: [true] } },
},
},
},
properties: [
toolDescription,
{
...textInput,
},
{
displayName: 'Require Specific Output Format',
name: 'hasOutputParser',
type: 'boolean',
default: false,
noDataExpression: true,
},
{
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
name: 'notice',
type: 'notice',
default: '',
displayOptions: {
show: {
hasOutputParser: [true],
},
},
},
{
displayName: 'Enable Fallback Model',
name: 'needsFallback',
type: 'boolean',
default: false,
noDataExpression: true,
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 2.1 } }],
},
},
},
{
displayName:
'Connect an additional language model on the canvas to use it as a fallback if the main model fails',
name: 'fallbackNotice',
type: 'notice',
default: '',
displayOptions: {
show: {
needsFallback: [true],
},
},
},
...getToolsAgentProperties({ withStreaming: false }),
],
};
}
// Automatically wrapped as a tool
async execute(this: IExecuteFunctions | ISupplyDataFunctions): Promise<INodeExecutionData[][]> {
return await toolsAgentExecute.call(this);
}
}
@@ -0,0 +1,144 @@
import { NodeConnectionTypes } from 'n8n-workflow';
import type {
IExecuteFunctions,
INodeExecutionData,
INodeType,
INodeTypeDescription,
INodeTypeBaseDescription,
} from 'n8n-workflow';
import {
promptTypeOptionsDeprecated,
textFromGuardrailsNode,
textFromPreviousNode,
textInput,
} from '@utils/descriptions';
import { getToolsAgentProperties } from '../agents/ToolsAgent/V2/description';
import { toolsAgentExecute } from '../agents/ToolsAgent/V2/execute';
import { getInputs } from '../utils';
export class AgentV2 implements INodeType {
description: INodeTypeDescription;
constructor(baseDescription: INodeTypeBaseDescription) {
this.description = {
...baseDescription,
version: [2, 2.1, 2.2],
defaults: {
name: 'AI Agent',
color: '#404040',
},
inputs: `={{
((hasOutputParser, needsFallback) => {
${getInputs.toString()};
return getInputs(true, hasOutputParser, needsFallback);
})($parameter.hasOutputParser === undefined || $parameter.hasOutputParser === true, $parameter.needsFallback !== undefined && $parameter.needsFallback === true)
}}`,
outputs: [NodeConnectionTypes.Main],
builderHint: {
...baseDescription.builderHint,
inputs: {
ai_languageModel: { required: true },
ai_memory: { required: false },
ai_tool: { required: false },
ai_outputParser: {
required: false,
displayOptions: { show: { hasOutputParser: [true] } },
},
},
},
properties: [
{
displayName:
'Tip: Get a feel for agents with our quick <a href="https://docs.n8n.io/advanced-ai/intro-tutorial/" target="_blank">tutorial</a> or see an <a href="/workflows/templates/1954" target="_blank">example</a> of how this node works',
name: 'aiAgentStarterCallout',
type: 'callout',
default: '',
},
promptTypeOptionsDeprecated,
{
...textFromGuardrailsNode,
displayOptions: {
show: {
promptType: ['guardrails'],
},
},
},
{
...textFromPreviousNode,
displayOptions: {
show: {
promptType: ['auto'],
},
},
},
{
...textInput,
displayOptions: {
show: {
promptType: ['define'],
},
},
},
{
displayName: 'Require Specific Output Format',
name: 'hasOutputParser',
type: 'boolean',
default: false,
noDataExpression: true,
},
{
displayName: `Connect an <a data-action='openSelectiveNodeCreator' data-action-parameter-connectiontype='${NodeConnectionTypes.AiOutputParser}'>output parser</a> on the canvas to specify the output format you require`,
name: 'notice',
type: 'notice',
default: '',
displayOptions: {
show: {
hasOutputParser: [true],
},
},
},
{
displayName: 'Enable Fallback Model',
name: 'needsFallback',
type: 'boolean',
default: false,
noDataExpression: true,
displayOptions: {
show: {
'@version': [{ _cnd: { gte: 2.1 } }],
},
},
},
{
displayName:
'Connect an additional language model on the canvas to use it as a fallback if the main model fails',
name: 'fallbackNotice',
type: 'notice',
default: '',
displayOptions: {
show: {
needsFallback: [true],
},
},
},
...getToolsAgentProperties({ withStreaming: true }),
],
hints: [
{
message:
'You are using streaming responses. Make sure to set the response mode to "Streaming Response" on the connected trigger node.',
type: 'warning',
location: 'outputPane',
whenToDisplay: 'afterExecution',
displayCondition: '={{ $parameter["enableStreaming"] === true }}',
},
],
};
}
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
return await toolsAgentExecute.call(this);
}
}
@@ -0,0 +1,96 @@
// Function used in the inputs expression to figure out which inputs to
import {
type INodeInputConfiguration,
type INodeFilter,
type NodeConnectionType,
} from 'n8n-workflow';
// display based on the agent type
/* istanbul ignore next */
export function getInputs(
hasMainInput?: boolean,
hasOutputParser?: boolean,
needsFallback?: boolean,
): Array<NodeConnectionType | INodeInputConfiguration> {
interface SpecialInput {
type: NodeConnectionType;
filter?: INodeFilter;
displayName: string;
required?: boolean;
}
const getInputData = (
inputs: SpecialInput[],
): Array<NodeConnectionType | INodeInputConfiguration> => {
return inputs.map(({ type, filter, displayName, required }) => {
const input: INodeInputConfiguration = {
type,
displayName,
required,
maxConnections: ['ai_languageModel', 'ai_memory', 'ai_outputParser'].includes(type)
? 1
: undefined,
};
if (filter) {
input.filter = filter;
}
return input;
});
};
let specialInputs: SpecialInput[] = [
{
type: 'ai_languageModel',
displayName: 'Chat Model',
required: true,
filter: {
excludedNodes: [
'@n8n/n8n-nodes-langchain.lmCohere',
'@n8n/n8n-nodes-langchain.lmOllama',
'n8n/n8n-nodes-langchain.lmOpenAi',
'@n8n/n8n-nodes-langchain.lmOpenHuggingFaceInference',
],
},
},
{
type: 'ai_languageModel',
displayName: 'Fallback Model',
required: true,
filter: {
excludedNodes: [
'@n8n/n8n-nodes-langchain.lmCohere',
'@n8n/n8n-nodes-langchain.lmOllama',
'n8n/n8n-nodes-langchain.lmOpenAi',
'@n8n/n8n-nodes-langchain.lmOpenHuggingFaceInference',
],
},
},
{
displayName: 'Memory',
type: 'ai_memory',
},
{
displayName: 'Tool',
type: 'ai_tool',
},
{
displayName: 'Output Parser',
type: 'ai_outputParser',
},
];
if (hasOutputParser === false) {
specialInputs = specialInputs.filter((input) => input.type !== 'ai_outputParser');
}
if (needsFallback === false) {
specialInputs = specialInputs.filter((input) => input.displayName !== 'Fallback Model');
}
// Note cannot use NodeConnectionType.Main
// otherwise expression won't evaluate correctly on the FE
const mainInputs = hasMainInput ? ['main' as NodeConnectionType] : [];
return [...mainInputs, ...getInputData(specialInputs)];
}