(PB) >>13636579 (PB)
Have to check the Law of War Manual for clarification. My guess is that diplomatic immunity does not exist in all circumstances.
Diplomats who represent their country abroad enjoy diplomatic immunity. This protects them against prosecution in the receiving state for the entire period in which they hold their diplomatic post.
https://www.government.nl/topics/embassies-consulates-and-other-representations/diplomatic-immunity