refactor(mux): drop dead openai reasoning fallback (#446)

usage.reasoningTokens is the AI SDK v6 normalized field across all
provider families, so the providerMetadata.openai fallback never fired.
Removed it and the now-unused openai extraction.
This commit is contained in:
Resham Joshi 2026-06-06 03:05:07 +02:00 • committed by GitHub
parent e0051fc403
commit cef1a6b669
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -183,14 +183,15 @@ function createParser(source: SessionSource, seenKeys: Set<string>): SessionPars
const pm = meta.providerMetadata ?? {}
const anthropic = asRecord(pm['anthropic'])
const openai = asRecord(pm['openai'])
// mux reports inputTokens inclusive of cache read+creation and
// outputTokens inclusive of reasoning; decompose to codeburn's
// cache/reasoning-exclusive convention. Cache creation is Anthropic-only.
// The AI SDK v6 normalizes reasoning into usage.reasoningTokens across
// every provider family, so that field is the single source of truth.
const cacheRead = num(usage['cachedInputTokens'])
const cacheCreate = num(anthropic?.['cacheCreationInputTokens'])
const reasoning = num(usage['reasoningTokens']) || num(openai?.['reasoningTokens'])
const reasoning = num(usage['reasoningTokens'])
const inputTokens = Math.max(0, num(usage['inputTokens']) - cacheRead - cacheCreate)
const outputTokens = Math.max(0, num(usage['outputTokens']) - reasoning)