fix: use last_usage_ prefix for usage metrics in get_template_vars#34
Open
nuthalapativarun wants to merge 1 commit into
Open
fix: use last_usage_ prefix for usage metrics in get_template_vars#34nuthalapativarun wants to merge 1 commit into
nuthalapativarun wants to merge 1 commit into
Conversation
Both _last_request_metrics and _last_usage_metrics loops used the same "last_request_" prefix, causing usage metrics to silently overwrite request metrics in the returned vars dict. Use "last_usage_" for the usage loop and "cumulative_usage_" for the cumulative usage loop.
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.
Problem
In
get_template_vars, both the_last_request_metricsand_last_usage_metricsloops write keys with the prefix"last_request_". This causes the usage keys (e.g.last_request_input_tokens) to silently overwrite the request keys (e.g.last_request_message_count) when they share the same suffix. Similarly,_cumulative_usage_metricsuses"cumulative_"while_cumulative_request_metricsuses"cumulative_request_"— an inconsistent naming scheme.Fix
Change the
_last_usage_metricsloop prefix to"last_usage_"and the_cumulative_usage_metricsloop prefix to"cumulative_usage_".Changes
src/webwright/models/base.py— fixed the two misnamed prefixes inget_template_varstests/unit/test_get_template_vars.py— added tests asserting bothlast_request_message_countandlast_usage_input_tokensappear as distinct keys, and that cumulative usage usescumulative_usage_prefixNot affected
_usage_snapshot()— separate method, not touchedbase.py— not touched