diff --git a/src/models.ts b/src/models.ts index 221bee64..3d2c5d40 100644 --- a/src/models.ts +++ b/src/models.ts @@ -60,7 +60,8 @@ export type LongContextTier = { /// top bills it twice. /// DSH TokenUsage includes reasoning in output too; see the pinned contract: /// https://github.com/deepseek-ai/deepseek-harness/blob/c291e7961a515f6d7af9304e7fd1d257929aef26/docs/subsystems/llm-streaming.md#tokenusage -const REASONING_INCLUDED_IN_OUTPUT = new Set(['claude', 'codex', 'copilot', 'dsh']) +/// Hermes stores completion/output tokens as the API reports them, reasoning inside. +const REASONING_INCLUDED_IN_OUTPUT = new Set(['claude', 'codex', 'copilot', 'dsh', 'hermes']) /// Output tokens to bill and display for one call. Single source of truth so /// the pricing sites and the display sums can never disagree about whether a diff --git a/src/providers/hermes.ts b/src/providers/hermes.ts index 490562ac..4fd481fa 100644 --- a/src/providers/hermes.ts +++ b/src/providers/hermes.ts @@ -450,7 +450,7 @@ function resolveHermesCost( const calculatedCost = calculateCost( model, tokens.inputTokens, - tokens.outputTokens + tokens.reasoningTokens, + tokens.outputTokens, tokens.cacheWriteTokens, tokens.cacheReadTokens, 0, diff --git a/tests/providers/hermes.test.ts b/tests/providers/hermes.test.ts index b147f2bc..3e2a6879 100644 --- a/tests/providers/hermes.test.ts +++ b/tests/providers/hermes.test.ts @@ -4,7 +4,7 @@ import { tmpdir, homedir } from 'os' import { createRequire } from 'node:module' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { calculateCost } from '../../src/models.js' +import { billableOutputTokens, calculateCost } from '../../src/models.js' import { createHermesProvider } from '../../src/providers/hermes.js' import { isSqliteAvailable } from '../../src/sqlite.js' import { aggregateProjectsIntoDays } from '../../src/day-aggregator.js' @@ -541,8 +541,10 @@ skipUnlessSqlite('hermes provider', () => { const calls = await collectCalls(tmpDir, `${dbPath}#hermes-session=no-cost-session`) expect(calls).toHaveLength(1) - expect(calls[0]!.costUSD).toBe(calculateCost('claude-sonnet-4-20250514', 1000, 250, 0, 0, 0)) + // Output already includes the reasoning tokens. + expect(calls[0]!.costUSD).toBe(calculateCost('claude-sonnet-4-20250514', 1000, 200, 0, 0, 0)) expect(calls[0]!.reasoningTokens).toBe(50) + expect(billableOutputTokens('hermes', calls[0]!.outputTokens, calls[0]!.reasoningTokens)).toBe(200) }) it('carries the billing route the session recorded, and stays silent for every other door', async () => {