fix: consolidate pricing tables to single source of truth#29
Open
fix: consolidate pricing tables to single source of truth#29
Conversation
Replace the outdated 10-model PRICING_TABLE in agent/types.ts with a re-export of DEFAULT_COST_RATES from metering/types.ts (24+ models). Fixes cost tracking returning undefined for newer models like Claude 4, o3-mini, DeepSeek, and Mistral.
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
The codebase had two separate pricing tables with conflicting data:
PRICING_TABLEinagent/types.ts— 10 models, stale pricing, used bycalculateStepCost()DEFAULT_COST_RATESinmetering/types.ts— 24+ models with current pricing, used byUsageMeterThis caused
calculateStepCost()to returnundefinedfor newer models (Claude 4, o1, o3-mini, DeepSeek, Mistral, Gemini 2.5), making agent cost reports incomplete.Fix
PRICING_TABLEconstant andPricingTableinterface fromagent/types.tsDEFAULT_COST_RATESasPRICING_TABLEfor backward compatibilityPricingTabletype from meteringcalculateStepCost()to useDEFAULT_COST_RATESdirectlyModels now covered by cost tracking
Backward compatibility
PRICING_TABLEis still exported (as an alias forDEFAULT_COST_RATES)calculateStepCost()signature unchangedAgentPricingTabletype still exported from index.tsTest plan
bun run build— all 3 packages compile cleanbun run test— all 364 tests passcalculateStepCost('claude-4-sonnet', ...)now returns a cost (previouslyundefined)