Skip to main content
All write operations in RbxGenie are wrapped with ChangeHistoryService, allowing users to undo any AI-made changes with Ctrl+Z in Roblox Studio.

How It Works

Every tool call that modifies the game is recorded as a single undo waypoint. When a tool executes, RbxGenie:
  1. Begins a recording with ChangeHistoryService:TryBeginRecording()
  2. Executes the tool operation
  3. Commits the recording with FinishRecording()
This means each tool call becomes one undoable action in Studio.

Implementation

From Bridge.lua:106-117:
local recording = nil
if not READ_ONLY_TOOLS[tool] then
  recording = ChangeHistoryService:TryBeginRecording("RbxGenie: " .. tool)
end

local t0 = os.clock()
local result, err = Executor.dispatch(tool, args)
local elapsedMs = math.round((os.clock() - t0) * 1000)

if recording then
  ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end

Read-Only Tools

Read-only tools (queries and getters) do not create undo waypoints: From Bridge.lua:13-24:
local READ_ONLY_TOOLS = {
  get_file_tree = true, search_files = true, get_place_info = true,
  get_services = true, search_objects = true, get_instance_properties = true,
  get_instance_children = true, search_by_property = true, get_class_info = true,
  get_project_structure = true, summarize_game = true,
  mass_get_property = true,
  get_script_source = true,
  get_attribute = true, get_attributes = true,
  get_tags = true, get_tagged = true,
  get_selection = true,
  get_console_output = true, get_studio_mode = true,
}

Undo Waypoint Names

Each undo waypoint is labeled with the tool name:
RbxGenie: set_property
RbxGenie: create_object_with_properties
RbxGenie: mass_set_property
RbxGenie: delete_object
This makes it easy to identify which operations were performed by RbxGenie in Studio’s undo history.

User Experience

Users can:
  • Press Ctrl+Z to undo the last AI operation
  • Press Ctrl+Y to redo
  • View the undo history in Studio to see labeled RbxGenie operations
  • Undo multiple operations in sequence

Bulk Operations

Each tool call is treated as a single undo unit, even if it affects multiple instances:

Example: mass_set_property

{
  "paths": ["Workspace.A", "Workspace.B", "Workspace.C"],
  "property": "Transparency",
  "value": 0.5
}
This creates one undo waypoint that sets transparency on all three parts. Pressing Ctrl+Z will revert all three changes at once.

Example: mass_create_objects

{
  "items": [
    { "path": "Workspace", "className": "Part" },
    { "path": "Workspace", "className": "SpawnLocation" },
    { "path": "Workspace", "className": "Model" }
  ]
}
This creates one undo waypoint. Pressing Ctrl+Z will delete all three created objects.

Failed Operations

If a tool encounters an error, the recording is still committed, but no changes are applied. This prevents partial undo states.

Best Practices for AI Agents

Use bulk tools (mass_set_property, mass_create_objects) instead of multiple individual calls. This:
  • Creates cleaner undo history (one waypoint vs. many)
  • Improves performance
  • Reduces token costs
// BAD: 3 separate undo waypoints
set_property({ "path": "Workspace.A", "property": "Transparency", "value": 0.5 })
set_property({ "path": "Workspace.B", "property": "Transparency", "value": 0.5 })
set_property({ "path": "Workspace.C", "property": "Transparency", "value": 0.5 })

// GOOD: 1 undo waypoint
mass_set_property({
  "paths": ["Workspace.A", "Workspace.B", "Workspace.C"],
  "property": "Transparency",
  "value": 0.5
})

Consider Undo Granularity

When performing complex multi-step operations, consider whether the user might want to undo individual steps or the entire operation:
  • Fine-grained: Multiple tool calls, each undoable separately
  • Coarse-grained: Single tool call with bulk operations
For most cases, coarse-grained undo is preferable (simpler history, better performance).

Technical Details

Recording Lifetime

  • Recording begins before tool execution
  • Recording commits after tool returns (success or error)
  • Recording uses Enum.FinishRecordingOperation.Commit

Thread Safety

RbxGenie processes one tool call at a time sequentially, so there are no race conditions between recordings.

Limitations

  • Undo is scoped to the current Studio session
  • Closing and reopening the place clears undo history
  • Undo does not work for operations performed during playtesting

Build docs developers (and LLMs) love