Skip to content

Fix/58498 status card oauth usage clean#1810

Open
BingqingLyu wants to merge 6 commits into
mainfrom
fork-pr-59208-fix-58498-status-card-oauth-usage-clean
Open

Fix/58498 status card oauth usage clean#1810
BingqingLyu wants to merge 6 commits into
mainfrom
fork-pr-59208-fix-58498-status-card-oauth-usage-clean

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 28, 2026

Copy link
Copy Markdown
Owner
  • fixes [Bug]: Status card shows the active OAuth profile, but weekly usage appears to reflect a different Oauth credential openclaw/openclaw#58498
    Summary

    Fix the status card so the usage/quota line is resolved with the same OAuth profile shown as active for the current session.

    Previously, when multiple OAuth profiles existed under the same provider, the status surface could display the correct active profile from authProfileOverride while weekly
    usage was still loaded from a different profile chosen by provider-level fallback order. This made the auth label and usage summary inconsistent.

    This PR threads the session’s active OAuth profile into provider usage resolution and prefers it when loading usage-backed status output.

    It also adds a guard so a preferred profile is only used when it actually belongs to the requested provider. If the override is stale or mismatched, usage resolution falls back
    to the normal provider-scoped order.

    Root Cause

    The status card already respected sessionEntry.authProfileOverride when rendering the active auth label, but provider usage loading resolved credentials only at the provider
    level.

    That meant:

    • the auth label used the session-selected OAuth profile
    • the usage line could still use the first available OAuth profile for that provider

    If the session override was stale or mismatched, the preferred profile could also be incorrectly tried for the wrong provider.

    Changes

    • Pass the active session OAuth profile into loadProviderUsageSummary
    • Thread preferredProfileIds through provider usage auth resolution
    • Prefer the requested OAuth profile when resolving provider usage auth
    • Validate that the preferred profile belongs to the requested provider before prioritizing it
    • Keep existing provider-level fallback behavior when no valid preferred profile is set
    • Add regression coverage for preferred-profile selection and mismatched-provider fallback

    Files Changed

    • openclaw/src/auto-reply/reply/commands-status.ts
    • openclaw/src/infra/provider-usage.auth.ts
    • openclaw/src/infra/provider-usage.load.ts
    • openclaw/src/infra/provider-usage.auth.normalizes-keys.test.ts

    Behavior After This Change

    • The status card auth label and usage/quota line use the same session-selected OAuth profile
    • A stale or cross-provider preferredProfileId is ignored safely
    • Usage resolution falls back to the existing provider-scoped order when no valid preferred profile is available

    Testing

    Intended targeted tests:

    pnpm vitest run \
    src/infra/provider-usage.auth.normalizes-keys.test.ts \
    src/infra/provider-usage.load.test.ts \
    src/agents/openclaw-tools.session-status.test.ts

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Status card shows the active OAuth profile, but weekly usage appears to reflect a different Oauth credential

1 participant