Why is my AI agent so expensive to run, and where do I cut?
Rius shows where an agent’s money goes by pricing every model call and rolling it up by model, by agent and by trace, so you can find the costly runs and the calls inside them. Start with cost by model, open the most expensive traces, and read the calls that cost the most. After you change something, compare two agent versions on cost per trace to confirm the change worked. The full pricing method is in Track LLM and agent cost.
How it works
Rius prices each model call from its model name and token counts, then adds the calls up. Four causes explain most expensive agents, and each shows up in a different place:
- Model choice. The cost by model chart and the models table on the Usage and cost page list calls, latency, tokens and cost for each model. A strong model doing simple work shows as a large share of cost from few calls.
- Long context. On a trace with several model calls, a strip above the tree plots input tokens per call in order. A prompt that keeps growing, or a history that is never trimmed, appears as rising bars. On a call with captured messages, the Since previous llm call view on the Input / Output tab marks what each step added to the prompt. When the model’s context window is known, the span also shows how much of it was used.
- Retries and tool loops. Back-to-back calls of the same tool collapse into one row such as
fetch_article · 3 attempts · recovered, so a retry loop is one visible event. A failed trace badged recovered means child spans errored and the agent retried or fell back, and those extra calls still cost money. The pre-defined Tool Loop alert flags this pattern. - Cache use. Cache read and write tokens are priced at the provider’s cache rates. Input tokens are counted as the whole prompt, cached tokens included, so a high input count with little caching is a place to cut. A model whose price entry has no separate cache rates is charged its input rate for cache tokens.
Costs are list-price estimates in US dollars from LiteLLM’s public model-price catalog. They do not include batch or long-context pricing or any discount you negotiated, so use them to compare runs and changes, not to match an invoice. A call whose model is not in the catalog, or that reported no tokens, has an empty cost rather than $0.
Set it up
- Find the expensive model. Open Usage and cost and choose a period. Read cost by model and the models table. The chart notes how many model calls were priced, so you know how complete the picture is.
- Find the expensive runs. Open Traces. The list shows cost per trace, and the strip above it sums cost for the traces that match your filters. Narrow the time range and filters, then open the traces that stand out. To look at single calls instead, open the Spans tab, filter the kind to LLM, and click the Cost header to sort. Add a filter on the model to see one model’s costliest calls.
- Find the expensive calls inside a run. In the open trace, switch to the Map tab and pick the cost lens to see which spans took the money. Click a node to land on its spans in the tree. Then check the context growth strip for rising input tokens and expand any retry rows for repeated attempts.
- Catch it next time. Create a custom alert on cost per trace. For example:
FILTERS Service = checkout-agent
RULES p95(Cost) > $2.00
WINDOW 1 hourThis fires when runs get expensive, such as after a prompt grows or an agent gets stuck retrying.
5. Check your change. Ship the fix as a new agent version. Set the version with RIUS_MAIN_AGENT_VERSION, which becomes rius.main_agent.version, the value the Agents page compares. Open the agent, choose version Compare, and read cost per trace next to failed rate, latency, time to first token (p50) and tokens per trace. Rius warns when either side has fewer than 20 traces, so wait for enough runs before you decide. The Drift charts show cost per trace over time.
What you get
- A ranked view of spend by model, by agent and by trace, with cost on every model call.
- A way to tell whether a costly run comes from the model, a growing prompt, a retry loop or missing cache use, using the map cost lens, the context growth strip and the retry rows.
- A before and after answer for each change, from the version comparison on cost per trace and the other measures beside it.
- An alert that tells you when cost per trace climbs again.
When something else fits
- If you need figures that match your invoice, use your provider’s billing. Rius shows list-price estimates and does not support custom prices or negotiated discounts.
- A total-spend or budget threshold for the whole workspace is not an alert metric, so watch the workspace total on Usage and cost.
- If cost shows a dash or an empty value, the model is not in the price catalog or the call reported no tokens. Fix the token reporting before you trust the totals.
Related
Still stuck? Get help