I am trying to create a simple agent that analyzes news data to make trading decisions.
{“nodes”: [{“parameters”: {“promptType”: “define”,“text”: “={{ $json }}”,“options”: {“systemMessage”: “You are an agent designed to analyze information based on recent currency exchange rates and cross reference against recent news headlines. From this you must present an analysis for recommended Forex trades”,“enableStreaming”: false}},“type”: “/n8n-nodes-langchain.agent”,“typeVersion”: 2.2,“position”: [-144,-416],“id”: “f5949a86-8683-4923-8115-c948aaf7f15a”,“name”: “AI Agent”},{“parameters”: {“toolDescription”: “Request News Headlines from Relevant Countries”,“url”: “https://newsapi.org/v2/top-headlines”,“sendQuery”: true,“queryParameters”: {“parameters”: [{“name”: “apiKey”,“value”: “******************”},{“name”: “country”,“value”: “={{ /n8n-auto-generated-fromAI-override/ $fromAI(‘parameters1_Value’, The 2-letter ISO 3166-1 code of the country you want to get headlines for. Possible options: us. Note: you can't mix this param with the sources param., ‘string’) }}”},{“name”: “category”,“value”: “={{ /n8n-auto-generated-fromAI-override/ $fromAI(‘parameters3_Value’, The category you want to get headlines for. Possible options: businessentertainmentgeneralhealthsciencesportstechnology. Note: you can't mix this param with the sources param., ‘string’) }}”}]},“options”: {}},“type”: “n8n-nodes-base.httpRequestTool”,“typeVersion”: 4.2,“position”: [64,-192],“id”: “030c7a32-606a-47b6-8048-7e7433c5643d”,“name”: “HTTP Request”},{“parameters”: {“model”: {“__rl”: true,“mode”: “list”,“value”: “gpt-4.1-mini”},“options”: {}},“type”: “/n8n-nodes-langchain.lmChatOpenAi”,“typeVersion”: 1.2,“position”: [320,-304],“id”: “ce4f4f78-68b4-4bba-90c5-1d6f28daea00”,“name”: “OpenAI Chat Model”,“credentials”: {“openAiApi”: {“id”: “*******”,“name”: “OpenAi Agent”}}},{“parameters”: {“sessionIdType”: “customKey”,“sessionKey”: “agentonetwo”},“type”: “/n8n-nodes-langchain.memoryBufferWindow”,“typeVersion”: 1.3,“position”: [-144,-208],“id”: “d8860e84-e168-49b9-9f74-ab05e1518d96”,“name”: “Simple Memory”}],“connections”: {“AI Agent”: {“main”: [,]},“HTTP Request”: {“ai_tool”: [[{“node”: “AI Agent”,“type”: “ai_tool”,“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}]]}},“pinData”: {},“meta”: {“templateCredsSetupCompleted”: true,“instanceId”: “498941ed9d693156b9ac14f58af73b6ad7b76737267a81cf5d7c6d2841eb628f”}}
This agent appears to be on the verge of producing a meaningful output, but then fails on the last turn:
Run
“openai_api_key”: {
“lc”: 1,
“type”: “secret”,
“id”: [
“OPENAI_API_KEY”
]
},
“model”: “gpt-4.1-mini”,
“timeout”: 60000,
“max_retries”: 2,
“configuration”: {
“baseURL”: “https://api.openai.com/v1”,
“fetchOptions”: {
}
},
“model_kwargs”: {
}
}
}
]
**Cannot read properties of undefined (reading ‘map’)
I really do not understand why this is happening. It seems I am not alone in encountering errors like this, but no-one else has been able to come up with a meaningful solution**


