Shalom u bracha
In todays daf the Guemar? brings a few times bame Arachta yamim. How did they know in which zechut they had long life?
Kol tuv
I don't think you can say that they knew through Ruach haKodesh - Divine inspiration - because we find cases where, at least according to one answer in Tosafos, they were wrong about the reason. For example, the Gemara (Eiruvin 54b) says that R'Preida was granted long life (four hundred years) because he had the patience to teach a Talmid the same thing four hundred times before he got it. The Gemara, though, in Megillah says that he told his Talmidim that he merited long life because no one got to the Beis Midrash before him in the morning. Tosafos gives two answers to the apparent contradiction - a) that both reasons contributed to his longevity, b) that he thought it was because of the latter reason until he reached the age of four hundred, at which point he realized it was for the former reason.
Therefore, I would say, that just as Chazal had a very deep understanding of the Torah, as evidenced by their ability to Darshen Psukim - something we don't have today - so too, they had a very deep understanding of Hash-m's system of reward and punishment; His Hanhagah of Midah k'Neged Midah (also something we are probably lacking today).
Kol Tuv,
Yonasan Sigler