Alternative theory: Is there possibly a max number of minions that can occupy a single tile, and when that limit is reached any extra minions are moved to the nearest empty tile (in this case outside of the walls)?
Would you mind testing that theory for me by dropping enemies in one at a time until one of them escapes and let me know if it is the same number of enemies each time?
It's not so easy to check.
I tested several dozen enemies at a time. Some time passed before someone escaped (this did not happen immediately after the prisoners were trapped).
The wells of the souls summoning the Reventats nearby and sometimes Reventats were also summoned inside the trap (I also do not know if it was a bug - or it was intended by the developers). The Revenants are of a spiritual nature and probably have the right to appear behind the wall.
I want to say that periodically the Revenants are trapped, and their number is more difficult to control.