fix(core): Skip disabled tool nodes when mapping AI Agent tool sources (#29460)

This commit is contained in:
Benjamin Schroth
2026-05-05 17:35:13 +02:00
committed by GitHub
parent 3a967fc041
commit bd7eeb7bc8
2 changed files with 41 additions and 5 deletions
@@ -200,13 +200,17 @@ export const getConnectedTools = async (
0,
)) as SupplyDataToolResponse[];
// Get parent nodes to map toolkits to their source nodes
// Get parent nodes to map toolkits to their source nodes.
// getInputConnectionData filters out disabled nodes, so parents must be filtered
// the same way to keep the index alignment between toolkitConnections and parentNodes.
const parentNodes =
'getParentNodes' in ctx
? ctx.getParentNodes(ctx.getNode().name, {
connectionType: NodeConnectionTypes.AiTool,
depth: 1,
})
? ctx
.getParentNodes(ctx.getNode().name, {
connectionType: NodeConnectionTypes.AiTool,
depth: 1,
})
.filter((node) => !node.disabled)
: [];
const connectedTools = (toolkitConnections ?? [])
@@ -341,6 +341,38 @@ describe('getConnectedTools', () => {
sourceNodeName: 'MCP Client Tool',
});
});
it('should map source node names correctly when a disabled tool node is still connected', async () => {
// getParentNodes returns ALL parents including disabled ones,
// while getInputConnectionData filters disabled nodes out.
// getConnectedTools must skip disabled parents to keep the index in sync.
const mockParentNodes = [
{ name: 'Tool Alpha', disabled: false },
{ name: 'Tool Bravo', disabled: true },
{ name: 'Tool Charlie', disabled: false },
];
const mockTools = [
{ name: 'alpha', description: 'desc-alpha' },
{ name: 'charlie', description: 'desc-charlie' },
];
mockExecuteFunctions.getInputConnectionData = jest.fn().mockResolvedValue(mockTools);
mockExecuteFunctions.getParentNodes = jest.fn().mockReturnValue(mockParentNodes);
const tools = await getConnectedTools(mockExecuteFunctions, false);
expect(tools).toHaveLength(2);
expect(tools[0].name).toBe('alpha');
expect(tools[0].metadata).toEqual({
isFromToolkit: false,
sourceNodeName: 'Tool Alpha',
});
expect(tools[1].name).toBe('charlie');
expect(tools[1].metadata).toEqual({
isFromToolkit: false,
sourceNodeName: 'Tool Charlie',
});
});
});
describe('unwrapNestedOutput', () => {