From 6db5e4c835c603bbe72e9cf2e55b212336687c22 Mon Sep 17 00:00:00 2001 From: Dmitry Paramonov Date: Fri, 13 Sep 2024 23:56:06 +0300 Subject: [PATCH] fix: Return empty tools list correctly --- agents-api/agents_api/common/protocol/sessions.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/agents-api/agents_api/common/protocol/sessions.py b/agents-api/agents_api/common/protocol/sessions.py index 1e98f7f12..a675a479f 100644 --- a/agents-api/agents_api/common/protocol/sessions.py +++ b/agents-api/agents_api/common/protocol/sessions.py @@ -94,9 +94,12 @@ def get_active_tools(self) -> list[Tool]: Get the active toolset from the session data. """ active_agent = self.get_active_agent() - active_toolset = next( - toolset for toolset in self.toolsets if toolset.agent_id == active_agent.id - ) + try: + active_toolset = next( + toolset for toolset in self.toolsets if toolset.agent_id == active_agent.id + ) + except StopIteration: + return [] return active_toolset.tools