Repository navigation
Keep token usage label maps within their bound when merged - #523
azooz2003-bit wants to merge 2 commits into
Conversation
addTokenUsageLabelCounts let a map reach tokenUsageMaxLabelKeys real labels and then added "other" as one more key. Merging such a map into an empty one (as a snapshot does) could land at 17 keys depending on iteration order, which made TestTokenUsageStopReasonAndErrorLabelsStayBounded fail about one run in seventeen. Reserve the last slot for "other".
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Pull Request opener @azooz2003-bit is not an author or co-author of any commit in this PR (commit identities:
I have read the CLA Document v2.2 and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
`addTokenUsageLabelCounts` let a label map fill all `tokenUsageMaxLabelKeys` slots with real labels and then added `other` as a 17th key. When a snapshot merged such a map into an empty one, whether the result stayed at 16 depended on map iteration order, so `TestTokenUsageStopReasonAndErrorLabelsStayBounded` failed roughly one run in seventeen (seen on #397: `stop reasons = 17 keys, want at most 16`).
The fix reserves the last slot for `other`, so a map never exceeds the bound regardless of merge order. Adds a test that merges a full map (16 labels plus `other`) repeatedly and asserts the bound and the total.
Test: `go test -count=20 -run 'TestTokenUsage|TestAddTokenUsageLabel' ./internal/proxy/` passes.
🤖 Generated with Claude Code
Summary by cubic
Fixes
addTokenUsageLabelCountsso merged token usage label maps never exceed thetokenUsageMaxLabelKeysbound. Previously, a full map could addotheras a 17th key, and whether that key survived merging depended on map iteration order, causingTestTokenUsageStopReasonAndErrorLabelsStayBoundedto fail intermittently. The last slot is now reserved forother, and a test repeatedly merges a full map to assert the bound and total.Written for commit cdcadad. Summary will update on new commits.
Migrated from #468 after correcting the PR author identity. The original head commit cdcadad is preserved.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.