Entities can get stuck inside short-pathfinder obstruction boundaries, making them compute short paths that they actually can't take. This was first reported here. It's pretty much unfixable.
However, the stuckiness can be fixed by computing a long-path occasionally.
Because of an off-by-one error, that sometimes never worked. This fixes it.
It also reintroduces larger max_range as a value of 6 is rather low.
Reported by Freagarach along with a very helpful minimal replay.