From dd1205b9a32fa84df142434e4fd629caa64cca5d Mon Sep 17 00:00:00 2001 From: Edwin Jose Date: Wed, 16 Apr 2025 16:33:36 -0400 Subject: [PATCH] fix: tool change check logic (#7675) * Update composio_base.py * fix: Fix template bug causing empty output in AgentQL component (#7489) * Fix empty output issue in AgentQL component * Apply suggestions from code review Co-authored-by: Gabriel Luiz Freitas Almeida * Add reference to AgentQL API key --------- Co-authored-by: Gabriel Luiz Freitas Almeida * tool change check * optimised logic --------- Co-authored-by: Desiree Sng Co-authored-by: Gabriel Luiz Freitas Almeida --- .../base/langflow/custom/custom_component/component.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/base/langflow/custom/custom_component/component.py b/src/backend/base/langflow/custom/custom_component/component.py index 70e10fab1..cf8220738 100644 --- a/src/backend/base/langflow/custom/custom_component/component.py +++ b/src/backend/base/langflow/custom/custom_component/component.py @@ -1125,7 +1125,11 @@ class Component(CustomComponent): return component_toolkit(component=self, metadata=metadata).update_tools_metadata(tools=tools) def check_for_tool_tag_change(self, old_tags: list[str], new_tags: list[str]) -> bool: - return old_tags != new_tags + # First check length - if different lengths, they can't be equal + if len(old_tags) != len(new_tags): + return True + # Use set comparison for O(n) average case complexity, earlier the old_tags.sort() != new_tags.sort() was used + return set(old_tags) != set(new_tags) def _filter_tools_by_status(self, tools: list[Tool], metadata: pd.DataFrame | None) -> list[Tool]: """Filter tools based on their status in metadata.