I think that an ideal system would look like this:
Actions should be percentage based on what the spy finds when they get there (if the city has scientist-citizens then tech stealing should have a higher chance of being successful, etc...)
Show the player what the odds are and then have the player make the choice of what action to persue.
An example would be:
Our adversity has discovered the secret of Rifling, what action should I take?
A) Attempt to Eavesdrop on the secret (50% to steal tech, 25% of failure, 25% of being killed)
B) Bribe the scientists who discovered it (Costs 100 gold, 80% steal tech, 20% of being killed)
C) Remain Undercover (No risk, attempt to find other technologies they have researched)
An example on the defensive side would be:
I have found an enemy spy in our city, what should I do?
A) Kill the enemy spy immediately (70% of eliminating the spy, 10% chance of finding their origin, 20% they escape)
B) Track the enemy spy (50% of finding their origin, 50% they escape)
C) Bribe them, costs gold (80% of finding their origin, 20% they escape)
I don't like having RNG involved whatsoever. Others are too, mostly, considering the change to be able to have a 100% chance of coup being well-received.
Some coups, some spy actions, can be game determinant, especially on higher difficulties, were if you fail to eliminate an enemy spy despite having the best level, training and resources dedicated to it, still fails and means you are better off reloading or starting a new game.
It's better if spy success rates were based on how much resources you have, and will dedicate to them. For example, in your example, 70% of killing the spy would mean the defensive party would have to pay the equivalent 30% remaining in food, production or just gold, but it would be guaranteed to happen.
If the chance was 30%, having to pay up 70% might just not be worth it.
Civ 5 and especially vox populi is built upon making strategic decisions and weighing options based on what you're presented with. You might spawn on a horrible location but you can always choose to go full war mode and take someone else's capital early, but if you had a good start you might make other choices.
There are no other RNG heavy things in civ, so let's not add one, especially considering the AI will make dumb decisions too often. Because a bad opponent is just as boring as an unfair advantage.