diff --git a/packages/integration/src/lib/context/context.state.ts b/packages/integration/src/lib/context/context.state.ts index 03ccbe5a00..e59b2896c1 100644 --- a/packages/integration/src/lib/context/context.state.ts +++ b/packages/integration/src/lib/context/context.state.ts @@ -67,8 +67,10 @@ export class ContextState { tools.forEach(tool => { if (tool.parent) { const parentIndex = tools.findIndex(el => el.name === tool.parent); - tools[parentIndex].children = []; - tools[parentIndex].children.push(tool.name); + if (parentIndex !== -1) { + tools[parentIndex].children = []; + tools[parentIndex].children.push(tool.name); + } } });