Workaround from [~GoldenHelmet]
I have created a behavior pack that allows trader llamas to follow normal despawn rules if they get separated from the wandering trader:
[media]
Note that using this will disable achievements in your world.
Steps to reproduce:
Play for a very long time staying and building around the spawning point.
Expected results:
Mobs regularly despawn even if they interacted with each other.
Observed results:
Mobs and animals stop spawning, mobs cap is reached. Observed large amounts of Llamas - see details why it happens. Really really it spoils the survival game.
Details:
While playing survival for a long time, from time to time I get a situation when no more animals or mobs appear around my home (it's initial spawing point). I think I found the cause of the issue: The mobs spawning cap is reached by leftover Llamas after their trader is killed by some other mob. For what is worse, the killing mob also does not despawn over time, killing more and more traders, and causing that point is overwhelmed by Llamas. After some searching around the base, I have found 2 of such points (see the screenshot of one of such points). And 3rd point was in the cave below the base (where I first discovered this). In all 3 places killing mob was a zombie. Each spot has 16-30 Llamas. These for sure were trader Llamas (all covered with carpet, some dropped the lead). I do not know how many places like that I have below in the huge caves system at my spawning point, but I still hear Llama sounds all around, so I think a few more are there for sure since the mobs spawning cap was reached.
I think mobs and trader's Llamas should not be marked as "interacted with Player" when they fight each other, so they can correctly despawn instead of gathering into the "Trader Llama" packs like that.
Related issues
is duplicated by
relates to
Attachments
Comments


One more case: Finally found a cave where Llama sounds below my base were for so long. And the killer was a baby zombie. See screens

This problem is a direct result of the way MCPE-66638 was patched. That change made trader llamas spawn with persistence, so now they can hide forever in hidden places much like cave monsters used to do (MCPE-21856). Moreover, trader llama spawning is not limited by any population or density caps, so they can accumulate indefinitely, just like converted drowned used to do (MCPE-34032).

By them accumulating to much in one area and not despawning there become way to many llamas which eventually cause a drop in game performance (lag) further more the wandering trader and his llamas can spawn literally anywhere even in the ocean.

The problem here is that the entities\llama.json file in the vanilla behavior pack includes the component
"minecraft:persistent": {
}
within the group
"minecraft:llama_wandering_trader"
.
This makes trader llamas stay persistent forever.
I have fixed the bug in the attached behavior pack by putting "minecraft:persistent" into a new, separate group, "llama_persistent", which gets added at the same point as minecraft:llama_wandering_trader, but gets removed by a new event, "lost", if the llama is unleashed from the trader.

The behavior pack is nice, although disabling the achievements would make me avoid it, assuming I could ever use it on console in the first place.
This is a serious issue. I've been having so many trader llamas spawn in my caves that it's insane. Please Mojang, fix this issue. It's an easy fix.

After 1.17 the trader llamas block glow squid and axolotl spawns.
Update: in 1.18 axolotl are classed as water_animal instead of animal, so trader llamas no longer block them from spawning.

Affects 1.17.40.20

Confirmed in 1.17.40. Llamas still accumulate around my base and don't ever despawn. I kill them on sight but I'm sure there are ones I haven't found producing lag and wasting the mob cap.

Can confirm that 1.18.2 still has this big issue. Wandering traders and llamas spawn in caves. Llamas detach from wandering trader either because he's killed, lava, water, dripstone, height etc. And then llamas start to build up as you play, leading to hundreds of persistent mobs and huge lag in your base after a while. Trader llamas that haven't interacted with the player should despawn.
It's also worth looking at MCPE-125111 as zombies underground will pick up llama leads and cause further persistence. Play long enough, and your base starts to get very laggy with hundreds of mob collisions underground. Zombies holding items should also despawn. Often they're just carrying junk like skeleton arrows, gravel, slime etc. Maybe if they're actually holding something valuable, they can have persistence, if that check doesn't cause lag?
Also, I have a village & bell in the surface, but wandering traders consistently spawn in deep underground caves below the bell, which will kill them and spawn more persistent llamas. The Y-range of the wandering trader bell spawn is messed up. See MCPE-151591 for details.

Still happening in 1.18.0. I have seen llamas despawn at the same time as they wandering trader as long as they are still connected by a lead. When the lead is broken (like when the trader is killed instead of despawning) the llamas become persistent.

I've uploaded an updated workaround pack.