Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:9:7

How can there be for the polytheists a treaty in the sight of Allah and with His Messenger, except for those with whom you made a treaty at al-Masjid al-Haram? So as long as they are upright toward you, be upright toward them. Indeed, Allah loves the righteous ˹who fear Him˺.  

How can the idolaters have a pact with God and His Messenger — they cannot —while they disbelieve in God and His Messenger, acting treacherously; except for those with whom you made a pact at the Sacred Mosque?, the day of al-Hudaybiyya — these were Quraysh, for whom an exception was made earlier ˹Q. 9:4˺. So long as they are true to you, keeping to the pact and not breaking it, be true to them, by fulfilling it (fa-mā, ‘so long as’: the mā is a conditional particle). Truly God loves the God-fearing: the Prophet (s) had kept to the pact made with them until they broke it by supporting the Banū Bakr against Khuzā‘a.
القرآن:٩:٧

كَيْفَ يَكُونُ لِلْمُشْرِكِينَ عَهْدٌ عِنْدَ اللَّهِ وَعِنْدَ رَسُولِهِ إِلَّا الَّذِينَ عَاهَدْتُمْ عِنْدَ الْمَسْجِدِ الْحَرَامِ ۖ فَمَا اسْتَقَامُوا لَكُمْ فَاسْتَقِيمُوا لَهُمْ ۚ إِنَّ اللَّهَ يُحِبُّ الْمُتَّقِينَ  

{كيف} أي لا {يكون للمشركين عهد عند الله وعند رسوله} وهم كافرون بالله ورسوله غادرون {إلا الذين عاهدتم عند المسجد الحرام} يوم الحديبية وهم قريش المستثنون من قبل {فما استقاموا لكم} أقاموا على العهد ولم ينقضوه {فاستقيموا لهم} على الوفاء به وما شرطية {إن الله يحب المتقين} وقد استقام النبي ﷺ على عهدهم حتى نقضوا بإعانة بني بكر على خزاعة.