-
Notifications
You must be signed in to change notification settings - Fork 53.7k
Description
Bug Description
When an agent is used as tool with main agent and it's connected to a postgres chat memory(same one as the parent agent), the postgres erros with the following
"Missing output data
Expected output #0 from node AI Agent"
This used to work with v2 just fine, but now i want to use the new options of v3.
To Reproduce
Copy the following workflow and run it:
{ "nodes": [ { "parameters": { "httpMethod": "POST", "path": "legal-assistant-prompt", "responseMode": "streaming", "options": { "allowedOrigins": "*", "ignoreBots": false } }, "type": "n8n-nodes-base.webhook", "typeVersion": 2.1, "position": [ -1408, 64 ], "id": "1eb7592a-2a80-41e9-8c32-fe66c9d13fee", "name": "Webhook", "webhookId": "d9896607-daf9-4f14-93a3-fe156415f5ef" }, { "parameters": { "assignments": { "assignments": [ { "id": "a183bd5f-6ba2-49a9-8278-98cf959463c3", "name": "chat_id", "value": "={{ $json.body.chat_id }}", "type": "string" }, { "id": "5d6a1eae-1bef-476d-87fb-92314647be68", "name": "systemPrompt", "value": "={{ $json.body.systemPrompt }}", "type": "string" }, { "id": "96efc04d-ec1e-4a4e-99af-641b6f099c9f", "name": "message_id", "value": "={{ $json.body.message_id}}", "type": "string" }, { "id": "96cba381-c4b8-4556-addb-a93e38e5b402", "name": "sessionId", "value": "={{ $json.body.sessionId}}", "type": "string" }, { "id": "04a43ca8-20ee-4061-af52-a40d2f486c64", "name": "chatInput", "value": "={{ $json.body.chatInput}}", "type": "string" }, { "id": "e7854f6e-8128-4acc-9448-aa06a4b45403", "name": "gitBranch", "value": "develop", "type": "string" }, { "id": "678ba185-1b5a-4694-bc59-5f3c65f9b8c3", "name": "=conversationHistory", "value": "={{ $json.body.conversationHistory?.toJsonString() }}", "type": "string" }, { "id": "772d2658-3444-4fba-b1a9-6df0864a383a", "name": "streaming", "value": "={{ $('Webhook').params.responseMode.toLowerCase() === \"streaming\" }}", "type": "boolean" } ] }, "options": { "ignoreConversionErrors": true, "dotNotation": true } }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -1184, 64 ], "id": "6a969c27-a8a5-4f06-ab58-e6614c6e9b65", "name": "Edit Fields" }, { "parameters": { "toolDescription": "phase 1 - validator AI Agent that given an input, it can validate and check if the input is valid. \nIf input is invalid, it returns validity status and results of the check.\n\nOutput structure:\n{\n \"Valid\": \"true|false\",\n \"Results\": \"Actual Results\"\n}", "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', The user input to be validated goes here, 'string') }}", "options": { "systemMessage": "=return \"{\n \"Valid\": \"true|false\",\n \"Results\": \"valid results\"\n}\"" } }, "type": "@n8n/n8n-nodes-langchain.agentTool", "typeVersion": 2.2, "position": [ -1072, 288 ], "id": "b5c0fac9-59cf-4e4e-a3c2-71952c81967e", "name": "phase 1 - validator Tool" }, { "parameters": { "model": "gpt-4o", "options": { "temperature": 0.7 } }, "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi", "typeVersion": 1, "position": [ -704, 816 ], "id": "b8e6d296-b790-4ae7-acfa-b1b1c263999d", "name": "4o", "credentials": { "azureOpenAiApi": { "id": "eY8uWGOV2iXMDtlJ", "name": "Azure Open AI account" } } }, { "parameters": { "sessionIdType": "customKey", "sessionKey": "={{ $('Edit Fields').item.json.sessionId }}", "contextWindowLength": 15 }, "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat", "typeVersion": 1.3, "position": [ -928, 816 ], "id": "3b45ea38-cb52-4d14-b0be-d3ece32f1136", "name": "Postgres Chat Memory1", "credentials": { "postgres": { "id": "pGmPEnGHHHSlldbM", "name": "Postgres account" } } }, { "parameters": { "toolDescription": "Retrieve a Specific Ruling\n", "url": "=http://www.7timer.info/bin/api.pl?lon=113.17&lat=23.09&product=astro&output=xml", "sendQuery": true, "queryParameters": { "parameters": [ {} ] }, "options": {} }, "type": "n8n-nodes-base.httpRequestTool", "typeVersion": 4.2, "position": [ -544, 560 ], "id": "09f9738a-03e7-44c7-850d-ea7fc06a4a36", "name": "Retrieve a Specific Ruling tool" }, { "parameters": { "toolDescription": "phase 2 - research AI Agent that given an input, it can take it and research further about the topic to find relevant resources like from rechtspraak.nl etc\n\nOutput structure:\n{\n \"Valid\": \"true|false\",\n \"Results\": \"Actual Results\"\n}", "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Prompt__User_Message_', ``, 'string') }}", "options": { "systemMessage": "=return \"{\n \"Valid\": \"true|false\",\n \"Results\": \"valid results\"\n}\"", "returnIntermediateSteps": false, "enableStreaming": true } }, "type": "@n8n/n8n-nodes-langchain.agentTool", "typeVersion": 3, "position": [ -704, 304 ], "id": "835ae956-a5a9-4236-9df5-163878615b16", "name": "phase 2 - research tool" }, { "parameters": { "promptType": "define", "text": "=User query:\n{{ $('Edit Fields').item.json.chatInput }}", "options": { "systemMessage": "=Call \"phase 1 - validator Tool\" first then\nCall \"phase 2 - research tool\"", "returnIntermediateSteps": true, "enableStreaming": "={{ $('Edit Fields').item.json.streaming }}" } }, "type": "@n8n/n8n-nodes-langchain.agent", "typeVersion": 3, "position": [ -928, 64 ], "id": "534b1a7d-291d-49d3-976d-139f5d061542", "name": "AI Agent", "alwaysOutputData": false, "onError": "continueErrorOutput" } ], "connections": { "Webhook": { "main": [ [ { "node": "Edit Fields", "type": "main", "index": 0 } ] ] }, "Edit Fields": { "main": [ [ { "node": "AI Agent", "type": "main", "index": 0 } ] ] }, "phase 1 - validator Tool": { "ai_tool": [ [ { "node": "AI Agent", "type": "ai_tool", "index": 0 } ] ] }, "4o": { "ai_languageModel": [ [ { "node": "phase 1 - validator Tool", "type": "ai_languageModel", "index": 0 }, { "node": "phase 2 - research tool", "type": "ai_languageModel", "index": 0 }, { "node": "AI Agent", "type": "ai_languageModel", "index": 0 } ] ] }, "Postgres Chat Memory1": { "ai_memory": [ [ { "node": "phase 1 - validator Tool", "type": "ai_memory", "index": 0 }, { "node": "phase 2 - research tool", "type": "ai_memory", "index": 0 }, { "node": "AI Agent", "type": "ai_memory", "index": 0 } ] ] }, "Retrieve a Specific Ruling tool": { "ai_tool": [ [ { "node": "phase 2 - research tool", "type": "ai_tool", "index": 0 } ] ] }, "phase 2 - research tool": { "ai_tool": [ [ { "node": "AI Agent", "type": "ai_tool", "index": 0 } ] ] }, "AI Agent": { "main": [ [], [] ] } }, "pinData": { "Webhook": [ { "headers": { "host": "", "user-agent": "Python/3.11 aiohttp/3.12.15", "content-length": "1784", "accept": "*/*", "accept-encoding": "gzip, deflate, br", "content-type": "application/json", "x-forwarded-for": "3", "x-forwarded-host": "i", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-forwarded-server": "dda6093a6dbc", "x-real-ip": "" }, "params": {}, "query": {}, "body": { "systemPrompt": "", "messages": [], "conversationHistory": [], "currentMessage": "Haal naar analogie van Gerards/Vijverberg de essentie uit de uitspraak en pas toe op deze casus: ik heb voor mijn zzp kantoor een huurovereenkomst gesloten met een bedrijf dat deelkantoren verhuurt en ben daar geinstalleerd op de 3e verdieping. Nu 3 maanden later komt dit bedrijf aan met nieuwe voorwaarden. Ze zeggen dat ik op de 4e verdieping had behoren te zitten voor deze prijs en anders een verhoging van de huurprijs moet accepteren. De 4e verdieping is de zolder en die is erg onaangenaam in klimaat. Ik ben van mening dat ik heb getekend voor de 3e en niet voor de 4e verdieping. Als ik had geweten dat ik op de 4e had moeten zitten was ik de overeenkomst niet aangegaan. Wat moet ik doen?", "chat_id": "7ae419f8-4d8a-4028-9c39", "message_id": "55184fd3-43a5-4394-9b52", "sessionId": "4Js-Q7AZJeInpxIdAAJl", "user_id": "45f12f83-72f8-4240-a9ee", "user_email": "blabla@ggagag.com", "user_name": "blablaba", "user_role": "blablaba", "chatInput": "Haal naar analogie van Gerards/Vijverberg de essentie uit de uitspraak en pas toe op deze casus: ik heb voor mijn zzp kantoor een huurovereenkomst gesloten met een bedrijf dat deelkantoren verhuurt en ben daar geinstalleerd op de 3e verdieping. Nu 3 maanden later komt dit bedrijf aan met nieuwe voorwaarden. Ze zeggen dat ik op de 4e verdieping had behoren te zitten voor deze prijs en anders een verhoging van de huurprijs moet accepteren. De 4e verdieping is de zolder en die is erg onaangenaam in klimaat. Ik ben van mening dat ik heb getekend voor de 3e en niet voor de 4e verdieping. Als ik had geweten dat ik op de 4e had moeten zitten was ik de overeenkomst niet aangegaan. Wat moet ik doen?" }, "webhookUrl": "blabla", "executionMode": "production" } ] }, "meta": { "instanceId": "09f8015d3773f4d8d4b2c0e94b51866ac406015ec52275d627e1461850d766d4" } }
Expected behavior
it should work and read/write history without issues
Debug Info
Debug info
core
- n8nVersion: 2.3.5
- platform: docker (self-hosted)
- nodeJsVersion: 22.21.1
- nodeEnv: production
- database: postgres
- executionMode: regular
- concurrency: -1
- license: enterprise (production)
- consumerId: 3603152f-9e4c-474a-9eea-fd26cef40ed5
storage
- success: all
- error: all
- progress: false
- manual: true
- binaryMode: filesystem
pruning
- enabled: true
- maxAge: 336 hours
- maxCount: 10000 executions
client
- userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/143.0.0.0 safari/537.36 edg/143.0.0.0
- isTouchDevice: false
security
- secureCookie: false
Generated at: 2026-01-15T14:49:30.305Z
Operating System
docker (self-hosted)
n8n Version
2.3.5
Node.js Version
22.21.1
Database
PostgreSQL
Execution mode
main (default)
Hosting
self hosted