fix(core): Prevent duplicate nodeExecuteBefore events for agent nodes #20726
+97
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes agent nodes showing stuck spinner in the UI due to duplicate
nodeExecuteBefore
events.Problem: When AI agent nodes pause execution to run tool nodes and then resume with tool results, they were emitting
nodeExecuteBefore
twice (initial + resume) butnodeExecuteAfter
only once. This caused the frontend's execution tracking queue to become unbalanced, leaving spinners stuck in "executing" state.AI-1414-before.mp4
Solution: Skip the
nodeExecuteBefore
hook when an agent node resumes execution after tool completion by setting and checking anodeWasResumed
metadata flag.AI-1414-after.mp4
Key changes:
nodeWasResumed
flag toITaskMetadata
interface (optional for backward compatibility)handleRequest()
inrequests-response.ts
to setnodeWasResumed: true
when re-scheduling agent nodeworkflow-execute.ts
to skipnodeExecuteBefore
hook ifnodeWasResumed
is truenodeWasResumed
andpreserveSourceOverwrite
propertiesRelated Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/AI-1414
Review / Merge checklist
Docs updated or follow-up ticket createdPR Labeled withrelease/backport
(if urgent fix needed)