My custom AI is stuck

So I have added some ai into the fisher class to enable it to auto harvest the captured crabs.
It didn’t worked.

It searches for the traps, find one, goes to it, and harvest it. So far, it is ok.
But for some reason, it does not goes to the next trap. It even gives an error (“has not yielded after 10 ai spins” error). The fisher is stuck there looking into the same trap forever.

If I use a command to renew that trap, it will harvest it as if it was working, but then get stuck on it again.
It looks like the ai is caching the found traps? When I delete the trap where the fisher is stuck, it will go to another one and harvest it.

I have a similar AI for auto harvesting fishes. The diference is that fish is not renewable, so as they get destroyed when harvested this problem doesn’t happen there, the fisher just go to the next fish until it harvested them all.

Here is the code I’m using:

local GetCrab = class()

GetCrab.name = 'get a crab'
GetCrab.does = 'archipelago_biome:get_fish'
GetCrab.args = { }
GetCrab.version = 2
GetCrab.priority = 1

function GetCrab:start_thinking(ai, entity, args)
   --Only with the right job perk
   local job_component = entity:get_component('stonehearth:job')
   if job_component and job_component:curr_job_has_perk('automatic_crab_fishing') then
      ai:set_think_output()
   else
      ai:halt()
      return
   end
end

function make_is_available_crab_fn()
   return stonehearth.ai:filter_from_key('archipelago_biome:get_crab', 'none', function(target)
         if radiant.entities.get_entity_data(target, 'archipelago_biome:crab_trap') then
            local rc = target:get_component('stonehearth:renewable_resource_node')
            return rc:is_harvestable()
         end
         return false
      end)
end

local ai = stonehearth.ai
return ai:create_compound_action(GetCrab)
         :execute('stonehearth:drop_carrying_now', {})
         :execute('stonehearth:goto_entity_type', {
            filter_fn = make_is_available_crab_fn(),
            description = 'get a crab'
         })
         :execute('stonehearth:reserve_entity', { entity = ai.PREV.destination_entity })
         :execute('stonehearth:harvest_renewable_resource_adjacent', { resource = ai.PREV.entity })

I must add that the problem should not be caused by my traps, as I tested the same code but for auto harvesting berry bushes and the same thing happened, the hearthling harvests one and get stuck in it refusing to go to the next.