How do I find the most expensive sessions in Codex (beta)?
Rius records each Codex (beta) session as one trace with its token counts and a computed cost, so you find the most expensive sessions in the console’s Traces page. You narrow the list to the codex agent and a time range, then open the costly session to see which model call drove the cost. You can also ask Codex (beta) directly through the Rius MCP server.
How it works
The Rius plugin traces Codex (beta) sessions as one trace per session. Each model call in the trace carries its model, input, cached, output and reasoning tokens. Rius computes cost from those token counts, so you never send a cost value.
The pieces that make a session findable:
- One trace per session. Resuming with
codex resumeorcodex exec resumecontinues the same trace, so a long, resumed session shows up as one expensive row. - An agent named
codex. Sessions appear under that agent on the Agents page, and you can filter the trace list to it. - A user on every span. With plugin 0.6.2 or later, each span carries
user.id, set to the email you signed in with, so sessions are grouped by developer. - Cost on every model call. The trace and each LLM span show tokens and cost. Cost is worked out at API rates, so on a ChatGPT plan it measures usage and is not what you pay. A call that reported no token usage shows a blank cost rather than $0.
A Codex (beta) trace stays in progress until the next Codex session you start on the same key closes it, once the old process has exited and been idle for about an hour. Agent-level cost figures count a session only after its trace is closed.
Set it up
- Make sure sessions are traced. Install the plugin, trust its five hooks in
/hooks, sign in with$rius:rius-login, and enable the repo. The full walkthrough for Codex (beta) is in Codex (beta).
codex plugin marketplace add glassflow/rius-coding-agents
codex plugin add rius@rius-coding-agentsThen run $rius:rius-enable-here in the repo. Structure-only mode already sends models, tokens and cost, so you don’t need to send prompt content to rank sessions by cost.
-
Open the trace list. In the console, go to Traces. Pick a time range: 15m, 1h, 1d, 7d (the default), 30d or a custom range. The strip above the list sums count, tokens and cost for the traces that match your filters.
-
Narrow to Codex (beta) sessions. Click an agent cell showing
codexto filter the list to it. Click a user cell, or the Sent by cell, to see one developer’s sessions. Each row shows token total, computed cost and latency, so you can compare sessions side by side. For more control, use Add filter and pick a trace column as the field. Filters combine with AND, and Saved keeps a search you come back to. See Exploring traces for the filter builder. -
Find the costly calls. Switch to the Spans tab, set the All kinds menu to LLM, and click the Cost header to sort. This lists the most expensive individual model calls across all your sessions. Click a trace ID to open that session with the span highlighted.
-
Open the session. The waterfall shows each turn, model call, tool call and subagent with tokens on the LLM spans, and the header shows total tokens and cost. The Map tab has a cost lens that shows where the money went at a glance. For a session with several model calls, the context growth strip plots input tokens per call, which is where a runaway history shows up first.
-
Or ask from Codex (beta). The plugin registers the Rius MCP server as
rius. Sign in to it once:
codex mcp login riusThen ask in plain language, for example “Which of my Codex sessions this week used the most tokens?”
What you get
- A ranked view of Codex (beta) sessions: the trace list for whole sessions, and the Spans tab sorted by Cost for single model calls.
- A path from a costly session to the exact call behind it, through the waterfall, the Map cost lens and the context growth strip.
- Per-developer totals on the Users page, where you can sort by Cost to see who drives spend. The same approach for a team is described in Track Claude Code usage and cost across a team.
- Answers from the terminal, through the MCP server, without opening the console.
- Cost figures that are estimates at API rates. OpenAI doesn’t report cache-write tokens, so none appear for Codex (beta) sessions.
For the wider picture across every coding agent, see Coding agents.
When something else fits
- If you need a billed amount for your ChatGPT plan, use your OpenAI account, because Rius shows list-price estimates at API rates.
- If you need to find which sessions drove spend across several coding agents, use the Users page and the trace list for each agent. Cursor (beta) sessions carry no token counts or cost, so they can’t be ranked by cost.