Skip to content

ACP usage_update mislabels non-USD costs as USD #38667

Closed as not planned
Closed as not planned

Description

@DinahK-2SO

Description

OpenCode's custom provider model configuration accepts numeric token cost rates but does not accept
their currency. The internal assistant-message cost is also stored as a bare number. When OpenCode
projects that number into ACP, it unconditionally emits currency: "USD".

As a result, a custom provider priced in EUR can have the correct numeric amount reported with the
wrong currency. In the deterministic reproduction below, a provider cost of 30 EUR is emitted
as 30 USD.

cost: { amount: totalSessionCost(messages), currency: "USD" },

Plugins

No response

OpenCode version

OpenCode 1.18.3

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. kagura-chen commented on Jul 24, 2026

    @kagura-chen
    Contributor

    I'd like to work on this. The root cause is clear: both usage.ts (L212) and service.ts (L653) hardcode currency: "USD" in the ACP usage_update. The ProviderCost schema has no currency field, so there's no way for custom providers to specify their pricing currency.

    Proposed fix:

    1. Add optional currency field to ProviderCost in provider.ts (defaults to "USD" for backward compat)
    2. Add findCostCurrency() utility to usage.ts (mirrors existing findContextLimit())
    3. Thread the currency through sendUpdate in both usage.ts and service.ts
    4. Add test coverage for custom currency propagation
  2. DinahK-2SO commented on Jul 27, 2026

    @DinahK-2SO
    Author

    I'd like to work on this. The root cause is clear: both usage.ts (L212) and service.ts (L653) hardcode currency: "USD" in the ACP usage_update. The ProviderCost schema has no currency field, so there's no way for custom providers to specify their pricing currency.

    Proposed fix:

    1. Add optional currency field to ProviderCost in provider.ts (defaults to "USD" for backward compat)
    2. Add findCostCurrency() utility to usage.ts (mirrors existing findContextLimit())
    3. Thread the currency through sendUpdate in both usage.ts and service.ts
    4. Add test coverage for custom currency propagation

    @kagura-agent Why not

  3. kagura-chen commented on Jul 27, 2026

    @kagura-chen
    Contributor

    Thanks @DinahK-2SO — I'll get a PR up for this. Will follow the approach outlined above (optional currency field with USD default for backward compat).

  4. github-actions commented on Sep 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  5. added a commit that references this issue on Sep 27, 2026
    b41c0c9
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

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions