Cut Computer-Use Agent Costs 8-13x by Replaying Compiled Task Programs
PreAct turns a successful agent run into a reusable state machine, eliminating repeated LLM calls for known tasks while adding safety checks.
Practical Summary
This technique reduces cost and latency for computer-use AI agents by compiling their first successful task execution into a deterministic replay program. Subsequent runs of the same task bypass the expensive reasoning and screen-reading steps, achieving 8.5x to 13x speedups with no per-step language-model calls.
Why It Matters
For businesses using AI agents to automate software tasks, the primary cost driver is often repeated reasoning for tasks the agent has already mastered. This workflow directly attacks that cost center by creating an amortized, reusable asset from a single successful run, offering a clear path to reduce operational expenses and improve response times for recurring processes.
How the PreAct Cost-Reduction Workflow Works
The workflow is built on compiling an agent's first successful execution of a task into a compact program, then using that program for all future identical tasks. This transforms a high-cost, variable reasoning process into a low-cost, deterministic replay.
Step 1: Initial Agent Run (High Cost)
The AI agent completes the task for the first time using its standard method. It reads the screen, reasons about each action, and executes taps or clicks step-by-step. This process incurs the full computational and API cost of multiple LLM calls.

Step 2: Compile into a State Machine Program
Once the task is successfully completed, the sequence of decisions and actions is compiled. This creates a small program with defined states (which check specific parts of the screen) and transitions (the actions to take). This program is stored for future use.
Step 3: Replay for Subsequent Runs (Low Cost)
For all future attempts at the same task, the agent executes the compiled program directly. It follows the predetermined state checks and actions without calling the LLM for reasoning at each step, resulting in dramatic speed and cost reductions.