You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Pi adapter mixes mutually exclusive message cache fields and session totals in live tokenUsage #40747
The Pi provider adapter emits tokenUsage updates using mutually exclusive message-level fields (input vs cacheRead) alongside get_session_stats session-cumulative totals (totals.input / totals.cacheRead), which diverges from the normalized OrchestrationV2ProviderTurnTokenUsage contract where cachedInputTokens is a subset of inputTokens.
Code Analysis (verified on origin/maincd3a57ac72)
packages/provider-pi/src/server/usage.ts:75-80 explicitly documents Pi's raw counters:
// Pi's input/cache counters are already disjoint.uncachedInputTokens: tokenCount(usage.input),cachedInputTokens: tokenCount(usage.cacheRead),cacheCreationTokens: tokenCount(usage.cacheWrite),
Overwrites the per-message/per-turn fields with session-wide totals.input and totals.cacheRead from get_session_stats, mixing message-level live snapshots with session-level cumulative totals.
Expected Behavior
Normalize Pi's OrchestrationV2ProviderTurnTokenUsage consistently with Claude/Codex/OpenCode/Antigravity (total inputTokens including cached/cache-creation tokens when computing subset ratios, and avoiding mixing disjoint message-level live counts with session-wide totals).
Activity