While changing the formula to make things riskier is one possibility, how about a small possibility not only of the spy being revealed, but also being interrogated? Example, you catch a spy, you wouldn't immediately execute them; you'd try to learn what they know. So why not create a possibility of the spy being captured and tortured/interrogated. With the resulting information, the defending country would do the same to the attacker as the mission the spy was sent on.
Example,
Spy is sent by X to Y to steal tech.
Spy fails in stealing tech, but is caught and forced to reveal where X stores its tech.
Nation Y gets up to 3 tech from X.
Even if the mission is successful, the effects would be mimicked in the attacking country.
Granted, this should only be a small possibility, but it would make nations think twice about using spies as missions are more risky (closer to real-life).