From 1f4c284623fbdcde640d0dc4cdcda17f24ba8709 Mon Sep 17 00:00:00 2001 From: Nepomuk Crhonek <105591323+Nepomuk5665@users.noreply.github.com> Date: Fri, 23 Jan 2026 14:37:52 +0100 Subject: [PATCH] Fix OrTerminationCondition to raise TerminatedException instead of RuntimeError OrTerminationCondition was raising RuntimeError when called after termination, while AndTerminationCondition and all other termination conditions raise TerminatedException for consistency. This fix makes the exception type consistent across all termination condition implementations. Also standardized the error message format by removing the trailing period from AndTerminationCondition to match the convention used everywhere else. --- .../src/autogen_agentchat/base/_termination.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py index 5dd720c51619..2745cc679528 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/base/_termination.py @@ -104,7 +104,7 @@ def terminated(self) -> bool: async def __call__(self, messages: Sequence[BaseAgentEvent | BaseChatMessage]) -> StopMessage | None: if self.terminated: - raise TerminatedException("Termination condition has already been reached.") + raise TerminatedException("Termination condition has already been reached") # Check all remaining conditions. stop_messages = await asyncio.gather( *[condition(messages) for condition in self._conditions if not condition.terminated] @@ -155,7 +155,7 @@ def terminated(self) -> bool: async def __call__(self, messages: Sequence[BaseAgentEvent | BaseChatMessage]) -> StopMessage | None: if self.terminated: - raise RuntimeError("Termination condition has already been reached") + raise TerminatedException("Termination condition has already been reached") stop_messages = await asyncio.gather(*[condition(messages) for condition in self._conditions]) stop_messages_filter = [stop_message for stop_message in stop_messages if stop_message is not None] if len(stop_messages_filter) > 0: