Skip to Content

How do I find the longest-running sessions in OpenHands?

Rius records each OpenHands conversation as one trace with a latency, so you find the longest-running sessions by filtering the trace list to your agent and reading the latency column. On the Spans tab you can also sort by Duration. The conversation id is the Rius session, so you can open every span of a slow conversation with one click.

How it works

OpenHands needs no plugin. Its SDK traces each conversation with OpenTelemetry, and Rius stores the whole conversation as a single trace. That is what makes a long session easy to spot, because the time it took is on the trace itself.

What Rius records for each conversation:

  • One trace per conversation. The root is the conversation span, with conversation.send_message and conversation.run under it. Each agent.step, model call and tool call sits below conversation.run.
  • Latency on every row. The trace list shows latency, span count, token total and cost for each conversation.
  • The conversation id as the session. A multi-turn conversation groups together under one session.
  • The agent name. It comes from the agent.name metadata, or from the script name when you set none.
  • The user. If you pass user_id, each conversation shows under that user.

These are the handles you filter on. The same approach works for Claude Code, where the trace list also shows one row per session. See Track Claude Code usage and cost across a team, or the Coding agents overview.

Set it up

  1. Send your OpenHands conversations to Rius with the three OTLP environment variables. The OpenHands guide has them in full, including the /v1/traces path and the header encoding.
  2. Name the agent and the user when you create the Conversation, so you can narrow the list to one agent or one developer:
conversation = Conversation( agent=agent, workspace=".", user_id="dev@example.com", observability_metadata={"agent.name": "fib-writer"}, )
  1. Open Traces in the console and set the time range. The presets are 15m, 1h, 1d, 7d (the default), 30d and a custom range.
  2. Narrow the list to your agent. Click an agent cell in any row, or use Add filter. Click a User cell to see one developer’s conversations. Filters combine with AND, and they live in the URL, so you can share the link.
  3. Read the latency column for each conversation. The strip above the list shows latency percentiles for the traces that match your filters, so you can tell which conversations are outliers.
  4. To rank by duration, switch to the Spans tab, type conversation.run in the search box, which matches span names, and click the Duration header to sort. The longest conversation runs rise to the top.
  5. Click a row to open the trace. The header shows the total duration, span and error counts, tokens and cost, and the session. The Session link opens Spans filtered to that session. Pasting a session id into the Spans search box does the same.

Web-app conversations show under the agent openhands-agent-server, so filter to that agent to find long sessions from the OpenHands web app.

What you get

  • A list of your slowest OpenHands conversations, from the latency column or from a Duration sort.
  • A path from a slow conversation to the cause. The waterfall shows every agent.step, model call and tool call on a timeline, and the Map tab has a latency lens that shows where the time went.
  • The same view per developer, when you pass user_id.
  • Tokens and cost on each model call for SDK scripts, so you can tell a long conversation that was also expensive from one that was only slow. Web-app conversations carry no tokens or cost, because their model calls are streamed.
  • Repeats made visible. If a long session was a loop, the pre-defined Tool Loop alert fires when the same tool is called with the same arguments at least three times in a row in one trace.

When something else fits

  • To see a conversation that is still going, note that OpenHands spans reach Rius as they end. The running… status needs partial spans, a Rius SDK option that OpenHands traces do not use, so the trace list shows a conversation’s time once its spans have ended.
  • For cost rather than time, the Usage and cost page breaks spend down by model and agent.
  • OpenHands Cloud cannot be pointed at Rius, because Cloud agents take no custom environment variables.

Still stuck? Get help

Last updated on