From 9d06a8b1472d38f429c18fe411807789b1458c2e Mon Sep 17 00:00:00 2001 From: Ben Browning Date: Thu, 10 Jul 2025 11:34:33 -0400 Subject: [PATCH] Narrow the scope of toolgroup exception catching Signed-off-by: Ben Browning --- llama_stack/core/routing_tables/toolgroups.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/llama_stack/core/routing_tables/toolgroups.py b/llama_stack/core/routing_tables/toolgroups.py index 03b0b0a95..8172b9b5f 100644 --- a/llama_stack/core/routing_tables/toolgroups.py +++ b/llama_stack/core/routing_tables/toolgroups.py @@ -53,20 +53,20 @@ class ToolGroupsRoutingTable(CommonRoutingTableImpl, ToolGroups): all_tools = [] for toolgroup in toolgroups: - try: - if toolgroup.identifier not in self.toolgroups_to_tools: + if toolgroup.identifier not in self.toolgroups_to_tools: + try: await self._index_tools(toolgroup) - all_tools.extend(self.toolgroups_to_tools[toolgroup.identifier]) - except AuthenticationRequiredError: - # Send authentication errors back to the client so it knows - # that it needs to supply credentials for remote MCP servers. - raise - except Exception as e: - # Other errors that the client cannot fix are logged and - # those specific toolgroups are skipped. - logger.warning(f"Error listing tools for toolgroup {toolgroup.identifier}: {e}") - logger.debug(e, exc_info=True) - continue + except AuthenticationRequiredError: + # Send authentication errors back to the client so it knows + # that it needs to supply credentials for remote MCP servers. + raise + except Exception as e: + # Other errors that the client cannot fix are logged and + # those specific toolgroups are skipped. + logger.warning(f"Error listing tools for toolgroup {toolgroup.identifier}: {e}") + logger.debug(e, exc_info=True) + continue + all_tools.extend(self.toolgroups_to_tools[toolgroup.identifier]) return ListToolsResponse(data=all_tools)