When entering the UK on official diplomatic or government business (including transit through the UK), you will not need a visa even if in transit going to or returning from an assignment in another country. You can still apply for an exemption sticker to avoid delays on entry. Your partner or family members can also apply for the same.
Similarly, you will not need a visa to enter the UK on official government business if you are a current government minister. Again, you can apply for an exemption stamp to avoid delays when entering the UK. Your partner or family members can also apply for the same.
The Honorary Consulate of San Marino endeavours to keep the information above updated but strongly recommends checking the UK government website for any eventual changes.