Skip to content

fix: use floating point for PRU computation in extractPremiumRequestCount#22820

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-premium-request-computation
Mar 25, 2026
Merged

fix: use floating point for PRU computation in extractPremiumRequestCount#22820
pelikhan merged 2 commits intomainfrom
copilot/fix-premium-request-computation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

Models like gemini-3-flash-preview consume fractional PRU (e.g. 0.33 per request), but the log parser was always reporting 1 because the regex only matched integers and parseInt was used.

Changes

  • parse_copilot_log.cjs: Updated all three regex patterns from \d+\d+(?:\.\d+)? and replaced parseInt with parseFloat
  • parse_copilot_log.test.cjs: Added test cases covering decimal PRU values (0.33, 0.5) across all supported log format variants
// Before
const patterns = [/premium\s+requests?\s+consumed:?\s*(\d+)/i, ...];
const count = parseInt(match[1], 10);  // "0.33" → NaN → falls through to default of 1

// After
const patterns = [/premium\s+requests?\s+consumed:?\s*(\d+(?:\.\d+)?)/i, ...];
const count = parseFloat(match[1]);  // "0.33" → 0.33

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…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
Copilot AI requested a review from pelikhan March 25, 2026 02:46
@pelikhan pelikhan marked this pull request as ready for review March 25, 2026 02:54
Copilot AI review requested due to automatic review settings March 25, 2026 02:54
@pelikhan pelikhan merged commit 4f15b24 into main Mar 25, 2026
99 checks passed
@pelikhan pelikhan deleted the copilot/fix-premium-request-computation branch March 25, 2026 02:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 parseInt to parseFloat for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of models that consumes 0.33% of premium requests is counted as 1 premium request

3 participants