Fixed a bug in adding agents