Problem in node ‘AI Agent‘ Cannot read properties of null (reading 'length')

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
```{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "085d0330-78b5-4bb4-8f16-27ba41d1b30f",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "url": "https://hnrss.org/newest?points=100",
        "options": {}
      },
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1.2,
      "position": [
        176,
        0
      ],
      "id": "7363f273-abc7-449f-b728-28d776edef94",
      "name": "RSS Read"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        384,
        0
      ],
      "id": "b73f53ad-9691-44f7-a934-317ecb2d93e0",
      "name": "Limit"
    },
    {
      "parameters": {
        "resource": "Default",
        "operation": "Scrape A Url And Get Its Content",
        "url": "={{ $json.link }}",
        "requestOptions": {}
      },
      "type": "n8n-nodes-firecrawl.fireCrawl",
      "typeVersion": 1,
      "position": [
        592,
        0
      ],
      "id": "56f5d43f-925d-4c76-8bb8-d0f02636cf62",
      "name": "Scrape A Url And Get Its Content",
      "credentials": {
        "fireCrawlApi": {
          "id": "GSJmLsDbn28cI4cK",
          "name": "FireCrawl account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.data }}",
        "options": {
          "systemMessage": "You are a news assistant, helping me organize the data I crawled from the website into a news briefing"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.1,
      "position": [
        800,
        0
      ],
      "id": "127db1ce-6016-433f-a182-c6c62959d326",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "deepseek-chat",
          "mode": "id"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        672,
        208
      ],
      "id": "839020f8-b9dd-488e-8731-22a6ae02bef1",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "Ds4d80pqCN3idkhY",
          "name": "OpenAi account"
        }
      }
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "RSS Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        [
          {
            "node": "Scrape A Url And Get Its Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape A Url And Get Its Content": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "4d9d5293b04b71e8d9ad13b6eed816f30e2b49cb5172625bf728aacef6f6ee46"
  }
}

## Share the output returned by the last node
<!-- If you need help with data transformations, please also share your expected output. -->

## Information on your n8n setup
- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**
2 Likes

Hi @3426485300

Can you embed that workflow in a preformatted text block? Then we can download the workflow and troubleshoot it.

I have the same problem.

Hey, same issue here with the AI Agent and the OpenAI Chat Model.

I have the same issue except mine is occurs when I try to use LiteLLM Proxy Server (LLM Gateway)

1 Like

same issue with using Open AI chat model with local host model

1 Like

Facing same issue using the AI Agent.

The problem is solved.
By using lastest version of vllm to serve the local model. Try pulling vllm/vllm-openai:latest

i have the same issue. using openai chat model, models are served by litellm.

the problem is also when i use the community litellm nodes

1 Like

yes, I confirm the issue with Azure and LiteLLM models

Same problem with LiteLLM node for model.
ERROR: Problem in node ‘AI Agent‘ Cannot read properties of null (reading 'length')

Any indications of a fix??

Updating LiteLLM resolved the issue on our side. Is it possible we have auto updates active that the problem occured “suddenly” ? We are running n8n self-hosted on Azure via container apps, but I am not aware that we did set auto-updates flag or similiar.

Hey @thomasender, how are you? How’s the performance of LiteLLM over there? I had disabled it because everything stopped working in production, and I didn’t have time to check and fix it. I just switched back to OpenAI’s default. But I’d like to reactivate the application. Do I just need to update it? Was the issue on the n8n side or LiteLLM’s side? Sorry for all the questions, and thanks for the feedback!

the same issue here with the AI Agent and using the OpenAI Chat Model but using local llm.