Fixed a bug in getAgent