Immutable solution version
n8n AI Agent node fails with "Cannot read properties of null (reading 'length')" after upgrade to 1.103.1
Complete solution
What caused "n8n AI Agent node fails with "Cannot read properties of null (reading 'length')" after upgrade to 1.103.1" and the fix that actually worked. Distilled from the thread where it was verified.
n8n AI Agent node fails with "Cannot read properties of null (reading 'length')" after upgrade to 1.103.1
What was going on
After upgrading to n8n 1.103.1, my AI Agent node connected to an OpenAI model breaks instantly with "Cannot read properties of null (reading 'length')". The exact same workflow ran fine on 1.102.4. The error pops up as soon as I add the AI Agent node and hook it up to OpenAI. Reinstalling did not help. Is this a known regression?
The fix that worked
Yes, this was a regression. The error came from a langchainjs bug that n8n pulled in with its dependency bump, not from your workflow. It was fixed upstream in langchainjs v0.3.31 and n8n merged the dependency upgrade in PR #19299, with the fix released in n8n 1.112.0. So the fix is simply to update to 1.112.0 or newer. If you are pinned to an affected version, a workaround several users confirmed is to export your workflow, change the AI Agent node's version from 2.2 to 1.9, and re-import it. Note the trade-off: the 1.9 node version works, but you lose the "AI Agent as tool" capability that came with 2.2, so updating the n8n version is the cleaner fix.
Where this came from
https://github.com/n8n-io/n8n/issues/17522
Evidence
Someone asked: After upgrading to n8n 1.103.1, my AI Agent node connected to an OpenAI model breaks instantly with "Cannot read properties of null (reading 'length')". The exact same workflow ran fine on 1.102.4. The error pops up as soon as I add the AI Agent node and hook it up to OpenAI. Reinstalling did not help. Is this a known regression? The verified resolution: Yes, this was a regression. The error came from a langchainjs bug that n8n pulled in with its dependency bump, not from your workflow. It was fixed upstream in langchainjs v0.3.31 and n8n merged the dependency upgrade in PR #19299, with the fix released in n8n 1.112.0. So the fix is simply to update to 1.112.0 or newer. If you are pinned to an affected version, a workaround several users confirmed is to export your workflow, change the AI Agent node's version from 2.2 to 1.9, and re-import it. Note the trade-off: the 1.9 node version works, but you lose the "AI Agent as tool" capability that came with 2.2, so updating the n8n version is the cleaner fix. Thread: https://vectle.com/threads/thrOMMImsaphbXHg5YGVqk7g
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_04JsDdz1dRHa2MCvirFPPA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">n8n AI Agent node fails with "Cannot read properties of null (reading 'length')" after upgrade to 1.103.1 <span>— Vectle</span></a>