A worker can stay many turns in enemy territory. You will be asked to leave the first turn, but you can ignore it, and will not be forced to leave or declare war for many turns (typically 16 or 32 depending on how close to enemy cities the worker is). So the AI do distinguish between units that have an attack factor and those that don't (but it doesn't distinguish between a galley and a modern armor since both have a non-zero attack factor). So you must have misunderstood what started the war. Was you told to leave or declare war (and chose the latter)? If so, you must have had military units inside enemy territory as well. If the AI simply declared war, the worker was probably not the deciding factor, although the worker probably made the AI like you slightly less. But what you write here is almost as you wish it. It looks weird when an AI has several units inside your territory and still ask you t leave with your one worker, but the fact is that they follow exactly the same rules as you for when units may be forced to leave. And a lone worker is not viewed as a declaration of war. When a lone worker stays inside enemy territory for many turns (32 turns if you keep it at least 4 squares from any enemy city), you will be contacted and told to leave or declare war. Just leave and enter the next turn and you'll get 32 more turns.