וַיִּגַּ֥שׁ אַבְרָהָ֖ם וַיֹּאמַ֑ר הַאַ֣ף תִּסְפֶּ֔ה צַדִּ֖יק עִם־רָשָֽׁע׃
Abraham came forward and said, “Will You sweep away the innocent along with the guilty? Genesis.18.23
The negotiation swivels around the idea that God's ultimate justice will not allow destroying the righteous alongside the wicked ones.
However, in the Exodus narrative, the Mechilta tells a different story - it is perfectly logical for God to destroy righteous with wicked ones:
מַגִּיד, שֶׁמֵּאַחַר שֶׁנִּתְּנָה רְשׁוּת לַמַּשְׁחִית לְחַבֵּל, אֵינוֹ מַבְחִין בֵּין צַדִּיק לְרָשָׁע:
This tells us that when once permission is given to the destroying angel to wound he makes no distinction between righteous and wicked (Mekhilta d'Rabbi Yishmael 12:22:2) Rashi_on_Exodus.12.22.5
How those two different approaches to God's justice can be settled?