This file (effective_tokens.go) implements the Effective Tokens (ET) specification defined in docs/src/content/docs/specs/effective-tokens-specification.md. Effective Tokens normalize raw token counts across token classes and model pricing using the formula: base_weighted_tokens = (w_in × I) + (w
(normalizedProvider string)
| 24 | // - Populating effective token counts on TokenUsageSummary after parsing |
| 25 | |
| 26 | func providerIncludesCacheReadsInInput(normalizedProvider string) bool { |
| 27 | // Cache read accounting is provider-specific: |
| 28 | // - bundled semantics: cache_read_tokens are already included in input_tokens, |
| 29 | // so we subtract once before applying input weight. |
| 30 | // - additive semantics: cache_read_tokens are separate from input_tokens, |
| 31 | // so no subtraction is applied. |
| 32 | // |
| 33 | // Known providers currently using bundled semantics are listed below. |
| 34 | // Unknown non-empty providers default to additive semantics to avoid |
| 35 | // under-counting input tokens. Empty provider values are treated as bundled |
| 36 | // semantics for backward compatibility with older usage records that omitted |
| 37 | // the provider field. |
| 38 | // We include both "azure-openai" and "azure_openai" to handle observed |
| 39 | // provider naming variants in historical logs. |
| 40 | switch normalizedProvider { |
| 41 | case "", "anthropic", "openai", "azure-openai", "azure_openai": |
| 42 | return true |
| 43 | default: |
| 44 | return false |
| 45 | } |
| 46 | } |
no outgoing calls
no test coverage detected