async def test_idle_monitoring_stops_on_false_return(self):
        """Test that idle monitoring stops when callback returns False."""
        retry_counts = []

        async def retry_callback(processor: UserIdleProcessor, retry_count: int) -> bool:
            retry_counts.append(retry_count)
            return retry_count < 2  # Stop after second retry

        processor = UserIdleProcessor(callback=retry_callback, timeout=0.4)

        frames_to_send = [
            UserStartedSpeakingFrame(),
            UserStoppedSpeakingFrame(),
            SleepFrame(sleep=0.5),  # First retry (count=1, returns True)
            SleepFrame(sleep=0.5),  # Second retry (count=2, returns False)
            SleepFrame(sleep=0.5),  # Should not trigger callback
        ]

        expected_down_frames = [
            UserStartedSpeakingFrame,
            UserStoppedSpeakingFrame,
        ]

        await run_test(
            processor,
            frames_to_send=frames_to_send,
            expected_down_frames=expected_down_frames,
        )

        assert retry_counts == [1, 2], f"Expected retry counts [1, 2], got {retry_counts}"
Test that idle monitoring stops when callback returns False.
tests/test_user_idle_processor.py