fix some problem and handle errors in agent