fix: capture per-model token usage in bench SDK driver #33
Reference in New Issue
Block a user
Delete Branch "fix-bench-token-extraction"
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?
Fixes a benchmark-harness bug: the SDK driver recorded zero token components for every run, silently zeroing the cost-equivalent-token headline metric the benchmark exists to measure.
Root cause
sumTokensread the Agent SDK's per-modelmodelUsageentries with snake_case field names (input_tokens,cache_read_input_tokens, …), but the SDK reports those per-model entries in camelCase (inputTokens,cacheReadInputTokens, …). Every component fell through to?? 0. Top-leveltotal_cost_usd/num_turnsare snake_case and kept working, which masked the problem (cost and turns looked fine while tokens were all zero).Fix
Read
modelUsagewith the correct camelCase fields, keeping the snake_case aggregateusageas the fallback (the two SDK shapes genuinely use different casing). ExportsumTokensand addbench/sdk-driver.test.ts(2 tests): the per-model camelCase sum folding in the auxiliary model, and the snake_case aggregate fallback — so a future SDK field-casing drift fails a test instead of silently producing zero-token samples.Verification