feat: support configurable cost display currency - #41208
Open
Meinianda-L wants to merge 2 commits into
Open
Conversation
1 task
Author
|
Friendly ping for review: @Hona @Brendonovich (code owners for the touched |
This was referenced Aug 8, 2026
…ding USD The usage_update ACP event hardcodes currency: "USD" regardless of the provider's actual currency configuration. This causes non-USD providers (e.g. EUR-priced custom providers) to report incorrect currency labels. Add an optional `currency` field to the ProviderCost schema (defaults to "USD" when omitted for backward compatibility). Thread the configured currency through to both usage_update call sites (usage.ts layer and service.ts ACP client) using a cached lookup pattern matching the existing contextLimit implementation. Fixes anomalyco#38667 Signed-off-by: kagura-agent <kagura.agent.ai@gmail.com>
Add a display.currency config option that converts usage costs to the user's preferred currency at presentation boundaries (ACP usage_update, TUI, and app). The provider/model currency remains the source currency: when no display currency is configured, costs are shown unchanged in the source currency, and amounts are never relabeled when conversion is impossible (unknown rate). - Add Currency core module: approximate USD-based display rate table, convert() with user rate overrides, and locale-aware format() - Add display.currency and display.rates to the config schema - Convert in both ACP usage_update paths (Effect layer and ACP client) - Replace hardcoded USD formatters in TUI (sidebar, prompt, subagent footer) and app (context usage, context tab) with the shared utility - Regenerate SDK types and document the new options Relates to anomalyco#32485. Supersedes the approach explored in anomalyco#32487 and builds on provider-currency propagation from anomalyco#39425.
Meinianda-L
force-pushed
the
feat/usage-display-currency
branch
from
August 8, 2026 05:32
cf8cee6 to
0a4b2cb
Compare
Author
|
Update: this PR is now self-contained — rebased onto latest dev with #39425's commit included (authorship preserved), so it no longer waits on that PR. Also applied pre-review polish: invalid user rates now disable conversion instead of silently falling back, renamed |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #32485
Type of change
What does this PR do?
This is needed for users whose model pricing is in a non-USD currency (e.g. CNY/RMB) to see usage costs in their own currency.
The PR is self-contained and depends on no unmerged PR (#39425 was closed as superseded). The first commit is the provider-currency propagation from #39425 (kagura-agent's authorship preserved, fixing #38667); the second adds the display-currency feature (closes #32485).
Adds
display.currencyanddisplay.exchangeRatesconfig options:{ "display": { "currency": "CNY", "exchangeRates": { "CNY": 7.15 } } }Costs stay tracked in the provider's source currency. When
display.currencyis set, amounts are converted at the display boundaries: ACPusage_update(both paths), TUI (sidebar, prompt footer, subagent footer) and the app (context usage, context tab) — all routed through one coreCurrencyutility. When it is unset, or no rate exists for the pair, the original amount and currency are shown — values are never relabeled without conversion. An invalid user rate disables conversion for that currency rather than silently falling back.display.exchangeRates(units per 1 USD) overrides the built-in approximate rate table, which is display-only and not billing-authoritative.This supersedes the approach in #32487 (auto-closed after going stale, not rejected): since the provider currency is propagated from provider config, no separate global source-currency knob is needed — custom prices configured in RMB are covered by the provider-level
currencyfield.Docs: new "Display" section in
packages/web/src/content/docs/config.mdx. Not changed: CLIstats/runfooter, which aggregate costs across models without source-currency information.How did you verify your code works?
New tests cover conversion (identity, cross-rate, overrides, invalid override disables conversion, unknown/empty source currency) and
sendUpdatebehavior (source-currency passthrough with no config, USD→CNY conversion, no-relabel fallback). Existing app/tui session tests still pass, oxlint clean on changed files, SDK regenerated withscript/generate.ts, config decode verified.Screenshots / recordings
N/A — formatting goes through
Intl.NumberFormatwith the resolved currency (e.g. withexchangeRates: { "CNY": 7.2 }, a $1.50 session shows CN¥10.80). Happy to add screenshots if helpful.Checklist