Repository navigation
Keep token usage label maps within their bound when merged - #468
Open
teamleaderleo wants to merge 2 commits into
Open
teamleaderleo wants to merge 2 commits into
teamleaderleo 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 reachedNext included review available in 8 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 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 |
|
All contributors have signed the CLA ✍️ ✅ |
This was referenced Oct 6, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
`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.