Log state in main agent loop only if state is active.