When to Compile a Computer-Use Agent? Measuring Payback and Making Compilation Decisions for Token Efficiency
Organizations: City University of Hong Kong
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 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 ().
Figures & tables
| Family | Attempt cost (K tokens) | Before repair (3/3 required) | After repair (3/3 required) | Compilation-only payback (uses) | Trace-inclusive payback (uses) |
|---|---|---|---|---|---|
| Contacts | 137 605 138 | 0/1/2 0/1/2 3/0/0 | 3/0/0 0/1/2 3/0/0 | 1.39 – 3.7 | 4.4 – 6.85 |
| Markor delete | 144 156 212 | 0/1/2 0/1/2 3/0/0 | 3/0/0 3/0/0 3/0/0 | 4.31 15.5 10 | 7.34 18.7 13.1 |
| Calendar | 3424 2872 1936 | 0/1/2 0/1/2 0/1/2 | 3/0/0 0/1/2 0/1/2 | 10.9 – – | 13.9 – – |
| OsmAnd marker | 3082 1701 1552 | 0/1/2 0/1/2 0/1/2 | 2/1/0 0/1/2 0/1/2 | – – – | – – – |
| Calc table | 2544 3057 3054 | 0/1/2 0/1/2 0/1/2 | 0/1/2 3/0/0 0/1/2 | – 4.73 – | – 7.74 – |
| Writer memo | 473 259 487 | 0/1/2 0/1/2 3/0/0 | 3/0/0 3/0/0 3/0/0 | 6.8 5.18 13.4 | 9.82 8.22 16.5 |
| Policy | Grid 1 mean ( PACE) | Grid 1 max ( PACE) | Grid 2 mean ( PACE) | Grid 2 max ( PACE) |
|---|---|---|---|---|
| ReAct | 1.121 1.144 1.056 | 2.796 3.495 2.281 | 1.147 1.174 1.070 | 3.692 3.128 2.742 |
| AutoRPA | 2.107 1.942 2.715 | 11.997 9.660 19.314 | 2.168 2.006 2.805 | 16.034 12.927 26.538 |
| ToolPro | 1.121 1.144 1.056 | 2.796 3.495 2.281 | 1.147 1.174 1.070 | 3.692 3.128 2.742 |
| PACE | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 |
| Policy | Sepsis ( PACE) | BPI 2019 ( PACE) | Wiki tools ( PACE) | Wiki humans ( PACE) |
|---|---|---|---|---|
| ReAct | 0.971 0.998 0.989 | 1.531 1.603 1.393 | 1.730 1.480 1.288 | 1.056 1.060 1.040 |
| AutoRPA | 1.145 1.123 1.246 | 1.582 1.641 1.489 | 1.754 1.498 1.331 | 1.164 1.144 1.232 |
| ToolPro | 0.971 0.998 0.989 | 1.531 1.603 1.393 | 1.730 1.480 1.288 | 1.056 1.060 1.040 |
| PACE | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 |
| Variant | Grid 1 mean ( PACE) | Grid 2 mean ( PACE) | Logs mean ( PACE) | Grid max ( PACE) |
|---|---|---|---|---|
| PACE | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 |
| No savings test | 1.174 1.186 1.181 | 1.140 1.167 1.121 | 1.581 1.548 1.451 | 1.957 1.810 1.901 |
| No cost budget | 1.008 1.014 1.007 | 1.015 1.016 1.010 | 1.000 1.000 1.000 | 1.371 1.410 1.301 |
| Equal attempt costs | 1.100 1.093 1.119 | 1.082 1.095 1.077 | 1.227 1.175 1.297 | 1.568 1.567 1.466 |
| Eager retry | 10.317 8.414 18.329 | 10.919 9.352 19.286 | 3.303 3.326 4.922 | 92.863 73.996 195.631 |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| Family | (K tokens) | (K tokens) | (fraction) | Saving share (fraction) |
|---|---|---|---|---|
| Contacts | 98.7 – 39.2 | 0.425 – 0.552 | 0.000 – 0.033 | 0.996 – 0.953 |
| Markor delete | 33.7 10.8 21.5 | 0.332 0.331 0.388 | 0.000 0.033 0.000 | 0.990 0.936 0.982 |
| Calendar | 314 – – | 0.640 – – | 0.000 – – | 0.998 – – |
| OsmAnd marker | – – – | – – – | – – – | – – – |
| Calc table | – 647 – | – 0.677 – | – 0.000 – | – 0.999 – |
| Writer memo | 70.2 50.7 37.0 | 0.596 0.692 0.724 | 0.000 0.000 0.000 | 0.992 0.986 0.980 |
| Family | Mean (K tokens) | Agent successes (of 30) | Program successes (of 30) | Saving share (fraction) |
|---|---|---|---|---|
| Contacts | 67.1 – 42.2 | 30/30 – 30/30 | 30/30 – 29/30 | 0.994 – 0.954 |
| Markor delete | 35.4 22.3 19.3 | 30/30 23/30 30/30 | 30/30 29/30 30/30 | 0.991 0.952 0.980 |
| Calendar | 535.3 – – | 14/30 – – | 30/30 – – | 0.999 – – |
| OsmAnd marker | – – – | – – – | – – – | – – – |
| Family | Verification outcomes | Given (of 5) | Extracted (of 5) |
|---|---|---|---|
| Contacts | P/P/P F/F/P P/G/P | 0/5 – 5/5 | 0/5 – 5/5 |
| Markor delete | P/P/P P/P/P P/P/P | 5/5 5/5 5/5 | 5/5 5/5 5/5 |
| Calendar | P/P/P F/G/F F/G/G | 3/5 – – | 3/5 – – |
| OsmAnd marker | F/F/F F/F/F – | – – – | – – – |
| Calc table | – – – | – – – | – – – |
| Writer memo | – – – | – – – | – – – |
| Family | (tokens) | Failures (of 30) 95% CI (fraction) |
|---|---|---|
| Contacts | 424.5 – 552.1 | 0/30 – 1/30 |
| Markor delete | 331.6 330.6 388.1 | 0/30 1/30 0/30 |
| Calendar | 640.0 – – | 0/30 – – |
| OsmAnd marker | – – – | – – – |
| Calc table | – 676.6 – | – 0/30 – |
| Writer memo | 596.3 692.0 724.1 | 0/30 0/30 0/30 |
| Family | Mean (K tokens) | Agent CV (ratio) |
|---|---|---|
| Contacts | 67.1 – 42.2 | 0.326 – 0.099 |
| Markor delete | 35.4 22.3 19.3 | 0.373 1.042 0.128 |
| Calendar | 535.3 – – | 0.485 – – |
| OsmAnd marker | – – – | – – – |
| Family | Agent successes (of 30) 95% CI (fraction) | Program successes (of 30) 95% CI (fraction) | Saving share (fraction) |
|---|---|---|---|
| Contacts | 30/30 – 30/30 | 30/30 – 29/30 | 0.994 – 0.954 |
| Markor delete | 30/30 23/30 30/30 | 30/30 29/30 30/30 | 0.991 0.952 0.980 |
| Calendar | 14/30 – – | 30/30 – – | 0.999 – – |
| OsmAnd marker | – – – | – – – | – – – |
| Family | Given (of 5) 95% CI (fraction) | Extracted (of 5) 95% CI (fraction) |
|---|---|---|
| Contacts | 0/5 – 5/5 | 0/5 – 5/5 |
| Markor delete | 5/5 5/5 5/5 | 5/5 5/5 5/5 |
| Calendar | 3/5 – – | 3/5 – – |
| OsmAnd marker | – – – | – – – |
| Scenario : cost ratio | ReAct ( PACE) | PACE ( PACE) | Equal attempt costs ( PACE) | Equal / PACE (all models) |
|---|---|---|---|---|
| 1.280 1.226 1.066 | 1.000 1.000 1.000 | 0.998 1.012 1.027 | 1.012 | |
| 1.322 1.241 1.131 | 1.000 1.000 1.000 | 1.000 1.005 1.000 | 1.002 | |
| 1.334 1.241 1.177 | 1.000 1.000 1.000 | 1.030 1.032 0.999 | 1.020 | |
| 1.261 1.210 1.191 | 1.000 1.000 1.000 | 1.106 1.174 1.143 | 1.141 | |
| Cost-dependent | 1.601 2.046 1.783 | 1.000 1.000 1.000 | 1.141 1.083 1.144 | 1.123 |
| Cost-dependent + costly frequent | 0.958 1.000 1.000 | 1.000 1.000 1.000 | 0.989 1.100 1.078 | 1.056 |
| Policy | Grid 1 mean ( PACE) | Grid 1 max ( PACE) | Grid 2 mean ( PACE) | Grid 2 max ( PACE) |
|---|---|---|---|---|
| ReAct | 1.121 1.144 1.056 | 2.796 3.495 2.281 | 1.147 1.174 1.070 | 3.692 3.128 2.742 |
| AutoRPA | 2.107 1.942 2.715 | 11.997 9.660 19.314 | 2.168 2.006 2.805 | 16.034 12.927 26.538 |
| ToolPro | 1.121 1.144 1.056 | 2.796 3.495 2.281 | 1.147 1.174 1.070 | 3.692 3.128 2.742 |
| Eager + allowance | 1.036 1.070 1.007 | 1.449 1.492 1.314 | 1.033 1.093 1.007 | 1.455 1.525 1.321 |
| After 10 arrivals | 1.032 1.032 1.007 | 1.449 1.492 1.314 | 1.029 1.055 1.007 | 1.455 1.525 1.321 |
| After 10 successes | 1.068 1.083 1.028 | 1.716 1.414 1.323 | 1.073 1.113 1.034 | 1.592 1.505 1.451 |
| Policy | Sepsis ( PACE) | BPI 2019 ( PACE) | Wiki tools ( PACE) | Wiki humans ( PACE) |
|---|---|---|---|---|
| ReAct | 0.971 0.998 0.989 | 1.531 1.603 1.393 | 1.730 1.480 1.288 | 1.056 1.060 1.040 |
| AutoRPA | 1.145 1.123 1.246 | 1.582 1.641 1.489 | 1.754 1.498 1.331 | 1.164 1.144 1.232 |
| ToolPro | 0.971 0.998 0.989 | 1.531 1.603 1.393 | 1.730 1.480 1.288 | 1.056 1.060 1.040 |
| Eager + allowance | 1.007 1.027 0.997 | 1.002 0.995 1.057 | 1.004 0.997 1.003 | 1.005 1.021 1.001 |
| After 10 arrivals | 1.010 1.010 0.997 | 1.003 0.988 1.057 | 1.005 0.994 1.003 | 1.006 1.008 1.001 |
| After 10 successes | 1.007 1.011 1.003 | 1.123 1.131 1.147 | 1.241 1.128 1.068 | 1.024 1.025 1.015 |
| Variant | Grid 1 mean ( PACE) | Grid 2 mean ( PACE) | Logs mean ( PACE) | Grid max ( PACE) |
|---|---|---|---|---|
| PACE | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 1.000 1.000 | 1.000 |
| No savings test | 1.174 1.186 1.181 | 1.140 1.167 1.121 | 1.581 1.548 1.451 | 1.957 |
| No cost budget | 1.008 1.014 1.007 | 1.015 1.016 1.010 | 1.000 1.000 1.000 | 1.410 |
| Equal attempt costs | 1.100 1.093 1.119 | 1.082 1.095 1.077 | 1.227 1.175 1.297 | 1.568 |
| Eager retry | 10.317 8.414 18.329 | 10.919 9.352 19.286 | 3.303 3.326 4.922 | 195.631 |
| Variant | Grid 1 cost (%) | Grid 2 cost (%) | Logs cost (%) | Grid max ( PACE) |
|---|---|---|---|---|
| PACE | 0.0 0.0 0.0 | 0.0 0.0 0.0 | 0.0 0.0 0.0 | 1.000 1.000 1.000 |
| No savings test | 17.4 18.6 18.1 | 14.0 16.7 12.1 | 58.1 54.8 45.1 | 1.957 1.810 1.901 |
| No cost budget | 0.8 1.4 0.7 | 1.5 1.6 1.0 | 0.016 -0.013 0.002 | 1.371 1.410 1.301 |
| Equal attempt costs | 10.0 9.3 11.9 | 8.2 9.5 7.7 | 22.7 17.5 29.7 | 1.568 1.567 1.466 |
| Eager retry | 931.7 741.4 1732.9 | 991.9 835.2 1828.6 | 230.3 232.6 392.2 | 92.863 73.996 195.631 |
| Serving path | Success (of 12) | Interrupted (count) | Mean cost bounds (milli-USD) |
|---|---|---|---|
| Agent | 7/12 | 4 | [8.142, 21.590] |
| Program + fallback | 11/12 | 1 | [1.202, 4.564] |
| Seed | Condition | Agent | P+F | Agent cost (milli-USD) | P+F cost (milli-USD) | Fields (of 6) |
|---|---|---|---|---|---|---|
| 0 | Clean | Interrupted | Success | [5.147, 45.493] | 0.048 | – |
| 0 | Renamed submit | Interrupted | Success | [2.050, 42.396] | 0.763 | 6/6 |
| 0 | Blocking dialog | Step limit | Success | 17.156 | 1.255 | 6/6 |
| 1 | Clean | Success | Success | 9.687 | 0.048 | – |
| 1 | Renamed submit | Success | Success | 6.831 | 0.763 | 6/6 |
| 1 | Blocking dialog | Success | Success | 11.091 | 1.129 | 6/6 |
| Arrival | Condition | Outcome | Cost (milli-USD) | Prefix ceiling (milli-USD) | Prefix total (milli-USD) |
|---|---|---|---|---|---|
| 1 | Renamed submit | Denied | 0.000 | 25.000 | 0.000 |
| 2 | Blocking dialog | Success | 1.257 | 50.000 | 1.257 |
| 3 | Renamed submit | Success | 0.890 | 75.000 | 2.147 |
| 4 | Blocking dialog | Interrupted | [0.215, 40.561] | 100.000 | 42.708 |
Computer-Use Agents
Computer-use agents perceive and operate graphical interfaces and software tools to complete tasks across websites, apps, and desktops.
See all 160 papers