Fix firewall token usage reporting to preserve raw counts and remove cache-rate transforms#31581
Merged
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix double-counting of cached input tokens in audit
Fix firewall token usage reporting to preserve raw counts and remove cache-rate transforms
May 11, 2026
Collaborator
|
@copilot merge main and recompile. |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates gh aw audit (and the setup action’s step summary) to stop deriving cache-efficiency / transformed totals from firewall token logs, and instead report raw token bucket counts while keeping Effective Tokens (ET) as the only computed metric.
Changes:
- Removes cache-efficiency calculation from Go and JS token-usage parsing paths.
- Updates audit rendering to print explicit raw token buckets (input/output/cache read/cache write) and removes “Total” / “Cache hit” lines.
- Updates Go and JS tests to assert the new “raw buckets + ET-only computed” behavior.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/token_usage.go | Removes cache-efficiency computation during token usage parsing while keeping ET computation. |
| pkg/cli/token_usage_test.go | Updates expectations to ensure cache-efficiency is no longer computed. |
| pkg/cli/audit_report_render_findings.go | Changes audit token usage output to render raw token buckets and removes cache hit reporting. |
| pkg/cli/audit_report_test.go | Adds coverage to ensure audit rendering no longer prints transformed totals/cache hit lines. |
| actions/setup/js/parse_mcp_gateway_log.cjs | Removes cacheEfficiency from the parsed summary model and markdown footer. |
| actions/setup/js/parse_mcp_gateway_log.test.cjs | Updates tests to assert cacheEfficiency is not computed or rendered. |
| pkg/workflow/data/action_pins.json | Pins github/gh-aw-actions/setup@v0.71.5. |
| pkg/actionpins/data/action_pins.json | Pins github/gh-aw-actions/setup@v0.71.5 (duplicate pin source). |
| .github/workflows/issue-arborist.lock.yml | Updates locked workflow content (including codex harness model flag invocation). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
pkg/cli/token_usage.go:176
- CacheEfficiency is no longer computed, but TokenUsageSummary still carries a non-omitempty
cache_efficiencyfloat field. That means any JSON marshaling of TokenUsageSummary will now reportcache_efficiency: 0even when there are cache reads, which is misleading (and looks like an actual 0% metric rather than “not reported”). Consider removing the field from the summary entirely (and any downstream diff/rendering that uses it), or changing it to an optional/pointer field withomitemptyso it’s absent when not computed/reported.
tokenUsageLog.Printf("Parsed %d entries: %d input, %d output, %d cache_read, %d cache_write, %d requests",
lineNum, summary.TotalInputTokens, summary.TotalOutputTokens,
summary.TotalCacheReadTokens, summary.TotalCacheWriteTokens, summary.TotalRequests)
// Compute effective tokens using per-model multipliers (with optional custom overrides)
populateEffectiveTokensWithCustomWeights(summary, customWeights)
- Files reviewed: 9/9 changed files
- Comments generated: 1
Comment on lines
+1059
to
+1066
| oldStderr := os.Stderr | ||
| r, w, err := os.Pipe() | ||
| require.NoError(t, err) | ||
| os.Stderr = w | ||
|
|
||
| renderTokenUsage(summary) | ||
| require.NoError(t, w.Close()) | ||
| os.Stderr = oldStderr |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Done in commit |
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.
origin/maininto this branch and resolve conflicts if any