UNDO after applying modifier

Hello,

Very simple script to help decimate the mesh during sculpting. The problem is that UNDO does not work( does not restore mesh state before decimation). Can anyone give me tips how to go about it so i can undo/not lose data. Thank You
[SUB]
class nwDecimate(bpy.types.Operator):
“”“Tooltip Sculpt Decimate”""
bl_idname = “nw.decimate”
bl_label = “nw Decimate Mesh”
bl_options = {‘REGISTER’, ‘UNDO’}

def invoke(self, context, abc):
    print ("Decimating")
    bpy.ops.object.modifier_add(type='DECIMATE')
    bpy.context.object.modifiers["Decimate"].ratio = 0.5
    bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Decimate")
    return {'FINISHED'}[/SUB]

does it help if you manually push to undo stack?

bpy.ops.ed.undo_push(message=“Add an undo step function may be moved”)

Hello. Worked like charm! Thank you so much CoDEmanX - your time and knowledge is very much appreciated!