For context, this is my first adventure as a DM. The PCs are level 2.
About 40 minutes into the first session, while investigating the rumours about a ghost ship, the group meets with Aleyd Burrows, a skilled veteran, Captain of the Guard and a very important figure.
She gives them various pieces of information and sends them on their way with new leads. As the party starts to leave, the last player walks up to Aleyd, shakes her hand and tries to steal her purse. Luckily he passes the Sleight of Hand check with ease since he rolled a 16+8 (he's a rogue with Expertise). (I chose a DC of 20 without disadvantage: Aleyd is usually quite alert, but the player did make a very natural “Thank you”+handshake, and Aleyd didn't have a reason to be more alert then usual.)
However, I do not know how to deal with this had he failed.
Knowing him, he is likely going to pull similar stunts.
P.S. I did talk with him afterwards, and he promised to be more mindful from now on.
He enjoys fooling around, but he is trying to do so without reducing the fun of the others.
He also set off a bit of a conflict with another thing he did, which me and the other players commented on. He did thoroughly apologise for it, and they spent some more time talking it out.
I mostly want to know how to deal with such situations without stepping out of the “in game” position.