Error with tool accessing previous nodes

Describe the problem/error/question

When using a tool with the Tools agent (everything is using latest n8n and nodes) I get an error referencing previous nodes. Even when the node shows that the variable is green and correctly references the correct data, the workflow errors.

What is the error message (if any)?

connect “HTTP Request4” to “set_env1”
However they are clearly connected and the variable resolves correctly.

Please share your workflow

Share the output returned by the last node

Error in sub-node ‘HTTP Request4’

Information on your n8n setup

  • n8n version: Version 1.86.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

hello @skoopadmin

try with that syntax for the HTTP node:
{{ $("set_env1").last().json["test_var"] }}

ok that worked, do you know why this syntax doesnt work here?
{{ $node[“set_env1”].json[“test_var”] }}

it may not work if you have mote than 1 item outputted via the AI tool. Because the syntax you were using can be rewritten to {{ $("set_env1").item.json["test_var"] }} (your version is a legacy syntax for this one) and it won’t work if the AI tool node (or any node in-between) have more than 1 items, while the set_env1 node has only 1 item, because it will raise an incompatibility issue ( items in these nodes can’t be linked due to the different amount)