Fix detection when ->agent is empty.