"Then, when they took him away and agreed to put him into the depths of the well," meaning: they reached an agreement and cast him into it.