Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:A9T9 RPA Copy On Write AI Macro Modifications

From Leeroopedia
Knowledge Sources
Domains AI_Agent, Data_Integrity
Last Updated 2026-10-22 17:48 GMT

Overview

AI-generated macro modifications are saved as new copies — the user's original macro file is never overwritten, preventing destructive edits when the AI fixes or extends an existing macro.

Description

When the AI macro agent fixes or extends an existing command-table macro, it converts the macro to a JS script first (table fixes generated user support and bug reports from fixes gone wrong), then saves the result via set_macro. The set_macro implementation writes a new copy — the original table file stays intact on disk. This copy-on-write behavior means the user can always compare the AI's changes against the original or revert by simply re-opening the original file. The AI is instructed to recommend the conversion in its summary rather than asking permission first, and to preserve the targeting technique (visual stays visual) during conversion.

Usage

Use this heuristic whenever the AI agent modifies existing macros via set_macro or create_macro. The copy-on-write behavior is built into the tool implementations — no user action is needed. The agent always produces JS script macros, never command tables, even when fixing a table macro.

The Insight (Rule of Thumb)

  • Action: set_macro writes a new file; the original is never modified in place.
  • Value: When fixing a table macro, convert to JS script and save as a new copy. The original table file remains on disk.
  • Trade-off: Creates duplicate files (original table + new script); the user must manually delete the old one if desired.
  • Compatibility: The AI always writes JS scripts — never command tables. Table-to-script conversion is mandatory for fixes.

Reasoning

In-format table fixes (editing the Commands array directly) generated user support tickets and bug reports when fixes went wrong — the original macro was destroyed and the user had no way to compare or revert. Copy-on-write eliminates this class of problem: the original is always preserved. Converting to JS script during the fix is more reliable because:

  1. JS scripts express logic (loops, conditionals, error handling) that table commands cannot.
  2. The agent writes the program as plain JavaScript with real newlines and quotes — no JSON escaping, so selectors like css=[aria-label="Go"] or xpath=//a[contains(@id, 'x')] don't break.
  3. The script is formatted as readable multi-line JavaScript — one statement per line, normal indentation — because it is what the user reads and edits in the editor.

The agent is told to preserve the targeting technique during conversion: a visual search stays visual (not converted to DOM selectors), and vice versa.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment