FrugentSign in ↗

Token economics

How to reduce AI agent token costs in browser automation

Reduce AI browser-agent costs with stable context, smaller tool results, reusable plans and bounded retries. Includes token math and a success-based cost metric.

An AI browser agent can make many model calls to finish one task. Each call may carry instructions, conversation history and a fresh view of the page. A low price per token does not guarantee a low cost per completed workflow. Start by finding where the same work happens repeatedly.

Count the loop, not just the final answer

Imagine a hypothetical ten-step workflow. Each step sends 4,000 input tokens and generates 200 output tokens. Before retries, the run has used 40,000 input tokens and 2,000 output tokens. Those are illustrative counts, not a Frugent measurement.

Now suppose the run gets stuck and repeats three steps. The additional calls belong in the cost of that task. A dashboard that records only the final successful call will make the workflow look cheaper than it is.

Keep reusable context stable

Separate durable instructions from changing page state. Avoid inserting request-specific noise ahead of content you intend to reuse. Check your provider’s cache boundaries and token usage rather than assuming every repeated prompt is discounted.

OpenAI’s prompt-caching guidance discusses preserving eligible prefixes and diagnosing cache reuse. Treat that as one optimization within the agent loop: cached input is still input, and a model call can still generate output and incur other charges.

Send the page information the next decision needs

A full page dump can contain menus, footers, duplicated navigation and unrelated records. Consider returning a bounded, relevant view: the selected report, the form being completed, or the controls in the active dialog. Keep enough surrounding context to identify the correct target.

Do not remove information merely to improve the token count. Hiding an account label or a warning can cause a more expensive mistake. Measure whether a smaller observation preserves the task’s success rate on realistic pages, including failures and changed layouts.

Reuse procedures and keep live data fresh

If the task repeatedly navigates the same website, a validated action map can reduce repeated planning. Keep task-specific values as inputs, check the current page, and fetch changing results when needed. Reusing an instruction to open a report is different from reusing the report’s old contents.

Frugent’s Action Map Registry is designed around this distinction. A compatible map may help even on a user’s first run; saved execution steps can provide further reuse on repeat tasks. A registry miss still needs setup and validation.

Put a budget on retries

Define what progress looks like before allowing another loop. Examples include reaching the expected page, locating a unique control, or obtaining a required field. Stop when repeated attempts produce no new evidence.

For an action whose outcome is uncertain, inspect the resulting state before trying again. Repeating a purchase or message submission can be far more costly than the inference saved. A retry budget should protect both money and correctness.

Optimize cost per successful task

Record total model spend, tool or browser infrastructure charges, validation and recovery work, and the number of tasks that met a defined success condition. Divide the total by successful tasks. Include unsuccessful attempts in the numerator.

Compare the same workload before and after each change. Keep the model, task inputs and success checks consistent when testing caching. If you change several things together, report the combined result rather than attributing every improvement to the cache.

Sources and further reading

Keep exploring

Compare local plans · Get started

AI agent latency vs token cost: measure both

Separate inference latency, tool execution and user wait time. Learn why fewer tokens, faster responses and lower workflow costs are different outcomes.

LLM cache hit rate: measure real cost savings

Learn the difference between request and token cache-hit rates, calculate cache break-even, and compare cost per successful AI task with a worked example.

Prompt caching vs response caching: LLM cost guide

Compare prompt caching, response caching and action caching. Learn which repeated AI work each removes, when reuse is safe, and how to measure the result.