auto detect/conifg Ag to accelerate the search