diff --git a/src/main/claude-usage/claude-model-pricing.test.ts b/src/main/claude-usage/claude-model-pricing.test.ts index 9eb3c2987c7..c8f7065392d 100644 --- a/src/main/claude-usage/claude-model-pricing.test.ts +++ b/src/main/claude-usage/claude-model-pricing.test.ts @@ -22,19 +22,23 @@ describe('estimateCostUsd cache-write TTL rates', () => { expect(estimateCostUsd('claude-opus-5', 0, 0, 0, 1_000, 5_000)).toBeCloseTo(0.01) }) - it('applies the long-context tier to 1-hour writes', () => { - expect(estimateCostUsd('claude-sonnet-4-6', 0, 0, 0, 400_000, 400_000)).toBeCloseTo(3.6) + it('keeps Sonnet 4.6 one-hour writes flat across its full 1M window', () => { + expect(estimateCostUsd('claude-sonnet-4-6', 0, 0, 0, 400_000, 400_000)).toBeCloseTo(2.4) }) - it('shares one long-context allowance across both TTL buckets', () => { + it('applies the legacy long-context tier to Sonnet 4.5 one-hour writes', () => { + expect(estimateCostUsd('claude-sonnet-4-5', 0, 0, 0, 400_000, 400_000)).toBeCloseTo(3.6) + }) + + it('shares one legacy long-context allowance across both TTL buckets', () => { // 400k writes split evenly: 200k @ (3.75/7.5) and 200k @ (6/12), each tier // getting half of the 200k allowance. - expect(estimateCostUsd('claude-sonnet-4-6', 0, 0, 0, 400_000, 200_000)).toBeCloseTo(2.925) + expect(estimateCostUsd('claude-sonnet-4-5', 0, 0, 0, 400_000, 200_000)).toBeCloseTo(2.925) }) - it('never lowers a long-context estimate as writes shift from 5-minute to 1-hour', () => { - const costs = [0, 50_000, 100_000, 200_000, 300_000, 400_000].map((write1h) => - estimateCostUsd('claude-sonnet-4-6', 0, 0, 0, 400_000, write1h)! + it('never lowers a legacy long-context estimate as writes shift to 1-hour', () => { + const costs = [0, 50_000, 100_000, 200_000, 300_000, 400_000].map( + (write1h) => estimateCostUsd('claude-sonnet-4-5', 0, 0, 0, 400_000, write1h)! ) for (let index = 1; index < costs.length; index++) { expect(costs[index]).toBeGreaterThan(costs[index - 1]) diff --git a/src/main/claude-usage/claude-model-pricing.ts b/src/main/claude-usage/claude-model-pricing.ts index eace643eb3b..904b24b2054 100644 --- a/src/main/claude-usage/claude-model-pricing.ts +++ b/src/main/claude-usage/claude-model-pricing.ts @@ -37,13 +37,13 @@ const MODEL_PRICING: Record = { 'claude-opus-4-5': { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25, cacheWrite1h: 10 }, 'claude-opus-4-1': { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75, cacheWrite1h: 30 }, 'claude-opus-4': { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75, cacheWrite1h: 30 }, + // Claude 4.6 and later keep standard rates across the full 1M context window. 'claude-sonnet-4-6': { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75, - cacheWrite1h: 6, - ...SONNET_LONG_CONTEXT_PRICING + cacheWrite1h: 6 }, 'claude-sonnet-4-5': { input: 3, diff --git a/src/main/claude-usage/store.test.ts b/src/main/claude-usage/store.test.ts index 650976a2455..f71d0269050 100644 --- a/src/main/claude-usage/store.test.ts +++ b/src/main/claude-usage/store.test.ts @@ -546,7 +546,7 @@ describe('ClaudeUsageStore', () => { expect(summary.estimatedCostUsd).toBeCloseTo(220.5) }) - it('prices Sonnet long-context usage with threshold rates', async () => { + it('prices Sonnet 4.6 long-context usage at its flat 1M-window rates', async () => { const store = createStoreWithState({ dailyAggregates: [ { @@ -569,7 +569,7 @@ describe('ClaudeUsageStore', () => { const summary = await store.getSummary('orca', '30d') - expect(summary.estimatedCostUsd).toBeCloseTo(8.07) + expect(summary.estimatedCostUsd).toBeCloseTo(6.615) }) it('returns automation usage for a single matching worktree session', async () => {