# Error with tool accessing previous nodes

**URL:** <https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029>\
**Category:** Questions\
**Created:** [April 9, 2025, 3:14pm UTC](https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029 "2025-04-09T15:14:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skoopadmin](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@skoopadmin](https://community.n8n.io/u/skoopadmin)\
**Post date:** [April 9, 2025, 3:14pm UTC](https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029/1 "2025-04-09T15:14:14Z")

</div>

## 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**

---

<div class="post-metadata">

**Author:** ![barn4k](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/barn4k/32/8170_2.png) [@barn4k](https://community.n8n.io/u/barn4k)\
**Post date:** [April 9, 2025, 7:27pm UTC](https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029/2 "2025-04-09T19:27:55Z")

</div>

hello @skoopadmin

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

---

<div class="post-metadata">

**Author:** ![skoopadmin](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@skoopadmin](https://community.n8n.io/u/skoopadmin)\
**Post date:** [April 12, 2025, 4:27pm UTC](https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029/3 "2025-04-12T16:27:45Z")

</div>

> [@barn4k](#):
>
> `{{ $("set_env1").last().json["test_var"] }}`

ok that worked, do you know why this syntax doesnt work here?  
{{ $node[“set\_env1”].json[“test\_var”] }}

---

<div class="post-metadata">

**Author:** ![barn4k](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/barn4k/32/8170_2.png) [@barn4k](https://community.n8n.io/u/barn4k)\
**Post date:** [April 15, 2025, 2:19pm UTC](https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029/4 "2025-04-15T14:19:18Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [July 14, 2025, 2:19pm UTC](https://community.n8n.io/t/error-with-tool-accessing-previous-nodes/99029/5 "2025-07-14T14:19:50Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
