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:- Begins a recording with
ChangeHistoryService:TryBeginRecording() - Executes the tool operation
- Commits the recording with
FinishRecording()
Implementation
FromBridge.lua:106-117:
Read-Only Tools
Read-only tools (queries and getters) do not create undo waypoints: FromBridge.lua:13-24:
Undo Waypoint Names
Each undo waypoint is labeled with the tool name: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
Example: mass_create_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
Group Related Changes
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
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
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