"And Sarah saw the son of Hagar the Egyptian, who she had borne unto Avraham, making sport. Wherefore she said unto Avraham: 'Cast out this bondwoman and her son for the son of this bondwoman shall not be heir with my son, even with Yitchak". (Bereshis 21:9-10)
Rashi on this verse brings a couple of midrashim to explain what Sarah Imeinu saw and what "making sport" means. Briefly, the first midrash connects the word "sport" (metzachek) with the three cardinal sins in Judaism: idolatry, illicit nookie and murder and accuses Yishmael of being guilty of each. The second midrash says that Yishmael took Yitzchak out on a play date but then tried to shoot him through with arrows while pretending that he was just playing a game with him. In either case it's clear that Sarah Imeinu saw a clear and present danger to Yitzchak Avinu and felt she had to take definitive action to prevent future problems.
There is a difficult with this understanding. While lost in the desert and dying of thirst, God gives a revelation to Hagar and promises to save Yishmael. "And God heard the voice of the lad and the angel of God called out of Heaven and said unto her: 'What aileth thee, Hagar? Fear not for God has heard the voice of the law where he is." (Bereshis 21:17)
On this verse Rashi once again brings a midrash in which the angels contest God's decision to save Yishmael from thirst by bringing up a well for him. They note that in the future his descendants would mistreat our ancestors through thirst. God is noted to reply that while this might be the case, in the here and now (or, I guess, the there and then) Yishmael was righteous and could not be punished for sins yet uncommitted.
It doesn't take much to see the contradiction here. God declared Yishmael righteous even though the whole reason he was in the desert dying of thirst in the first place was because Sarah Imeinu was worried about how wicked he was. Which is it?
Further, if Yishmael was guilty of murder, incest and idolatry, why did the angels not accuse him of them instead of going after the future sins of his descendants?
Rav Chaim Pinchas Sheinberg, zt"l, takes issue with the use of the word "tzadik" in the midrash. According to the standard understanding of the word God asks the angels: "Is he righteous right now or not?" The angels are compelled to answer "Righteous". However, Rav Sheinberg translates "tzadik" not as "righteous" but as "innocent", a less frequent but not rare use of the word. Thus God was asking the angels "Has he actually killed anyone yet? Is he guilty or innocent?" and the angels had to answer "Innocent".
Rav Chaim Kanievsky, shlit"a, brings a different answer from a legal perspective. He reminds us that while a man becomes an adult under halacha at the age of 13 he is only answerable to the court from the age of 20. Yishmael, depending on who you ask, was 15 or 17 at the time of this incident. Therefore, despite being guilty of the three cardinal sins of Judaism he could not yet be punished for them. That's why the angels didn't accuse him of those sin but instead mentioned future events.