I didn't notice this thread before. There's no such thing in this game. The concept of being "in combat" is left to the routine to decide.
For example, you can check if there are mobs around you within a distance, but you could still be under attack from range. You could check to see what the BestTarget was, but that doesn't mean you're safe and not about to attack something because you're moving. Are you in combat because you have something to kill, even if it's further away?
Then there's the case of standing on top of some environment hazard. If you're on a permanent patch of burning gerund and taking more damage than you're regenerating, you'll die.
In modern mmos, there's usually some GUI display to let you know if you're in combat or not. PoE doesn't have such a thing. In other bots, such a state flag is checked, and the routine is only called under that condition.
So there's no clear definition of being in combat that is easily determined. The routine gets logic called every time there is no other task registered before it that needs to execute. That means you decide if you should or shouldn't cast skills inside the routine, because you're controlling what the bot is currently doing at the time you want to check if it's in combat or not.