Skip to Content

How do I find the most expensive sessions in OpenHands?

Rius records each OpenHands conversation as one trace with its cost, so the most expensive sessions show up in the trace list, on the Users page and in the Spans tab. The conversation id becomes the Rius session, and every model call carries its model, tokens and cost. Open any trace to see which step spent the money.

How it works

OpenHands traces every conversation with OpenTelemetry. Rius turns that into the records you search:

  • One conversation is one trace. The trace holds the conversation, each agent.step, and the model and tool calls inside it. The cost on the trace row is the cost of that whole conversation.
  • Each model call carries its own cost. The span for each model call records the model, input and output tokens, cache reads and writes, and the prompt and answer. Rius computes the cost from the model and token counts. It is a list-price estimate in US dollars, not a billed amount.
  • The conversation id is the Rius session. A multi-turn conversation groups together. In a trace header, the Session link opens the Spans tab filtered to that session.
  • The agent name makes the list filterable. It comes from the script name, or from agent.name metadata you set.
  • The user comes from user_id. Pass it when you create the conversation and the conversation appears under that user.

For scale, a Claude Haiku 4.5 run that made four model calls used 31,091 input tokens and 966 output tokens and cost $0.0175 in total.

A model call that reported no token usage shows a blank cost, not $0, so it never looks free.

Set it up

  1. Send OpenHands traces to Rius. The OpenHands guide covers the full setup. In short, set the three OTLP variables for the process that runs the SDK script, plus your model key:
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://ingest.eu.console.rius-glassflow.com/v1/traces export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf export OTEL_EXPORTER_OTLP_TRACES_HEADERS="Authorization=Bearer%20ri_..." export LLM_API_KEY=sk-ant-...
  1. Name the agent and attribute each conversation to a user when you create it. The agent name gives you one filter for all OpenHands runs, and user_id gives you a per-person cost view:
conversation = Conversation( agent=agent, workspace=".", user_id="dev@example.com", observability_metadata={"agent.name": "fib-writer"}, )
  1. Open Traces in the console and click the agent cell on any row to filter the list to that agent. The strip above the list sums count, error rate, latency, tokens and cost for the traces that match your filters. Pick a time range from 15m to 30d, or a custom range. Each row shows its computed cost, so you can read down the cost column. Use Add filter to narrow by user, status or any attribute your agent sends. See Exploring traces for the filter builder and saved searches.

  2. To find the costliest single calls, open the Spans tab, filter the kind to LLM, and click the Cost header to sort. Click a trace ID to open that conversation with the span highlighted.

  3. To compare people, open the Users page. It lists each user with their traces, failed traces and cost for the window. Sort by Cost and open a user to see their conversations.

What you get

  • A ranked view of spend. Sort model calls by cost on the Spans tab, or scan the cost column on the trace list for the conversations that matter.
  • A path from total to step. Open an expensive conversation. The waterfall shows every agent.step, model call and tool call in order, with tokens and cost on each model call. The Map tab has a cost lens for spotting the hot node at a glance.
  • An explanation of growth. On a trace with several model calls, the context growth strip plots input tokens per call, which is where an ever-growing history shows up. On a model call’s input, Since previous llm call shows only what each step added.
  • One session in one place. Paste a session id into the Spans search box to list every span in that session.
  • A way to share what you found. Share on the trace list creates a read-only link to a frozen, filtered list with summary tiles and metadata only. It carries no span content.
  • A standing guard. Create a custom alert, for example average cost per conversation above $0.50 for one agent, so a costly pattern reaches you without a search.

Cost and tokens are recorded for OpenHands SDK scripts that use models such as Claude or GPT-4o. Conversations from the OpenHands web app have no tokens or cost, because the app streams its model calls, and OpenAI Responses API models such as GPT-4.1 and GPT-5 report no token data. Those conversations still appear in the list with every call and its content, but you cannot rank them by cost.

When something else fits

  • If your team also uses Claude Code, the same workspace shows those sessions by developer and cost. See Track Claude Code usage and cost across a team. For the other coding agents Rius traces, see Coding agents.
  • If you want the ranking without opening the console, ask an MCP client connected to the Rius MCP server, for example through the agent_traces_summary tool, what an agent cost per day.

Still stuck? Get help

Last updated on