arXiv:2610.02932cs.AIOct 2026

Manuscript Offprint

arXiv:2610.02932

When to Compile a Computer-Use Agent? Measuring Payback and Making Compilation Decisions for Token Efficiency

Yulong Ming, Jie Xu, Zihan Wu, Xiaohua Jia

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Compiling GUI procedures that agents execute repeatedly into programs can reduce their token costs. However, measuring payback and deciding when to compile have two challenges. First, compilation costs are uncertain because attempts can require repair and still fail to produce a usable program. Second, future reuse is unknown because tasks may stop arriving or GUI drift may stop the program from working. To address these challenges, we propose PACE (Payback-Aware Compilation from Experience), a system with a measurement protocol and an online compilation algorithm. The measurement protocol records successful and failed compilation costs, and compares agent and program execution costs on matched task inputs to estimate per-use savings and payback counts. Using these measurements, the online algorithm compares estimated future savings with compilation costs, including failed attempts, based on past task arrivals and compilation outcomes. It checks execution and compilation charges against a cumulative budget determined by observed task arrivals before allowing either action. Under stated action-cost assumptions, total cost after each arrival is at most 1+ϵ1 + \epsilon times the cost of running every task with the agent. For successful compilation attempts, estimated payback counts excluding source agent runs are 2–16 uses. In simulations using recorded task arrivals, PACE reduces token costs by 17.3% compared with ReAct, 24.9% with the AutoRPA adaptation, and 17.3% with the ToolPro adaptation on average ( ϵ=0.25\epsilon = 0.25).

1 INTRODUCTION

Large language models have advanced rapidly. This progress enables computer-use agents. A computer-use agent interacts with applications through graphical user interfaces (GUIs). At each step, the agent reads the GUI as both a screenshot and a structured text tree, e.g., an accessibility or DOM tree (Hong et al., 2024; Zhang et al., 2025). It then runs a ReAct-style (Yao et al., 2023) agent loop, i.e., it calls the model to generate actions and executes them on the interface. Task success rates keep rising on benchmarks of web, desktop, and mobile tasks (Zhou et al., 2024; Xie et al., 2024; Rawles et al., 2025). However, computer-use agents consume more tokens than general agents because of the screenshot inputs, making them more expensive to run. Token efficiency, i.e., reducing the token cost, has become a first-order concern.

To improve token efficiency, prior systems reuse earlier experience. When an agent solves similar tasks repeatedly, starting from scratch requires it to rediscover the same procedure each time. To reduce this cost, prior systems store earlier experience as text (e.g., memory items or skills) (Wang et al., 2025b; Zheng et al., 2024) or compile it into parameterized programs by generating code (Wang et al., 2025a; Li, 2026; Chen et al., 2026a; El Yadouni & Li, 2026). A model call extracts the task inputs, which the program then uses to execute the procedure without further model calls. We focus on the program method, which has the highest token efficiency.

However, a low execution cost does not mean that compilation saves tokens over the full task stream. Prior audits report payback counts ranging from 4 (Chen et al., 2026a) to 17 (Trooskens et al., 2026) uses, where the payback count is the number of uses required for token savings to cover the compilation cost. Most systems report no payback count (El Yadouni & Li, 2026; Xu et al., 2026).

Moreover, these audits measure the costs of different system parts, making the numbers incomparable. We therefore ask two questions. How can we systematically measure the payback count? When is it worth compiling a program instead of continuing to use the agent?

Measuring the payback count and deciding when to compile have two challenges. Uncertain compilation cost. Producing a program may require multiple compilation attempts. Each attempt may consume tokens on repair, i.e., model calls that modify the program so it can complete the task. If the attempt produces no usable program, the system pays the compilation cost and continues to use the agent. Unknown future use. The system does not know how many later tasks can reuse the program. Similar tasks may stop arriving before they pay back the spend. GUI changes that make a deployed program stop working, i.e., GUI drift, can require a new compilation before further reuse. Therefore, compiling early can waste tokens if tasks do not repeat, while waiting can lose savings on tasks that repeat often. An online algorithm is required to make this choice using past observations.

Example task: Add a calendar event

Add Lab meeting · Oct 6, 10:00

Add Project review · Oct 8, 14:00

Add Reading group · Oct 13, 11:00

Same procedure

Different inputs

Open

Fill

Save

Two ways to execute the task

Agent: model calls at each step

Program: compile, then reuse

Compile

Extract inputs per use

Compilation attempt

Outcome

Token cost

</> Program

Failed early

Failed after repair

Costly failures leave no usable program

(a) Uncertain compilation cost

After successful compilation

Recovered

Unrecovered

Many tasks

Tasks stop

GUI drift

Too few reuses to pay back the cost

Cost to recover

(b) Unknown future use

Figure 1: Challenges in deciding when to compile GUI procedures. Top: an example task and its agent and program execution paths. In (a), red cost bars mark failed compilation attempts. In (b), red bar segments show compilation costs left unrecovered when task arrivals stop or GUI drift ends reuse.

We propose PACE (Payback-Aware Compilation from Experience), a system with a measurement protocol and an online compilation algorithm. PACE uses experience in two ways: completed agent traces provide the procedure to compile, while past task arrivals and compilation outcomes inform the decision to compile. The measurement separates the cost of producing a program from the saving after that program exists. We compare agent and program execution costs on matched task inputs, and estimate the additional cost of agent fallback after a detected program failure. The protocol compiles recorded agent traces, and records the token costs of successful and failed attempts. Deployment runs measure extraction cost and program failures. Additional compilations test whether the initial outcome repeats, and agent replays on the program's task inputs check this cost comparison. Across seven task families and three models, the measurements show per-use savings alongside differences in compilation cost and outcome.

PACE uses these measurements to decide when to compile under a cumulative cost constraint. A cost-aware compilation proposal compares estimated future savings with the estimated compilation cost of producing a program, including failed attempts. A separate budget check allows an action only when its possible cost fits the budget from task arrivals already observed. Total cost includes task execution, routing, and every successful or failed compilation. Under the stated cost model, PACE spends at most 1+ϵ1 + \epsilon times the reference cost of running every task with the agent after each arrival. The margin ϵ\epsilon limits the extra spend even when future-reuse estimates are wrong or compilation keeps failing. We evaluate the resulting savings and tradeoffs with measured cost profiles, synthetic arrivals, and arrival orders from public logs.

Our contributions are:

• We propose a measurement protocol for the costs and savings of compiling computer-use tasks. We report task-execution costs, compilation outcomes, repair costs, and payback counts under a shared accounting scheme, with repeated compilations and matched task-input replays.

• We propose an online compilation algorithm that uses a cost budget to decide whether to compile. PACE makes cost-aware proposals from past experience and checks their costs against a cumulative budget. We prove a cumulative bound under action-cost assumptions.

• We implement PACE and evaluate it under different cost settings and task arrival patterns. We release the measurement records, policy implementations, and paired experimental outcomes. With ϵ=0.25\epsilon = 0.25, PACE reduces token costs by 17.3% relative to ReAct, 24.9% relative to the AutoRPA adaptation, and 17.3% relative to the ToolPro adaptation on average across the recorded-arrival simulations. Ablations separate the effects of the savings test, cost budget, and failed-attempt cost.

References (77)