def create_termination_strategy()

in generators/backend/templates/src/backend/patterns/debate.py [0:0]


    def create_termination_strategy(self, agents, maximum_iterations):
        """
        Creates a strategy to determine when the debate should end.
        
        The strategy terminates the conversation when the Critic agent's evaluation 
        score exceeds a threshold (8.0) or when maximum iterations are reached.
        
        Args:
            agents: List of agents that can trigger termination evaluation.
            maximum_iterations: Maximum number of conversation turns before forced termination.
            
        Returns:
            CompletionTerminationStrategy: A strategy for determining when to end the debate.
        """

        # Using UTILITY model - the task is simple - evaluation score extraction
        class CompletionTerminationStrategy(TerminationStrategy):
            logger: ClassVar[logging.Logger] = logging.getLogger(__name__)
            
            iteration: int = Field(default=0)
            kernel: ClassVar[Kernel] = self.kernel
            
            termination_function: ClassVar[KernelFunctionFromPrompt] = KernelFunctionFromPrompt(
                function_name="TerminationEvaluator",
                prompt_execution_settings=self.settings_utility,
                prompt=fr"""