fix(usage): avoid cross-provider pricing fallback

This commit is contained in:
Tam Nhu Tran committed 2026-04-28 15:55:35 -04:00
1 parent fc90b6f473
commit f736190196
2 files changed
+22 -3

No files matched your search

+17
View File
@@ -327,6 +327,11 @@ describe('model-pricing', () => {
name: 'GPT-5.5',
cost: { input: 5, output: 30, cache_read: 0.5 },
},
'openai-exclusive-model': {
id: 'openai-exclusive-model',
name: 'OpenAI Exclusive Model',
cost: { input: 9, output: 18 },
},
},
},
'github-copilot': {
@@ -373,6 +378,18 @@ describe('model-pricing', () => {
expect(hasCustomPricing('gpt-5.5', { provider: 'openai' })).toBe(true);
});
it('does not use another provider pricing when explicit provider lookup misses', () => {
const fallback = getModelPricing('unknown-model-xyz');
expect(getModelPricing('openai-exclusive-model', { provider: 'github-copilot' })).toEqual(
fallback
);
expect(getModelPricing('github-copilot/openai-exclusive-model')).toEqual(fallback);
expect(hasCustomPricing('openai-exclusive-model', { provider: 'github-copilot' })).toBe(
false
);
});
it('calculates cost with provider-aware models.dev pricing', () => {
const usage: TokenUsage = {
inputTokens: 1_000_000,