fix: use floating point for PRU computation in extractPremiumRequestCount#22820
Merged
fix: use floating point for PRU computation in extractPremiumRequestCount#22820
Conversation
…ount - Update regex patterns to match decimal numbers (e.g., 0.33, 2.5) using \d+(?:\.\d+)? instead of \d+ - Replace parseInt with parseFloat for correct fractional PRU parsing - Add tests for decimal PRU values in multiple log format variants Fixes models like gemini-3-flash-preview that consume 0.33 PRU per request being incorrectly counted as 1 premium request Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/gh-aw/sessions/b69733e2-c34e-426f-9da6-68164229a326
Copilot
AI
changed the title
[WIP] Fix premium request computation for floating point values
fix: use floating point for PRU computation in extractPremiumRequestCount
Mar 25, 2026
pelikhan
approved these changes
Mar 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Copilot log parser to correctly extract fractional premium request units (PRU) from CLI output, instead of defaulting to 1 when decimals are present.
Changes:
- Broadened premium request regexes to match both integers and decimals.
- Switched parsing from
parseInttoparseFloatfor matched PRU values. - Added test coverage for decimal PRU values across all supported log format variants.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| actions/setup/js/parse_copilot_log.cjs | Allows extracting decimal premium request consumption values by matching and parsing floating-point numbers. |
| actions/setup/js/parse_copilot_log.test.cjs | Adds unit tests validating decimal parsing for each supported log message format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Models like
gemini-3-flash-previewconsume fractional PRU (e.g. 0.33 per request), but the log parser was always reporting 1 because the regex only matched integers andparseIntwas used.Changes
parse_copilot_log.cjs: Updated all three regex patterns from\d+→\d+(?:\.\d+)?and replacedparseIntwithparseFloatparse_copilot_log.test.cjs: Added test cases covering decimal PRU values (0.33,0.5) across all supported log format variants📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.