Just had a very strange situation arise: my spy completed a Great Work Heist mission in Sparta the turn the city was captured by Arabia. As a result he fled to my capital, Xi'an. Unfortunately the mission was a failure and he was captured ... in Xi'an rather than Sparta, by Qin Shi Huang (me). I now see an 'Ask for Trade' option in the spy screen but can't trade with myself to get him back. This is the sort of extreme corner case I'm not surprised there's no coding for, but it definitely needs to be considered a bug.