def run(self, max_iterations: int = None):
        """Run the reasoning engine.

        :param int max_iterations: The number of max_iterations to run the reasoning engine
        """
        self.iterations = max_iterations or self.max_iterations
        self.build_context()
        self.output_message.actions.append("Reasoning the message..")
        self.output_message.push_update()

        it = 0
        while self.iterations > 0:
            self.iterations -= 1
            print("-" * 40, "Reasoning Engine Iteration", it, "-" * 40)
            if self.stop_flag:
                break

            self.step()
            it = it + 1

        self.session.save_context_messages()
        print("-" * 40, "Reasoning Engine Finished", "-" * 40)
Run the reasoning engine.

        :param int max_iterations: The number of max_iterations to run the reasoning engine
        
backend/director/core/reasoning.py