fix: Filter out disabled AI Agent tool parents when mapping connected tools#28743
Closed
Dom-Tursini wants to merge 1 commit inton8n-io:masterfrom
Closed
fix: Filter out disabled AI Agent tool parents when mapping connected tools#28743Dom-Tursini wants to merge 1 commit inton8n-io:masterfrom
Dom-Tursini wants to merge 1 commit inton8n-io:masterfrom
Conversation
9f32c74 to
7a6d889
Compare
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant Agent as AI Agent Node
participant Helper as getConnectedTools()
participant Context as n8n Workflow Context
Note over Agent,Context: Tool Connection Mapping Flow
Agent->>Helper: Invoke tool resolution
Helper->>Context: getInputConnectionData(AiTool)
Context-->>Helper: toolkitConnections (Active tool objects)
Helper->>Context: getParentNodes(currentNode, AiTool)
Context-->>Helper: parentNodes (All connected nodes)
rect rgb(240, 240, 240)
Note over Helper: Fix: Prevent index desync
Helper->>Helper: NEW: Filter out nodes where disabled === true
end
loop For each tool in toolkitConnections
Helper->>Helper: CHANGED: Map tool to parentNode by matching index
Note right of Helper: Correlation relies on identical list lengths
end
Helper-->>Agent: Return tools with correct sourceNodeName metadata
7a6d889 to
ec053b8
Compare
d0bef14 to
08bee6d
Compare
e3eeddb to
2fbfe35
Compare
86472c8 to
66b1602
Compare
66b1602 to
4759491
Compare
Author
|
Closing this as the fix has been merged via #29460 by @schrothbn . I’m glad to see the index-desync I identified here was resolved using the same logic. Hopefully, the regression tests I included here can still be useful for the core team. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This fixes a tool/source-node desync in getConnectedTools() for AI Agent tool connections when disabled AI tool nodes remain connected.
Previously,
toolkitConnectionsexcluded disabled AI tool nodes, whileparentNodesstill included them. Because the helper correlates both arrays by index, disabling any AI tool node caused later tools to receive the wrongsourceNodeName.This change filters disabled nodes out of
parentNodesso both arrays use the same active-node set and stay index-aligned.A regression test was added to cover the case where a disabled tool node appears between active tool connections.
How to test:
sourceNodeName.pnpm test -- utils/tests/helpers.test.ts --runInBandinpackages/@n8n/nodes-langchain.Related Linear tickets, Github issues, and Community forum posts
#26356
Review / Merge checklist
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)