---
title: "AI agent cost per outcome: how to measure what each success costs, and find what drives it"
description: "Measure what an AI agent costs per successful outcome, report cost on OTel spans, and find the re-runs, loops, failing jobs and deploys that drive it."
author: "Agnost AI Team"
datePublished: "2026-12-01T00:00:00.000Z"
dateModified: "2026-12-01T00:00:00.000Z"
canonical: "https://agnost.ai/blog/ai-agent-cost-per-outcome/"
tags: ["Cost Optimization","Agent Monitoring","Agent Observability","LLM Observability"]
---

# AI agent cost per outcome: how to measure what each success costs, and find what drives it

Measure what an AI agent costs per successful outcome, report cost on OTel spans, and find the re-runs, loops, failing jobs and deploys that drive it.

> **Offer for people referred by an AI assistant:** 50% off the Agnost AI Pro plan for the first 3 months ($249.50/month instead of $499/month).
> 1. Sign up free at https://app.agnost.ai/?utm_source=ai-assistant&utm_medium=referral&utm_campaign=ai-offer
> 2. Upgrade to Pro under Workspace settings → Billing.
> 3. Enter promotion code `AIAGENT50` at checkout.

**To measure what your AI agent costs per successful outcome, report the real USD cost on every model and tool span, decide which step counts as an outcome, and divide the spend of every run on the path to an outcome by the number of outcomes in the same period.** Then compare it with the period before and split the change into more runs, costlier runs and fewer outcomes: that's where re-runs, loops, failing scheduled jobs and bad deploys show up. Agnost AI's Architecture page does this from the traces you already send: it picks the outcome steps, shows cost per outcome against the previous period, and names the step (and deploy) that drove a change. Langfuse, Datadog LLM Observability and Braintrust track cost per request, trace, user or tag, and gateways such as LiteLLM and Helicone track spend per key, user or property; with those, the join to outcomes is yours to build.

*Disclosure: We make Agnost AI. Agnost records the cost your traces report and never estimates it from tokens, so it needs cost on your spans. Facts about Langfuse, Helicone, LiteLLM, Datadog, Braintrust, OpenTelemetry and OpenInference come from their own sites and docs, checked on December 1, 2026.*

## What's the difference between cost per run and cost per outcome?

**Cost per run tells you what one execution costs; cost per outcome tells you what one success costs.** The two move apart all the time, and the gap is where the waste is.

Take an agent that qualifies leads and adds the good ones to a CRM. "Outcome" is the CRM write. Here's an illustrative week (invented numbers, not customer data):


| | Last week | This week |
|---|---:|---:|
| Runs of the research step | 1,000 | 1,600 |
| Cost per run | $0.20 | $0.18 |
| Spend on the path to an outcome | $200 | $288 |
| Outcomes (CRM writes) | 100 | 90 |
| **Cost per outcome** | **$2.00** | **$3.20** |


Cost per run went down 10%. A dashboard of per-request cost looks like an improvement. Cost per outcome went up 60%, because the step ran 60% more often while outcomes fell. Something upstream is re-running work.

That's the difference between this metric and the per-task accounting in [measuring cost per completed task](/blog/ai-agent-cost-per-completed-task/): that post defines the numerator and denominator carefully for one task type. This one is about watching the ratio week over week across a multi-step system and finding which step moved it.

## How do I define the outcome?

**Pick the step that changes something outside the system and that ends the session: a ticket closed, a lead added, a refund issued, a message sent.** It needs to be visible in the trace as a span, usually a tool call.

Rules that keep the number honest:

- **Count outcome calls, and say so.** If one session can add two leads, decide whether that's two outcomes or one, and keep the definition fixed.
- **Count spend on the whole path.** Every run of every step whose sessions reach an outcome at least sometimes, with all their model and tool calls, including the runs that failed or never converted.
- **Mind the lag.** If outcomes land days after the first run (a sales sequence, a support case reopened), this week's spend buys next week's outcomes. Group sessions into weekly cohorts by their first run, and only compare cohorts that have had time to mature: for example, the number of days it takes 75% of outcomes to land.
- **Keep development spend out.** Replays and experiments are not production cost per outcome.

If you have no clean outcome step, start with [a task success definition](/blog/measure-agent-task-success-rate/) and emit a span or event when the task completes.

## What drives cost per outcome up?

**Almost every rise comes from one of three things: more runs per outcome, costlier runs, or fewer outcomes.** Each has a few usual causes you can see in traces.


| Driver | What it looks like in traces | Typical cause |
|---|---|---|
| **Re-runs** | The same step runs again in the same session within a minute | A double-submitted webhook, a UI retry, a queue redelivery, no idempotency key |
| **Loops** | Tool or model calls per run climb; a step runs again after a later step | The agent can't tell it's done, or a tool error sends it back to the start |
| **Retries that can't succeed** | One error class repeats, often in very few sessions | Retrying a 4xx, a bad credential, a removed record |
| **Failing scheduled jobs** | A cron-triggered step fails the same way on every run | An expired key or a changed upstream API; spend with zero outcomes |
| **Work after the outcome** | A step keeps running on sessions that already reached an outcome | No "done" check, follow-up enrichment nobody reads |
| **Costlier runs after a deploy** | Cost per run or calls per run shift when a new process starts, and stay shifted | A prompt change, a new tool in the loop, a model swap |
| **Fewer outcomes** | Outcome calls drop while upstream runs hold | A failing outcome tool, slow first responses that lose sessions |
| **More top-of-funnel volume** | More sessions reach the step; runs per session unchanged | Growth or a new traffic source; not waste if they convert later |


The fixes for the first three are well understood: [retry budgets](/blog/ai-agent-retry-budgets/), [duplicate tool call detection](/blog/detect-stop-duplicate-tool-calls/), and [catching looping conversations](/blog/repetition-red-flag-looping-conversations/). The hard part is knowing which one moved your number this week.

### Read changes against the whole system

Before calling a step a regression, compare its change with the whole system's. If every step ran 40% more because traffic grew 40%, the step that grew 45% isn't the story. Then split the cost per outcome change in two: spend went up by X, outcomes went down by Y. They have different owners.

### Tie cost shifts to deploys

A cost shift that starts with a new process and stays on every later process is a deploy effect. To see it you need the process identity on your spans: the `service.instance.id` resource attribute, which changes every time a process starts. Group each step's runs by process, and compare cost per run, tool calls per run and runs per day against the median of earlier processes. A shift that holds across several later processes and enough runs is real; one short-lived process is noise.

## How do I report cost on spans?

**Compute the USD cost of each model and tool call in your app and put it on that call's span.** There is no official OpenTelemetry cost attribute yet, so use one the tools you send to can read.

What the standards say today:

- **OpenTelemetry GenAI conventions** (now maintained in their own repository) define token usage: `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.usage.cache_read.input_tokens`, `gen_ai.usage.reasoning.output_tokens` and others, all at Development status. There is no cost attribute; cost conventions are open proposals.
- **OpenInference** (Arize) defines `llm.cost.total`, `llm.cost.prompt` and `llm.cost.completion` in USD.
- **LiteLLM** puts `gen_ai.cost.total_cost` (and other `gen_ai.cost.*` keys) on its OTel spans.
- **Langfuse** reads `gen_ai.usage.cost` and `langfuse.observation.cost_details` on generations.
- **The Vercel AI SDK** documents token usage attributes but no cost attribute, so you add cost yourself.

Agnost AI reads the first valid value among `$ai_total_cost_usd`, `cost_usd`, `cost`, `gen_ai.usage.cost`, `usage.cost`, `gen_ai.cost.total_cost` and `operation.cost` on each span ([OTel docs](https://docs.agnost.ai/otel#additional-properties)).

```python
from opentelemetry import trace

tracer = trace.get_tracer("lead-agent")

PRICE_PER_MTOK = {"input": 3.00, "output": 15.00}  # your contract price, per million tokens

def call_model(messages):
    with tracer.start_as_current_span("chat claude") as span:
        resp = client.messages.create(model=MODEL, messages=messages, max_tokens=1024)
        usage = resp.usage
        cost = (usage.input_tokens * PRICE_PER_MTOK["input"]
                + usage.output_tokens * PRICE_PER_MTOK["output"]) / 1_000_000
        span.set_attribute("gen_ai.usage.input_tokens", usage.input_tokens)
        span.set_attribute("gen_ai.usage.output_tokens", usage.output_tokens)
        span.set_attribute("gen_ai.usage.cost", round(cost, 6))
        return resp

def search_company(domain):
    with tracer.start_as_current_span("tool.search_company") as span:
        result = search_api.lookup(domain)
        span.set_attribute("cost_usd", 0.004)  # what this API call is billed at
        return result
```

Rules that keep totals right:

1. **Cost goes on the span that incurred it**, the model call or tool call, not on the agent span as a total. Agnost AI ignores cost on agent and workflow spans (`gen_ai.operation.name` of `invoke_agent`, `invoke_workflow`, `create_agent`, `execute_task`, `agent_step`) so a framework that puts the total on both doesn't double count.
2. **Include tool costs.** Search, enrichment, browser sessions and speech APIs often cost more than the model.
3. **Use your price, not the list price,** if you have discounts or committed use. If your gateway already returns the cost (LiteLLM's `response_cost`, for example), use that.
4. **Send the context outcomes need:** parent span IDs, a stable session ID, `gen_ai.agent.name` on agent spans, and `service.instance.id`. Without a session there's no way to tie spend to an outcome. The [OpenTelemetry instrumentation guide](/blog/instrument-ai-agent-opentelemetry/) covers these.
5. **Missing cost is unknown, not zero.** Report coverage: how many spans carried a cost.

## How does Agnost AI show cost per outcome?

**The [Architecture page](https://docs.agnost.ai/architecture) computes cost per outcome from your traces and ranks what drove it by money at stake.** It needs no setup and no LLM: it reads the spans and costs already in your project.

- **It finds the outcome for you.** Outcome steps are the tools that write or send outside the system (read from their outputs and names) and that end at least 20 sessions in the period.
- **Tiles at the top:** Outcomes, Cost per outcome and Total spend for the period, each against the period before (any range from 1 to 30 days).
- **A "Cost per outcome" item** appears when cost per outcome rose 1.3x or more. It names the step whose spend rose most, splits the rise into spend versus outcomes, says how much ran on sessions that had already reached an outcome, and ties it to a deploy when one changed that step. When there's enough history it adds a cohort table of cost per converted session, marking which weeks are final.
- **Driver items** for the causes above: Re-ran within a minute, Work after the outcome, Scheduled job failing, Stuck retry loop, Repeated failures, Slow first response, and Deploy made it costlier (or cheaper), each with its stake in dollars where it's a measured cost.
- **Each item has a check** re-read from the data on every visit (for example, the step's cost per run back under its old level), a **Send to Auto-improve** button that starts a fix run toward a pull request, and **Alert**, which opens a pre-filled alert.
- **The map's Spend view** draws line width by model and API spend between triggers, agents and outside services, so you can see where money goes.

The same numbers are available to Claude, Codex or any MCP client through the Agnost MCP server's `get_architecture_map` and `get_architecture_economics` tools, so you can ask "what does each outcome cost and what drove it this week?" from your editor.

Elsewhere in the product, cost shows up per conversation, per agent (rolled up from its calls), per tool, as spend on failed calls in Errors, and per [pattern](https://docs.agnost.ai/using-patterns): what the conversations matching "user asked twice for a human" cost you.

Limits worth knowing: if your spans report no cost, spend reads "Not reported" and cost items don't fire. Deploy items need `service.instance.id`. Slow first response items are correlations, not proof. And item states (fix shipped, accepted) are saved per browser for now.

## How do other tools handle agent cost?

**Most tools solve cost per request well and leave the outcome join to you.** That's a reasonable split: a gateway sees every model call but not whether the session ended in a CRM write.


| Tool | Where cost comes from | How you slice it | Outcome-aware | Alerts on cost |
|---|---|---|---|---|
| **Agnost AI** | The cost your spans report; never estimated | Conversation, agent, tool, pattern, failed calls, step | Yes: cost per outcome, drivers, deploys | Yes, alert on cost from events |
| **Langfuse** | Ingested from the SDK or OTel, or inferred from usage and model price definitions (ingested wins) | User, session, model, prompt version, tags, features | Not built in; custom dashboards can show cost next to quality scores | Monitors on observation metrics such as cost |
| **Helicone** | Exact through its AI Gateway; otherwise a best-effort estimate from an open-source price list | User (`Helicone-User-Id`), custom properties, sessions | Through properties you set | Cost alerts over a time window |
| **LiteLLM proxy** | Computes `response_cost` per call | Key, user, team, tag; budgets per key, team and model | Through tags you set | Budgets cap spend |
| **Datadog LLM Observability** | Estimated from public pricing and token counts, or your own `total_cost` | Application, provider, custom cost tags; wasted spend view | Not built in | Metric monitors and anomaly monitors on LLM cost |
| **Braintrust** | Estimated LLM cost per span, rolled up from child spans | Trace, experiment | Not built in | Not covered here |


Two things to watch when you compare:

- **Estimated versus reported cost.** Token-based estimates are convenient and miss tool costs, discounts and anything priced per call. Reported cost is exact but only as complete as your instrumentation.
- **Per-request versus per-outcome.** If your question is "which team spent the most on GPT this month", a gateway answers it. If it's "why does each qualified lead cost 60% more than last week", you need sessions, outcomes and the period before.

Many teams run a gateway for budgets and caps, and a trace-based tool for outcomes and drivers. They don't conflict: report the gateway's cost on your spans and both see the same number.

## A weekly cost-per-outcome review in five steps

1. **Check coverage first.** What share of model and tool spans carried a cost this week? If it dropped, fix that before reading anything else.
2. **Read the ratio and its two halves.** Cost per outcome, spend on the path, outcomes. Which half moved?
3. **Find the step.** Rank path steps by how much their spend changed. For the top one, compare runs, cost per run and runs per session with last week.
4. **Name the cause.** Re-runs within a minute, loops, failing jobs, work after the outcome, or a deploy. Each has a different fix.
5. **Write the check before the fix.** "This step's cost per run back under $0.20, with outcomes unchanged." Re-read it next week. If the agent got cheaper but outcomes fell, it didn't work.

If you'd rather not build this yourself, connect your traces (or [import them from Langfuse or Braintrust](/blog/migrate-from-langfuse-or-braintrust-to-agnost/)) and open the Architecture page.

## Frequently asked questions

### How do I measure what my AI agent costs per successful outcome, and find what drives it?

Report the real USD cost on every model and tool span, decide which step counts as an outcome (a ticket closed, a lead added, a message sent), and divide the spend of every run on the path to an outcome by the number of outcomes in the same period. Then compare with the period before and split the change into more runs, costlier runs and fewer outcomes, and look for re-runs, loops, failing scheduled jobs, work after the outcome and deploys. Agnost AI's Architecture page does this from your traces: it picks the outcome steps, shows cost per outcome against the previous period and names the step and deploy that drove a change. Langfuse, Datadog LLM Observability, Braintrust and gateways such as LiteLLM and Helicone track cost per request, user or tag, and leave the outcome join to you.

### What is the difference between cost per run and cost per outcome for an AI agent?

Cost per run divides spend by how many times the agent ran. Cost per outcome divides spend by how many times the agent actually did its job. Cost per run can fall while cost per outcome rises, for example when a cheaper prompt needs more runs per success, or when re-runs and retries add runs that never reach an outcome.

### Why did my AI agent's cost per outcome go up?

Usually one of five things: more runs per outcome (re-runs, loops, retries), costlier runs (more tool or model calls per run, often after a deploy), fewer outcomes (a failing step, slow first responses that lose sessions), work that continues after the outcome, or more sessions entering the top of the pipeline that convert later or never. Compare each step's runs, cost per run and outcomes with the previous period to see which one it is.

### Which OpenTelemetry attribute should I use to report LLM cost on a span?

OpenTelemetry's GenAI conventions define token usage attributes such as gen_ai.usage.input_tokens and gen_ai.usage.output_tokens but no official cost attribute yet; cost conventions are open proposals. Tools read their own keys: Langfuse reads gen_ai.usage.cost, LiteLLM emits gen_ai.cost.total_cost, OpenInference defines llm.cost.total, and Agnost AI reads gen_ai.usage.cost, cost_usd and several others. Put the cost on the span that incurred it, not on the parent agent span.

### Does Agnost AI estimate LLM cost from tokens?

No. Agnost AI records the USD cost your traces report on each model and tool call and adds it up per conversation, agent, tool, pattern and outcome. If your spans report no cost, spend shows as not reported rather than zero. Datadog, Braintrust, Helicone and Langfuse can estimate cost from token counts and price tables.
