Refactor HydraWrapper so the when-to-retry logic is in the worker