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