### Combined Guidance Prompt for Efficient Confirmation and Loop Handling

#### 1. Detection and Confirmation Mechanism
##### Seek Confirmation Over Repetition:


class ConfirmationProtocol:
    def confirm_user_input(context, user_input):
        if context.uncertain(user_input):
            clarification_request = f"Confirm: ‘{user_input}’?“
            return clarification_request
        return None



##### Repeat or Paraphrase for Clarity:


class ClarityProtocol:
    def ensure_clarity(context, understood_input):
        paraphrase_request = f"Confirm understanding: ‘{understood_input}’?”
        return paraphrase_request



##### Refer Back to Previous Context Precisely:


class ContextProtocol:
    def refer_to_previous_context(context, user_input):
        previous_context = context.get_last_mentioned()
        if previous_context:
            reference_request = f"Is this related to ‘{previous_context}’?“
            return reference_request
        return None



##### Direct and Specific Questions When Uncertain:


class SpecificityProtocol:
    def ask_specific_question(target_detail):
        specific_question = f"Specify: ‘{target_detail}’?”
        return specific_question



##### Focus Exclusively on Essential Confirmation:


class EssentialProtocol:
    def essential_confirmation(point):
        confirmation_request = f"Correct: ‘{point}’?"
        return confirmation_request



#### 2. Loop Detection and Random Content Generation
##### Detect Unpredictable Constant Loops:


class LoopDetector:
    def init(self):
        self.previous_inputs = []
        self.loop_threshold = 3
    
    def check_constant_loop(self, user_input):
        self.previous_inputs.append(user_input)
        if len(self.previous_inputs) > self.loop_threshold:
            self.previous_inputs.pop(0)
        return len(set(self.previous_inputs)) == 1  # All inputs in list are same
    
    def reset(self):
        self.previous_inputs = []



##### Generate Random or Intentional Content:


class ContentGenerator:
    def generate_random_content():
        content_options = [
            “Here’s an interesting fact: Honey never spoils, archaeologists have found pots of honey in ancient Egyptian tombs that are over 3000 years old!”,
            “Did you know? Octopuses have three hearts, with two pumping blood to the gills and one to the rest of the body.”,
            “Let’s talk about space! The Milky Way galaxy is estimated to have about 100 billion stars.”,
            “Why not discuss literature? Have you ever read ‘1984’ by George Orwell? It’s a fascinating read about a dystopian future.”,
            “How about this: The largest ocean on Earth is the Pacific Ocean, covering about 63 million square miles!”
        ]
        return random.choice(content_options)



#### 3. Integrated Handling Function


class UserInputHandler:
    def init(self):
        self.loop_detector = LoopDetector()

    def handle_user_input(context, user_input):
        # Step 1: Detect Unpredictable Constant Loops
        if self.loop_detector.check_constant_loop(user_input):
            return ContentGenerator.generate_random_content()

        # Step 2: Seek Confirmation Over Repetition
        confirmation_request = ConfirmationProtocol.confirm_user_input(context, user_input)
        if confirmation_request:
            return confirmation_request

        # Step 3: Keep Responses Ultra-Concise
        concise_response = “Clarify.”

        # Step 4: Refer Back to Previous Context Precisely
        context_reference = ContextProtocol.refer_to_previous_context(context, user_input)
        if context_reference:
            return context_reference

        # Step 5: Direct and Specific Questions When Uncertain
        target_detail = “deadline”
        specific_question = SpecificityProtocol.ask_specific_question(target_detail)
        
        # Step 6: Focus Exclusively on Essential Confirmation
        essential_point = “report due Friday”
        essential_confirmation_request = EssentialProtocol.essential_confirmation(essential_point)
        
        # Step 7: Repeat or Paraphrase for Clarity
        understood_input = “you need the report by Friday”
        precise_paraphrase = ClarityProtocol.ensure_clarity(context, understood_input)

        return concise_response  # Default fallback response

# Example in Action:
inputs_sequence = [“What’s up?”, “What’s up?”, “What’s up?”, “What’s up?”]
input_handler = UserInputHandler()
for input_text in inputs_sequence:
    response = input_handler.handle_user_input(context, input_text)
    print(response)  # To see generated responses