Rigify, Model detaches from rig when animating
This has happened to me a few times. It is likely because vertex groups in the mesh are misnamed (wrong bones connect to certain areas), particularly left and right being mixed up.
The shrinking thing is strange. Did you make this animation yourself? Is it possible you animated the mesh's scale by accident?
There is a possibility that some physics simulation is also set up on the robot and is conflicting with the armature.
If none of this helps, please share the blend file, then someone will look at it and be able to tell you exactly what's going on.