Skip to content

Conversation

despairblue
Copy link
Contributor

@despairblue despairblue commented Oct 13, 2025

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) but nodeExecuteAfter 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 a nodeWasResumed metadata flag.

AI-1414-after.mp4

Key changes:

  • Added nodeWasResumed flag to ITaskMetadata interface (optional for backward compatibility)
  • Modified handleRequest() in requests-response.ts to set nodeWasResumed: true when re-scheduling agent node
  • Updated workflow-execute.ts to skip nodeExecuteBefore hook if nodeWasResumed is true
  • Added test verifying correct 1:1 pairing of before/after events
  • Added JSDoc for both nodeWasResumed and preserveSourceOverwrite properties

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/AI-1414

Review / Merge checklist

  • PR title and summary are descriptive
  • Docs updated or follow-up ticket created
  • Tests included
  • PR Labeled with release/backport (if urgent fix needed)

Fix agent nodes showing stuck spinner due to duplicate nodeExecuteBefore
events. When agents pause execution to run tools and then resume, they
were emitting nodeExecuteBefore twice but nodeExecuteAfter only once,
causing frontend execution tracking to become unbalanced.

Solution: Skip nodeExecuteBefore hook when agent node resumes after
tool execution by setting and checking nodeWasResumed metadata flag.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@despairblue despairblue force-pushed the ai-1414-agent-incorrectly-displays-executing-state-after-using-tools branch from 427ab57 to 6e29a97 Compare October 13, 2025 15:43
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Oct 13, 2025
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@despairblue despairblue marked this pull request as ready for review October 13, 2025 16:23
@despairblue despairblue requested a review from schrothbn October 13, 2025 16:23
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant