fix running agent detection logic