Comprehensive token usage tracking for V2 #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
V2 callers cannot fully track token consumption across all API surfaces:
string— usage from all iterations lostSolution
Details map[string]inttoUsagefor provider-specific token breakdowns*UsagefromChat.Send*,Generate[T], andAgent.Run*UsageTrackermiddleware to accumulate detailsModelPricing/PricingRegistryutility for cost computationStarting work on this. Plan of approach:
Details map[string]inttoprovider.Usageand publicUsage, extract provider-specific details from OpenAI/Anthropic/GoogleStreamOptions.IncludeUsage) and Google (captureUsageMetadatafrom last chunk)Chat.Send*,Generate[T],Agent.Run*now return*UsageUsageTrackermiddleware to accumulate detail valuesModelPricing/PricingRegistryinv2/pricing.goWork finished. PR: #3
Also created steve/steveternet#47 for the V1 audit.