I’m running into an issue in n8n when wiring multiple inputs into the AI Agent node. I have two schedules (Schedule Trigger and Schedule Trigger1) that each go through a function (f1 and f2) before reaching the AI Agent. In the AI Agent’s Prompt (User Message) field, I’m referencing both: {{ $(‘f1’).item.json.test1 }} {{ $(‘f2’).item.json.test2 }} The problem: If I only trigger Schedule Trigger1 → f2, I get this error: > This makes sense because f1 never ran in that execution, so the AI Agent doesn’t have any data to pull from it. Basically, n8n throws this error any time you reference a node that didn’t execute earlier in the run.
Has anyone found a cleaner way to handle “optional” node inputs in n8n AI Agent prompts without getting this error?
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.)
Share the output returned by the last node
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:


