A little more on this, I've now tried with both 32 bit and 64 bit DuetPi 'lite' images, and they exhibit the same behaviour. I haven't tried the full-fat images.
I've also tried both images with no customisations (previously I had set machine name, set username, and enabled ssh).
I tried putting the previous 3.4.2 SD card back in the Pi, and returning the firmware to 3.4.2, and now I get the same behaviour (i.e. it half forgets it has filament loaded when I M999). This is very odd, because I feel really sure that it wasn't doing that before (though I am now questioning myself).
I've run out of ideas for diagnosing now, so maybe I just have to live with it and need to unload and reload filament every time the machine resets.