Al-Kāfi - Volume 1 > The Imams (a.s.) know their friends and that they are the in charge of their affairs
Hadith #3

3ـ أَحْمَدُ بْنُ إِدْرِيسَ وَمُحَمَّدُ بْنُ يَحْيَى عَنِ الْحَسَنِ بْنِ عَلِيٍّ الْكُوفِيِّ عَنْ عُبَيْسِ بْنِ هِشَامٍ عَنْ عَبْدِ الله بْنِ سُلَيْمَانَ عَنْ أَبِي عَبْدِ الله (عَلَيْهِ السَّلام) قَالَ سَأَلْتُهُ عَنِ الامَامِ فَوَّضَ الله إِلَيْهِ كَمَا فَوَّضَ إِلَى سُلَيْمَانَ بْنِ دَاوُدَ فَقَالَ نَعَمْ وَذَلِكَ أَنَّ رَجُلاً سَأَلَهُ عَنْ مَسْأَلَةٍ فَأَجَابَهُ فِيهَا وَسَأَلَهُ آخَرُ عَنْ تِلْكَ الْمَسْأَلَةِ فَأَجَابَهُ بِغَيْرِ جَوَابِ الاوَّلِ ثُمَّ سَأَلَهُ آخَرُ فَأَجَابَهُ بِغَيْرِ جَوَابِ الاوَّلَيْنِ ثُمَّ قَالَ هذا عَطاؤُنا فَامْنُنْ أَوْ أَعْطِ بِغَيْرِ حِسابٍ وَهَكَذَا هِيَ فِي قِرَاءَةِ علي (عَلَيْهِ السَّلام) قَالَ قُلْتُ أَصْلَحَكَ الله فَحِينَ أَجَابَهُمْ بِهَذَا الْجَوَابِ يَعْرِفُهُمُ الامَامُ قَالَ سُبْحَانَ الله أَ مَا تَسْمَعُ الله يَقُولُ إِنَّ فِي ذلِكَ لاياتٍ لِلْمُتَوَسِّمِينَ وَهُمُ الائِمَّةُ وَإِنَّها لَبِسَبِيلٍ مُقِيمٍ لا يَخْرُجُ مِنْهَا أَبَداً ثُمَّ قَالَ لِي نَعَمْ إِنَّ الامَامَ إِذَا أَبْصَرَ إِلَى الرَّجُلِ عَرَفَهُ وَعَرَفَ لَوْنَهُ وَإِنْ سَمِعَ كَلامَهُ مِنْ خَلْفِ حَائِطٍ عَرَفَهُ وَعَرَفَ مَا هُوَ إِنَّ الله يَقُولُ وَمِنْ آياتِهِ خَلْقُ السَّماواتِ وَالارْضِ وَاخْتِلافُ أَلْسِنَتِكُمْ وَأَلْوانِكُمْ إِنَّ فِي ذلِكَ لاياتٍ لِلْعالِمِينَ وَهُمُ الْعُلَمَاءُ فَلَيْسَ يَسْمَعُ شَيْئاً مِنَ الامْرِ يَنْطِقُ بِهِ إِلا عَرَفَهُ نَاجٍ أَوْ هَالِكٌ فَلِذَلِكَ يُجِيبُهُمْ بِالَّذِي يُجِيبُهُمْ.

3. Ahmad ibn Idris and Muhammad ibn Yahya havenarrated from al-Hassan ibn Ali al-Kufi from ‘Ubays ibn Hisham from ‘Abdallah ibn Sulayman who has said the following. “I asked abu ‘Abdallah (a.s.) about the Imam. Has Allah made him the in charge of the and in full control (over the affairs of the people) as Sulayman ibn Dawud was?” The Imam (a.s.) said, “Yes, he is given control. It is because a man asked him a question and he gave the answer. Another person asked the same question and he gave him a different answer (although the question was the same). A third person asked him the same question and he gave an answer that was different from both the previous answers. Then he said, “This is Our gift to you so give them away free or keep them as you like.” (38:39). This is charity from us enjoy it with thanks or ( give to others) without being questioned. This is according to Imam Ali’s recitation.” The narrator has said that I said to him, “May Allah grant you well being, when the he gives such answers does the Imam know them?” The Imam (a.s.) said, “Glory belongs to Allah. Have you not heard Allah words? “ In this there is evidence (of the Truth) for the discreet ones. (15:75) (Such people are the Imams (a.s.) That town lies on a road which still exists (15:76) (It will remain there for ever).” Then The Imam (a.s.) said to me, “Yes, when the Imam look at a person he recognizes him and his color. On hearing his words even from behind the wall he recognizes him and what he is. Allah has said, “Other evidence of His existence are the creation of the heavens and the earth and the differences of languages and colors. In this there is evidence (of the truth) for the worlds (mankind).” (30:22) The Imams are the scholars. Whatever they would hear that is spoken they recognize it, the one who has received salvation or one who is destroyed. For this reason they answer them as they answer them.”