Skip to content

UI shows costs for all sessions even when drilled into a session #1116

Closed

Description

@esnible

It confused me to see costs when I was viewing a Bob session:

abctl · Can I configure environment variables for Bob Shell to use when it starts? (cf6d4a762a052c650dbe46ee933d676d)                                                 
LAST 1H $7.53+ · TODAY $31.25+ · 7 DAYS ~$618.07+ · THIS MONTH —                                                                                                      
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 #     DIR   PHASE    METHOD              STATUS     DURATION             TOKENS                COST▼  HOST                                                           
 1     out   req      premium-ide                                          8,131                       api.us-east.bob.ibm…                                           
 1     out   resp     premium-ide         200           3.12s                117                       api.us-east.bob.ibm…                                           
 2     out   req      initialize                                                                       api.us-east.bob.ibm…                                           
 2     out   resp     initialize          200            30ms                                          api.us-east.bob.ibm…                                           
 3     out   req      notifications/ini…                                                               api.us-east.bob.ibm…                                           
 3     out   resp     notifications/ini…  202            26ms                                          api.us-east.bob.ibm…                                           
 5     out   req      tools/list                                                                       api.us-east.bob.ibm…                                           
 5     out   resp     tools/list          200            30ms                                          api.us-east.bob.ibm…                                           
 6     out   req      tools/call                                                                       api.us-east.bob.ibm…                                           
 6     out   resp     tools/call          200           173ms                                          api.us-east.bob.ibm…                                           
 7     out   req      premium-ide                                          9,217                       api.us-east.bob.ibm…                                           
 7     out   resp     premium-ide         200           2.24s                 36                       api.us-east.bob.ibm…                                           

If a session has no cost, I expected the cost bar to show $0 or unknown.

Activity

  1. huang195 commented on Oct 7, 2026

    @huang195
    Member

    the top bar was meant to be a cost dashboard that shows the overall cost info. at least that was the original intention. but maybe that's confusing.

  2. self-assigned this
    on Oct 14, 2026
  3. esnible commented on Oct 14, 2026

    @esnible
    MemberAuthor

    Findings from looking at whether the session view can show this session's cost instead of
    the proxy-wide band.

    Short answer: partly. agentop can show this session's lifetime cost and its LAST 1H. It
    cannot show TODAY, 7 DAYS or THIS MONTH for one session.

    Figure for one session Available? Where it comes from
    Lifetime cost Yes, and agentop already has it SessionSummary.CostMicros, plus Saturated, Currencies, AvoidedMicros, TotalTokens (store.go#L899-L954). agentop re-fetches /v1/sessions on every refresh tick, including while drilled in (app.go#L1639), and the session header already reads its title from that list.
    LAST 1H (any window up to 6h) Yes, through an existing endpoint GET /v1/usage?window=1h&session=<id>, served from the in-memory usage buffer (usage.go#L213-L214). Pressing u on the events pane already opens a Usage pane scoped to the session this way.
    TODAY / 7 DAYS / THIS MONTH No, by design The cost ledger stores no session id, for privacy and to keep rows small. /v1/usage answers session= with any of these windows with a 400 (usage.go#L184-L201).
    Per request Already shown The events table's COST column, from each response's cost record.

    The band ignores the session on purpose, which matches @huang195's comment:
    fetchSpendSpan calls it "a per-proxy reading"
    (spend.go#L943-L946).

    Details that matter for any fix:

    • "Unknown" already works. CostMicros is omitted when nothing was priced, so it never
      renders as $0.00, and the sessions table already draws — for it. The premium-ide
      requests in this session have no price (their COST cells are blank), so a per-session figure
      here would read —, which is "unknown" rather than $0.
    • The lifetime figure can't say it is partial. SessionSummary has no counts of
      unpriced or inexact requests, so a session where only some requests were priced would look
      complete; it can't wear the band's + or ~. The per-session LAST 1H reply does carry those
      counts (usage.go#L241-L292),
      so that figure can be marked the same way the band marks its figures.
    • Lifetime covers only what the proxy still holds. On a local install with a session
      archive it continues across restarts. Without one, which is any cluster sidecar, it starts
      over when the proxy restarts.
    • A per-session TODAY is possible but unbuilt. Every response event has a timestamp and a
      cost record, so the server could sum a session's own events by day (on a local install the
      archive keeps 30 days). That would be new server work.

    One possible shape for a fix: on the events and detail panes, show THIS SESSION (lifetime,
    from the session list) and LAST 1H (session-scoped) in place of the proxy-wide band, drop
    the three spans that can't be answered per session, and bring the proxy-wide band back on Esc.
    Another: keep the proxy-wide band, caption it ALL SESSIONS when drilled in, and put the
    session's cost on the header line.

    Assisted-By: Claude (Anthropic AI) [email protected]

  4. huang195 commented on Nov 6, 2026

    @huang195
    Member

    PR #1372 fixed this. When you drill into a session, the spend band now has the caption ALL SESSIONS (cmd/agentop/tui/spend_band.go:247). This is the second fix in the last comment.

    The band does not show $0. The ledger has no session key, so TODAY, 7 DAYS and THIS MONTH are not available for one session. A cost band for one session needs a new issue.

    Assisted-By: Claude (Anthropic AI) [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions