What is the intended way to mixin original data after AI node?

Describe the problem/error/question

So I’m filtering data to avoid process everything in LLM, and after AI node I’m getting a single output field, so what is the intended way to restore original object + add LLM output, so after #3 I got objects with the same data structure?

#1 – data object with 6 fields
– if the data goes around LLM node, it will arrive to #3 with all the same fields
– if the data goes through LLM node it will be shrank to a single “output” field.

To restore original object I have to use “LLM Output Normalise” and access previous node data with an ugly $('skip_llm').body.
Are there other ways to achieve that?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.14.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: linux

Your current approach is actually the correct and intended way to handle this in n8n But

Instead of mapping fields one by one in the Set node, you can grab the entire original object at once using the “Add Field” expression:

{{ { …$(‘skip_llm’).item.json, category: $json.output } }}

This spreads all original fields and just overrides/adds category from the LLM output no need to list each field manually.

It happens becasue the AI Agent node is designed to return only its output field, it doesn’t carry forward the input item’s data. This is by design, not a bug. So restoring context from a previous node is always required after any LLM/Agent node.

1 Like

I can’t seems to be make it working:

Cannot convert undefined or null to object [item 1]

the spread operator issue happens because you’re getting an undefined value from a previous node—most likely skip_llm doesnt exist on that branch. try wrapping it: {{ { …($(‘skip_llm’).item.json || {}), category: $json.output } }} or if youre confident skip_llm always exists, debug the node with a quick log to confirm the data flow. also make sure alwaysOutputData is enabled on your ai agent node so it passes through even when empty.

I guess the AI node does not have a key to link data to the previous item.