fix agent determination