I have a POST node starting a deep research request. The reason i am using the HTTP node and not the built in OpenAI nodes is because deep research uses different API endpoint which those nodes don’t support yet.
since deep research takes a while I have to poll it after a wait node to see if it’s done.
The issue i run into is that after the IF node (where it’s completed or not) i loop it back to do it again, but the next node creates a new item from the if node.
I understand why that is but couldn’t figure out how do make it keep only 1 item.
I’ve tried:
“Limit” node with “keep last” and “execute once” right after wait node (and if node)
“filter” node, to filter out only 0th index item
“Code” node (to do the same thing)
“merge” node, which was almost working but i couldn’t get it to work (maybe the solution?)
welcoming any possible help i could get here. I likely did one of these solutions wrong so I don’t mind trying it again with guidance.
Insert a Loop Over Items node after Wait 10s2, Type: SplitInBatches, Batch size: 1, and Activate Reset with this expression: {{ $prevNode.name === "Check Completed" }}
Connect the Loop to the Code node (since it filters to the last item in the array).
Or remove the Code node and connect directly to Poll Status if you’re already using a Loop with a batch size of 1.
Make sure only 1 item travels in each iteration.
The Loop ensures that n8n doesn’t accumulate items from previous polling cycles.
1- Use loop elements with a batch size of 1
This ensures that only one element is processed per iteration, avoiding unnecessary accumulation.
2- Enable Conditional Reset
Define an expression like this:
{{ $prevNode.name === "Check Completed" && !$node["Loop Items"].context.noItemsLeft }}
This way, the loop restarts only if there are still items to process, avoiding eternal loops.
3- Use context.noItemsLeft to control the exit
An IF node can stop the loop when:
{{$node[“Loop Items”].context.noItemsLeft}}
returns true, indicating that there are no more pending items.
[Check Completed?]
→ Yes → continue end of flow
→ No → return to the loop (conditional reset)
I want to have only 1 item in the workflow, i just need to keep checking whether the previous POST call has been completed or not. Once it returns “status == completed” then we move on to the next step.
but the way it is right now it just keeps accumulating items, which also doesn’t le me do if check properly since i’d need to change the reference to data to the last output and idk how i would even do that.
(it needs to check the last GET call for the status)