fixed agent bugs