Skip to content

Cost per session for Claude and Pi, like Codex has #4930

Closed as not planned
Closed as not planned

Description

@oryband

Codex already shows cost per session: codexbar cost --group-by session (#2854) and the Cost > Conversations list with titles (#4434). Claude and Pi do not. The same command prints:

Skipping session grouping for providers without Codex session data: Claude
Skipping session grouping for providers without Codex session data: Pi

Request

  1. Support --group-by session and --group-by project for Claude and Pi.
  2. Show the Conversations list for Claude and Pi in the menu and in Usage & Spend. For Pi, use the session name from the session_info record as the title.
  3. Optional: add up sessions whose names start with the same task id, so one task split across a few sessions shows one total.

The data already exists

Both tools write one log file per session, with token usage on each assistant message:

  • Claude Code: ~/.claude/projects/<project-folder>/<session-id>.jsonl. Each line has sessionId. Each assistant message has message.usage with input_tokens, output_tokens, cache_read_input_tokens and cache_creation_input_tokens.
  • Pi: ~/.pi/agent/sessions/<cwd>/<timestamp>_<session-id>.jsonl. Each assistant message has usage with input, output, cacheRead, cacheWrite, cacheWrite1h and usage.cost.total. A session_info record holds the session name in name.

Why

I want to see what each task costs. A task is usually one session, sometimes a few.

Activity

  1. added
    clawsweeper:intake:featurePreliminary submission classification; full source review pending.
    P2Normal priority bug or improvement with limited blast radius.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    and removed
    clawsweeper:intake:featurePreliminary submission classification; full source review pending.
    on Nov 4, 2026
  2. clawsweeper commented on Nov 4, 2026

    @clawsweeper

    Codex review: this still needs some work.

    Summary
    Keep open: Claude and Pi still lack session/project cost breakdowns on main, and the repository requires conservative handling of feature requests.

    Reproducibility: Current source and explicit CLI tests establish the reported omission; no command against real accounts or live reproduction was run.

    Next step
    Decide whether to prioritize Claude/Pi session and project parity, with task-prefix aggregation considered separately.

    Review details

    Best possible solution:

    Extend the existing breakdown models with Claude/Pi adapters and shared presentation while preserving privacy, accounting, and estimate labels.

    Do we have a high-confidence way to reproduce the issue?

    Current source and explicit CLI tests establish the reported omission; no command against real accounts or live reproduction was run.

    Is this the best way to solve the issue?

    Provider adapters feeding the existing breakdown models are appropriate; displaying recorded Pi costs or merging task-name prefixes would require additional policy beyond presentation parity.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • Session attribution must preserve existing duplicate suppression, provider source ownership, partial-history coverage, and pricing semantics.
    • Task-prefix aggregation has no defined identity or collision rules and needs a separate scope decision.

    Codex review notes: model internal, reasoning medium; reviewed against 897bff31731b.

    Label changes

    Label changes:

    No label changes.

    Label justifications:

    • P2: Useful parity improvement with limited blast radius; aggregate cost reporting remains available.
    • impact:ux-friction: Users cannot inspect Claude/Pi task costs through the conversation views and grouping commands already available for Codex.
    Evidence reviewed

    Acceptance criteria:

    • swift test --filter CLICostTests
    • swift test --filter CostUsageFetcherTests
    • swift test --filter PiSessionCostScannerTests
    • swift test --filter CostHistoryChartMenuViewTests
    • swift test --filter SpendDashboardSessionRowTests

    What I checked:

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge; those execution lanes are retired.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Reviewed November 4, 2026, 3:34 PM ET / 20:34 UTC.

  3. steipete commented on Nov 7, 2026

    @steipete
    Owner

    Thanks for describing the log formats. We checked the current command: session/project grouping and the Conversations view remain Codex-only. Adding Claude and Pi needs persistent session/project attribution, deduplication, incremental updates, and matching UI behavior; it is not just enabling the existing CLI switch. We're closing this parity request rather than keeping it as an open commitment. A focused implementation for one provider with synthetic ownership and append/update coverage would be a basis to reconsider. Existing ungrouped cost totals remain available.

  4. oryband commented on Nov 8, 2026

    @oryband
    ContributorAuthor

    I opened two focused PRs for this, one per provider, as you suggested:

    Each one stores session and project attribution in the cache, keeps the existing dedup, handles appends, and adds --group-by session|project plus the menu views. All tests use synthetic data.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions