Check whether agents and locations existing with the same ID before adding them to long-term memory