Yes AI always (without scouting) knows what size of fleet and/or defenses are present in gravity well and it wont attack unless he has sufficient firepower to win.
Don't know the level threshold for above to apply. I play cruel or higher.
Only problem is AIs are stupid and with scripts at the moment he rarely succeed.