[Blog](https://cohesivity.ai/blog)

Foundational

Published Jun 22, 2026·Updated Aug 30, 2026

![](https://cohesivity.ai/authors/shouryamaan.webp)![](https://cohesivity.ai/authors/arag.webp)[Shouryamaan](https://www.linkedin.com/in/shouryamaanjain/) and [Arag](https://www.linkedin.com/in/aragagrawal/)

# AI Agent Infrastructure Costs: Models, Storage, Compute, and Tool Calls

[Read as Markdown](https://cohesivity.ai/blog/ai-agent-infrastructure-costs.md)

Workload

Runtime

Meter

Budget

AI agent infrastructure cost is the cost of a completed task, including model tokens, paid tools, execution time, storage, network use, retries, and idle resources. Tracking only the model invoice misses the parts that grow when an agent takes a longer path or fails halfway through.

The right denominator is a useful outcome such as a resolved ticket, deployed application, or reviewed document. Cost per request can improve while cost per completed task gets worse if more requests fail.

## The six cost components

### Model tokens

Record input, cached input, reasoning where the provider exposes it, and output tokens for every model call. Prices differ by model and can change, so calculate from stored usage and a versioned price table rather than hard-coding one blended rate.

Provider pages such as [OpenAI API pricing](https://openai.com/api/pricing/) publish the billing units. Keep the exact price used for a historical run in your own record, because recomputing an old run with today's price rewrites the past.

### Paid tools and external APIs

Search, browser sessions, speech, email, image generation, maps, and data providers may charge per call, result, minute, or byte. Record the provider operation next to the agent tool call so one workflow trace can explain both behavior and cost.

A tool that returns an ambiguous result may cost more through retries than through its listed unit price. The [guide to debugging wrong tool use](https://cohesivity.ai/blog/how-to-debug-an-ai-agent-that-uses-the-wrong-tool) helps separate selection failures from provider failures.

### Agent and sandbox runtime

Count active CPU or worker time, memory duration, sandbox minutes, and any minimum session charge. Long model waits can keep a sandbox alive even when no code runs. Record both active execution and total lifetime when the provider bills the latter.

### Database, storage, and network

Persistent services create a baseline cost independent of the number of agent runs. Include database compute, retained logs, checkpoints, vector indexes, object storage, and network egress. Attribute shared resources by a stable rule such as tenant usage, workflow writes, or storage bytes, and keep that rule visible.

### Retries and failed runs

Let `attempted cost` include every run, successful or not:

```text
cost per successful task = total attempted cost / successful tasks

```

If 20 of 100 runs fail after consuming most of their budget, the surviving 80 outcomes absorb that spend. This is why the [production agent guide](https://cohesivity.ai/blog/running-ai-agents-in-production) treats bounded retries as a cost and reliability control together.

### Idle resources

An agent may create a database, deployment, or sandbox and never remove it. Track resources that outlive the run, their owner, last activity, and cleanup deadline. A per-run cost dashboard will miss them unless the resource record points back to the workflow that created it.

## A calculation you can audit

For one workflow, calculate:

```text
run cost = model + paid tools + runtime + storage allocation + network

completed-task cost =
  sum of successful, failed, and retried run costs
  divided by completed tasks

```

Report the median and p95\. The average alone hides a small number of long loops, while the maximum may describe an incident rather than normal operation. Keep the maximum as a separate alert case.

## Set budgets where the cost occurs

| Cost source  | Enforceable limit                                     |
| ------------ | ----------------------------------------------------- |
| Model use    | Tokens, calls, or currency per run                    |
| Tools        | Calls per tool and repeated identical arguments       |
| Runtime      | Wall-clock time, CPU, memory, and concurrent sessions |
| Storage      | Bytes, retained artifacts, and checkpoint lifetime    |
| Retries      | Attempts per operation and total retry spend          |
| Provisioning | Resource count, tier, and automatic expiry            |

The runtime should stop work when a limit is reached. A prompt asking the model to be economical is useful guidance, but it cannot enforce a budget.

## How Cohesivity usage fits the model

Cohesivity separates metered provider activity from plan quotas. Its pricing page describes current [bucket and fluid allowances](https://cohesivity.ai/pricing). Map fluid usage to the provider calls that caused it, and map bucket usage to the provisioned service or account quota it consumes.

Do not collapse those records into a single Cohesivity number if the goal is diagnosis. You still need to see that a browser loop, model retry, or forgotten deployment caused the change.

## Measure before estimating scale

Choose one representative task and capture every model call, tool call, retry, runtime interval, and created resource. Mark values as measured, configured, or assumed. Then calculate the normal case, p95, and one failure loop.

The prompt below prepares that model from the project without spending money while it investigates.

or send it to[Claude Code](https://claude.ai/new?q=Inspect+this+project+and+choose+one+representative+AI+agent+workflow.+Do+not+make+code+changes+or+call+paid+services.+Build+a+cost+model+per+successful+completion+that+includes+input+and+output+tokens+by+model%2C+paid+tool+and+search+calls%2C+sandbox+or+worker+runtime%2C+database+and+storage+usage%2C+network+egress%2C+retry+rate%2C+failed-run+rate%2C+and+idle+provisioned+resources.+Separate+measured+values+from+assumptions+and+attach+a+source+or+configuration+path+to+every+measured+value.+Calculate+cost+at+the+median%2C+p95%2C+and+one+plausible+failure+loop.+Then+propose+hard+per-run+budgets+and+the+telemetry+needed+to+enforce+them.+If+Cohesivity+is+already+present%2C+map+its+bucket+and+fluid+usage+into+the+same+model. "Send to Claude")[Cursor](https://cursor.com/link/prompt?text=Inspect+this+project+and+choose+one+representative+AI+agent+workflow.+Do+not+make+code+changes+or+call+paid+services.+Build+a+cost+model+per+successful+completion+that+includes+input+and+output+tokens+by+model%2C+paid+tool+and+search+calls%2C+sandbox+or+worker+runtime%2C+database+and+storage+usage%2C+network+egress%2C+retry+rate%2C+failed-run+rate%2C+and+idle+provisioned+resources.+Separate+measured+values+from+assumptions+and+attach+a+source+or+configuration+path+to+every+measured+value.+Calculate+cost+at+the+median%2C+p95%2C+and+one+plausible+failure+loop.+Then+propose+hard+per-run+budgets+and+the+telemetry+needed+to+enforce+them.+If+Cohesivity+is+already+present%2C+map+its+bucket+and+fluid+usage+into+the+same+model. "Send to Cursor")[Codex](https://chatgpt.com/codex?prompt=Inspect+this+project+and+choose+one+representative+AI+agent+workflow.+Do+not+make+code+changes+or+call+paid+services.+Build+a+cost+model+per+successful+completion+that+includes+input+and+output+tokens+by+model%2C+paid+tool+and+search+calls%2C+sandbox+or+worker+runtime%2C+database+and+storage+usage%2C+network+egress%2C+retry+rate%2C+failed-run+rate%2C+and+idle+provisioned+resources.+Separate+measured+values+from+assumptions+and+attach+a+source+or+configuration+path+to+every+measured+value.+Calculate+cost+at+the+median%2C+p95%2C+and+one+plausible+failure+loop.+Then+propose+hard+per-run+budgets+and+the+telemetry+needed+to+enforce+them.+If+Cohesivity+is+already+present%2C+map+its+bucket+and+fluid+usage+into+the+same+model. "Send to Codex")[opencode](https://opencode.ai/?q=Inspect+this+project+and+choose+one+representative+AI+agent+workflow.+Do+not+make+code+changes+or+call+paid+services.+Build+a+cost+model+per+successful+completion+that+includes+input+and+output+tokens+by+model%2C+paid+tool+and+search+calls%2C+sandbox+or+worker+runtime%2C+database+and+storage+usage%2C+network+egress%2C+retry+rate%2C+failed-run+rate%2C+and+idle+provisioned+resources.+Separate+measured+values+from+assumptions+and+attach+a+source+or+configuration+path+to+every+measured+value.+Calculate+cost+at+the+median%2C+p95%2C+and+one+plausible+failure+loop.+Then+propose+hard+per-run+budgets+and+the+telemetry+needed+to+enforce+them.+If+Cohesivity+is+already+present%2C+map+its+bucket+and+fluid+usage+into+the+same+model. "Send to OpenCode")
