{
“nodes”: [
{
“parameters”: {
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“typeVersion”: 1.3,
“position”: [
416,
512
],
“id”: “0cc0fca8-eee0-4f0e-b472-b6fd179ffe68”,
“name”: “When chat message received”,
“webhookId”: “e8c7cb32-d9b6-4691-a135-e0d91367a8ac”
},
{
“parameters”: {
“agent”: “conversationalAgent”,
“promptType”: “define”,
“text”: "=Reply to {{ $json.chatInput }} with an appropriate message. ",
“hasOutputParser”: true,
“options”: {
“systemMessage”: “Assistant is a large language model trained by OpenAI.\n\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.”
}
},
“id”: “3f4c3861-f7b1-47d7-9561-ff4468d1c998”,
“name”: “AI Agent1”,
“type”: “@n8n/n8n-nodes-langchain.agent”,
“maxTries”: 5,
“position”: [
704,
528
],
“retryOnFail”: false,
“typeVersion”: 1.7,
“alwaysOutputData”: true,
“waitBetweenTries”: null
},
{
“parameters”: {
“model”: {
“__rl”: true,
“mode”: “list”,
“value”: “gpt-4.1-mini”
},
“options”: {}
},
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1.2,
“position”: [
560,
704
],
“id”: “d7f931f3-a82c-4d1c-af4e-fb7f18579ec3”,
“name”: “OpenAI Chat Model”,
“credentials”: {
“openAiApi”: {
“id”: “vqLjzHWd6iQrYPHS”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {},
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“typeVersion”: 1.3,
“position”: [
688,
736
],
“id”: “098e54ee-4630-429b-91eb-812df03a364a”,
“name”: “Simple Memory”
}
],
“connections”: {
“When chat message received”: {
“main”: [
[
{
“node”: “AI Agent1”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Agent1”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Simple Memory”: {
“ai_memory”: [
[
{
“node”: “AI Agent1”,
“type”: “ai_memory”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “037fe526661fa82c41d79c6a3e56d1f30e26eef15df35ff74fb073e25b3e9258”
}
}
I built a simple workflow in n8n:
-
It starts with When chat message received.
-
Then the message goes to an AI Agent.
-
The AI Agent is connected to OpenAI Chat Model and Simple Memory.
The issue:
-
When I send a message to the AI Agent, sometimes it loses connection to the server and throws an error.
-
After that, the workflow continues but the Agent does not use the Chat Model at all – the output is empty as if the language model was skipped.
What I need help with:
-
Why does the Agent sometimes skip the OpenAI Chat Model and return no result?
-
Are there any specific settings to make sure the Agent always uses the language model?
-
How can I fix the “lost connection to server” problem that causes the workflow to fail intermittently?