fix(agent): fix the logic to select custom endpoints