When can a spotted agent safely move into hiding?

If you can make it so the enemy does not have direct sight to your agent using no or a single movement they can (temporarily) escape to safety. Other agent can use as many actions as you like, it is only the action of a watching agent or the end of a turn that will get that agent shot.

Some possible ways to do this include closing a door, the watched agent moving a single tile to hide behind cover or otherwise out of sight, disabling the enemy (most difficulty levels allow a watched agent to melee attack a guard watching them, you could also use ranged weapons or another agent).

If you are planning to move to safely, you can see which tiles are considered safe on the map (I highly recommend activating the tactical view by holding Alt to get a clearer view (apologies but I cannot get a screenshot of that at the moment).

An example of this can be seen in screenshot below where we see an agent in trouble. There are 3 yellow tiles adjacent to the agent's current position that can all be reached safely, also note how hovering on these tiles indicates they are "hidden". Also, note that there is a direct path drawn on the map between the agent and the tile aimed for (this is the "single movement" that it is acceptable to make your escape with).

The vision indicators on the map are a combination of all enemies, so it's possible for a red square to be a safe choice in the event that the enemy currently on overwatch cannot see it, and the enemy that can see the red square is currently not on overwatch. You'll have to work out visions yourself in this case however; there's no way to view the cones of individual enemies.

Cropped screenshot of Invisible Inc showing agent in danger and possible escape routes

You should also note that enemies will also shoot at other agents which enter their direct vision without a warning if they are already in overwatch (pointing a gun at someone), so be careful when manoeuvring other agents to help. It is safe to move agents through the 'noticed' peripheral part of a guards vision cone in this case - the guard will continue to focus on their currently watched target.

Finally, it is not necessary to sprint if attempting to move to cover, sprinting just gives you more actions points while making you loud, and it's that first action point you use that matters here.