fix: add server-side tool usage tracking and normalization#44
Merged
Conversation
3 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.
Summary
Add native tool billing support for provider-side tools and expose the related admin controls.
This change records native tool usage in billing snapshots and service billing items, adds default native tool pricing for OpenAI, Anthropic, and xAI, and adds an admin Tool Pricing section below Model Pricing. Native tool billing is enabled by default and can be disabled from the billing settings.
It also updates related billing UI details: Claude cache write pricing now explains that Fast Mode applies another 6x on top, pricing tooltip labels no longer wrap unexpectedly, and backend task model selectors no longer hide routable chat models just because model pricing has not been configured.
Change type
Affected areas
Verification
cd backend && make swaggercd backend && go test ./internal/application/billing ./internal/application/settings ./internal/infra/llm ./internal/transport/http/billingcd backend && go test ./...cd frontend && pnpm buildgit diff --checkScreenshots, API examples, or logs
Not included.
Configuration, migration, and compatibility notes
Configuration changes: Adds native tool billing configuration in billing settings. Native tool billing defaults to enabled.
API changes: Billing config responses now include
nativeToolBillingEnabledandnativeToolPricing.Database migrations: None expected.
Deployment changes: None expected.
Backward compatibility: Existing model pricing and usage billing behavior remains compatible. Native tool usage is added as service billing detail when available. If native tool billing is disabled, native tool usage can still be recorded in snapshots without charging.
Swagger was regenerated to include the new billing config fields and native tool pricing response shape.
Documentation
Security and privacy
Checklist
.pycfiles,.envfiles, and local storage data are not committed.