The Prophet ﷺ was praying one night in his chamber when some people came and joined his prayer. He shortened it, then went inside the house. He came out again, and this happened several times, each time he was praying.In the morning, they said, "Messenger of Allah, you prayed while we wished you would lengthen your prayer."He replied, "I knew you were there, and I did that deliberately."
حدثنا محمد بن أبي عدي عن حميد
أن النبي ﷺ كان يصلي ذات ليلة في حجرته فجاء أناس فصلوا بصلاته فخفف فدخل البيت ثم خرج فعاد مرارا كل ذلك يصلي فلما أصبح قالوا يا رسول الله صليت ونحن نحب أن تمد في صلاتك قال قد علمت بمكانكم وعمدا فعلت ذلك
Its isnad is sahih. Muhammad bin Abu Adi is Muhammad bin Ibrahim, attributed here to his grandfather, and he is trustworthy. Haythami did not attribute the hadith to Ahmad, but attributed it to Abu Yaala and Bazzar, saying, "Its narrators are the narrators of the sahih" (2/274). It is also found in Ibn Khuzayma (3/62, no. 1627) and Bayhaqi (3/110), and it appears in the sahih collections with other wordings that will come later.