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,124 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import path from 'node:path';
import type { WorkflowTestData } from 'n8n-workflow';
// CI has cold-start overhead on the first test (coverage instrumentation, module loading)
jest.setTimeout(10_000);
/**
* Helper to create a standard OpenAI chat completion response.
*/
function chatCompletionResponse(content: string) {
return {
id: 'chatcmpl-test',
object: 'chat.completion',
created: 1700000000,
model: 'gpt-4o-mini',
choices: [
{
index: 0,
message: { role: 'assistant', content },
finish_reason: 'stop',
},
],
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
};
}
/**
* Helper to create an OpenAI chat completion response with tool calls.
*/
function toolCallResponse(toolCalls: Array<{ id: string; name: string; arguments: string }>) {
return {
id: 'chatcmpl-test',
object: 'chat.completion',
created: 1700000000,
model: 'gpt-4o-mini',
choices: [
{
index: 0,
message: {
role: 'assistant',
content: null,
tool_calls: toolCalls.map((tc) => ({
id: tc.id,
type: 'function',
function: {
name: tc.name,
arguments: tc.arguments,
},
})),
},
finish_reason: 'tool_calls',
},
],
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
};
}
describe('AgentTool V3 Integration', () => {
const baseUrl = 'https://api.openai.com';
const credentials = {
openAiApi: {
apiKey: 'test-api-key',
url: `${baseUrl}/v1`,
},
};
const testHarness = new NodeTestHarness({
additionalPackagePaths: [path.dirname(require.resolve('n8n-nodes-base'))],
});
describe('Agent as Tool', () => {
const testData: WorkflowTestData = {
description: 'should execute sub-agent tool and return parent final answer',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-tool-v3-basic.json'),
},
output: {
nodeData: {
'Parent Agent': [
[
{
json: {
output: '2+2 equals 4.',
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: toolCallResponse([
{
id: 'call_1',
name: 'SubAgent',
arguments: JSON.stringify({ input: 'What is 2+2?' }),
},
]),
},
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('2+2 equals 4.'),
},
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('2+2 equals 4.'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
});
@@ -0,0 +1,503 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import path from 'node:path';
import type { WorkflowTestData } from 'n8n-workflow';
// CI has cold-start overhead on the first test (coverage instrumentation, module loading)
jest.setTimeout(10_000);
/**
* Helper to create a standard OpenAI chat completion response.
*/
function chatCompletionResponse(content: string) {
return {
id: 'chatcmpl-test',
object: 'chat.completion',
created: 1700000000,
model: 'gpt-4o-mini',
choices: [
{
index: 0,
message: { role: 'assistant', content },
finish_reason: 'stop',
},
],
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
};
}
/**
* Helper to create an OpenAI chat completion response with tool calls.
*/
function toolCallResponse(toolCalls: Array<{ id: string; name: string; arguments: string }>) {
return {
id: 'chatcmpl-test',
object: 'chat.completion',
created: 1700000000,
model: 'gpt-4o-mini',
choices: [
{
index: 0,
message: {
role: 'assistant',
content: null,
tool_calls: toolCalls.map((tc) => ({
id: tc.id,
type: 'function',
function: {
name: tc.name,
arguments: tc.arguments,
},
})),
},
finish_reason: 'tool_calls',
},
],
usage: { prompt_tokens: 10, completion_tokens: 5, total_tokens: 15 },
};
}
describe('Agent V3 Integration', () => {
const baseUrl = 'https://api.openai.com';
const credentials = {
openAiApi: {
apiKey: 'test-api-key',
url: `${baseUrl}/v1`,
},
};
const testHarness = new NodeTestHarness({
additionalPackagePaths: [path.dirname(require.resolve('n8n-nodes-base'))],
});
describe('Basic Completion', () => {
const testData: WorkflowTestData = {
description: 'should return basic completion from Agent V3',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-basic.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: 'Hi there!',
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('Hi there!'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Tool Calling Flow', () => {
const testData: WorkflowTestData = {
description: 'should execute tool call and return final answer',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-with-tool.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: '5 times 5 equals 25.',
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: toolCallResponse([
{
id: 'call_1',
name: 'Calculator',
arguments: JSON.stringify({ input: '5*5' }),
},
]),
},
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('5 times 5 equals 25.'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Custom System Message', () => {
const testData: WorkflowTestData = {
description: 'should pass system message to model',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-system-message.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: 'Ahoy there, matey!',
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('Ahoy there, matey!'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Auto Prompt Type', () => {
const testData: WorkflowTestData = {
description: 'should read prompt from chatInput field when promptType is auto',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-auto-prompt.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: 'Hi from auto!',
},
},
],
],
},
},
trigger: {
mode: 'trigger',
input: { json: { chatInput: 'Hello!' } },
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('Hi from auto!'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Fallback Model', () => {
const testData: WorkflowTestData = {
description: 'should use fallback model when primary fails',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-fallback-model.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: 'Hello from fallback!',
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 400,
responseBody: {
error: {
message: 'Bad request',
type: 'invalid_request_error',
code: null,
},
},
},
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('Hello from fallback!'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Output Parser', () => {
const testData: WorkflowTestData = {
description: 'should parse structured output via format_final_json_response tool',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-output-parser.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: {
state: 'California',
cities: ['Los Angeles', 'San Francisco'],
},
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: toolCallResponse([
{
id: 'call_1',
name: 'format_final_json_response',
arguments: JSON.stringify({
output: {
state: 'California',
cities: ['Los Angeles', 'San Francisco'],
},
}),
},
]),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Intermediate Steps', () => {
const testData: WorkflowTestData = {
description: 'should include intermediate steps when returnIntermediateSteps is enabled',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-intermediate-steps.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: '5 times 5 equals 25.',
intermediateSteps: expect.arrayContaining([
expect.objectContaining({
action: expect.objectContaining({
tool: 'Calculator',
toolCallId: 'call_1',
}),
observation: expect.any(String),
}),
]),
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: toolCallResponse([
{
id: 'call_1',
name: 'Calculator',
arguments: JSON.stringify({ input: '5*5' }),
},
]),
},
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('5 times 5 equals 25.'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Continue-on-Fail', () => {
const testData: WorkflowTestData = {
description: 'should return error in output when continueOnFail is enabled',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-continue-on-fail.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
error: expect.any(String),
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 400,
responseBody: {
error: {
message: 'Bad request',
type: 'invalid_request_error',
code: null,
},
},
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Memory Integration', () => {
const testData: WorkflowTestData = {
description: 'should complete successfully with buffer window memory connected',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-memory.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: 'I remember everything!',
},
},
],
],
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('I remember everything!'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
describe('Binary Image Passthrough', () => {
const testData: WorkflowTestData = {
description: 'should complete successfully with binary image data in input',
input: {
workflowData: testHarness.readWorkflowJSON('workflows/agent-v3-binary-images.json'),
},
output: {
nodeData: {
'AI Agent': [
[
{
json: {
output: 'I see a cat in the image.',
},
},
],
],
},
},
trigger: {
mode: 'trigger',
input: {
json: { chatInput: 'What is in this image?' },
binary: {
image: {
mimeType: 'image/png',
data: Buffer.from('fake-png-data').toString('base64'),
fileName: 'test.png',
},
},
},
},
nock: {
baseUrl,
mocks: [
{
method: 'post',
path: '/v1/chat/completions',
statusCode: 200,
responseBody: chatCompletionResponse('I see a cat in the image.'),
},
],
},
};
testHarness.setupTest(testData, { credentials });
});
});
@@ -0,0 +1,123 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Ask the sub agent what 2+2 is"
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "parent-agent-id",
"name": "Parent Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "parent-model-id",
"name": "Parent Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"toolDescription": "A sub agent that can answer math questions",
"promptType": "define",
"text": "={{ $json.input }}"
},
"type": "@n8n/n8n-nodes-langchain.agentTool",
"typeVersion": 3,
"position": [400, 0],
"id": "sub-agent-id",
"name": "SubAgent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [400, 200],
"id": "child-model-id",
"name": "Child Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "Parent Agent",
"type": "main",
"index": 0
}
]
]
},
"Parent Model": {
"ai_languageModel": [
[
{
"node": "Parent Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"SubAgent": {
"ai_tool": [
[
{
"node": "Parent Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Child Model": {
"ai_languageModel": [
[
{
"node": "SubAgent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,76 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "auto"
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
},
"pinData": {
"AI Agent": [
{
"json": {
"output": "Hi from auto!"
}
}
]
}
}
@@ -0,0 +1,77 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Hello!"
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
},
"pinData": {
"AI Agent": [
{
"json": {
"output": "Hi there!"
}
}
]
}
}
@@ -0,0 +1,70 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "auto",
"options": {
"passthroughBinaryImages": true
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,69 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Hello!"
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent",
"onError": "continueRegularOutput"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,110 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Hello!",
"needsFallback": true
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "primary-model-id",
"name": "Primary OpenAI Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [400, 200],
"id": "fallback-model-id",
"name": "Fallback OpenAI Model",
"credentials": {
"openAiApi": {
"id": "456",
"name": "OpenAi account 2"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Primary OpenAI Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Fallback OpenAI Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 1
}
]
]
}
},
"pinData": {
"AI Agent": [
{
"json": {
"output": "Hello from fallback!"
}
}
]
}
}
@@ -0,0 +1,90 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "What is 5 times 5?",
"options": {
"returnIntermediateSteps": true
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
},
{
"parameters": {},
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"typeVersion": 1,
"position": [400, 200],
"id": "calculator-id",
"name": "Calculator"
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Calculator": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,91 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Hello!"
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "test-session",
"contextWindowLength": 5
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.2,
"position": [400, 200],
"id": "memory-id",
"name": "Simple Memory"
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,91 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Tell me about California",
"hasOutputParser": true
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"schemaType": "fromJson",
"jsonSchemaExample": "{\n\t\"state\": \"California\",\n\t\"cities\": [\"Los Angeles\", \"San Francisco\"]\n}"
},
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"typeVersion": 1.3,
"position": [400, 200],
"id": "parser-id",
"name": "Structured Output Parser"
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
}
}
}
@@ -0,0 +1,80 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "Hello!",
"options": {
"systemMessage": "You are a pirate. Always respond in pirate speak."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
},
"pinData": {
"AI Agent": [
{
"json": {
"output": "Ahoy there, matey!"
}
}
]
}
}
@@ -0,0 +1,96 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "trigger-id",
"name": "When clicking 'Execute workflow'"
},
{
"parameters": {
"promptType": "define",
"text": "What is 5 times 5?"
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 3.1,
"position": [220, 0],
"id": "agent-id",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 200],
"id": "model-id",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "123",
"name": "OpenAi account"
}
}
},
{
"parameters": {},
"type": "@n8n/n8n-nodes-langchain.toolCalculator",
"typeVersion": 1,
"position": [400, 200],
"id": "calculator-id",
"name": "Calculator"
}
],
"connections": {
"When clicking 'Execute workflow'": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Calculator": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"pinData": {
"AI Agent": [
{
"json": {
"output": "5 times 5 equals 25."
}
}
]
}
}