Issue with Undoable Mesh Deformations in Sculpt Mode

Hi All,

It doesn’t appear to be possible to undo operators that deform meshes in Sculpt mode.

Here’s a Blender 2.8 operator to demonstrate the problem:

import bpy
import mathutils
import random

class TEST_OT_deform(bpy.types.Operator):
    bl_idname = 'test.deform'
    bl_label = 'Test Deform'
    bl_options = {'REGISTER', 'UNDO'}
    def poll(cls, context):
        return (
            context.active_object is not None and
            context.active_object.type == 'MESH' and
            context.active_object.mode in {'OBJECT', 'SCULPT'}
    def execute(self, context):
        mesh =
        for v in mesh.vertices:
   += 0.05 * mathutils.Vector((
                random.random() * 2 - 1,
                random.random() * 2 - 1,
                random.random() * 2 - 1
        return {'FINISHED'}

classes = [TEST_OT_deform]

register, unregister = bpy.utils.register_classes_factory(classes)

if __name__ == '__main__':

Run it a few times in Object mode, and each step can be undone. However after doing the same while in Sculpt mode, the deformations are undoable.

Even adding a call to “bpy.ops.ed.undo_push()” doesn’t fix the issue.

Does anyone know how to undo mesh deformations in Sculpt mode?