Skip to content

Usage/cost attribution is provider-keyed: mixed API+subscription and multi-account setups show wrong billing mode/quota #102807

Description

@steipete

Context

#102784 surfaces provider plan usage (5h/weekly/model windows, credits, plan label) in the chat context popover and gates per-token cost display on whether the session's provider has subscription windows. Two structural limitations remain because usage/billing attribution is provider-keyed, not credential-keyed:

  1. Cost gating is provider-level. Session rows do not record which auth profile served a run. A provider configured with both an API key and a subscription profile (e.g. anthropic api_key + synced claude-cli OAuth, or openai api_key + Codex OAuth) always resolves to subscription display, hiding Est. cost / cost-by-type for sessions that actually ran on the API key.
  2. Usage snapshots are one-per-provider. loadProviderUsageSummary fetches one snapshot per usage provider id. When a native anthropic OAuth account and a different Claude Code (claude-cli) account coexist, the native account's token wins and its quota/plan is attached to both auth rows (and to CLI sessions). Same conflation exists on the /usage page, openclaw status, and openclaw models today.

Proposed direction

  • Record the serving auth profile (or at least credential type: subscription vs API key) on run/session projections so cost display can be gated per run.
  • Key usage snapshots by auth profile (or provider+account) instead of provider id, and attach them to the matching auth rows; aggregate views can still group by provider.

Both need a data-contract decision (session row schema + usage summary shape), which is why they were split out of #102784 (flagged by autoreview there).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.app: web-uiApp: web-uiclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.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:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.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.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions