fix: exclude zero-spend (skipped) runs from token-optimizer AIC ranking#122
Open
mrfelton wants to merge 1 commit into
Open
fix: exclude zero-spend (skipped) runs from token-optimizer AIC ranking#122mrfelton wants to merge 1 commit into
mrfelton wants to merge 1 commit into
Conversation
The "Aggregate top workflows by AIC usage" step keeps every completed run, including runs whose agent skipped via activation/preconditions and consumed 0 AIC. Those zero-spend runs pad run_count, dilute avg_ai_credits, and can surface never-spent workflows into the top-10 that drives target selection. High-frequency event-driven workflows (e.g. label-triggered) are mostly these 0-AIC completed runs. Add `select((.aic // 0) > 0)` after the status filter so a "top workflows by AIC spend" ranking only counts runs that actually spent. NOTE: only correct once the compiler reliably computes AIC. On gh-aw < v0.79.4 (incl. v0.72.1 used here) the Copilot 0-AIC bug (github/gh-aw#38314, fixed in v0.79.4) makes real-spend Copilot runs report 0 AIC, so this filter would drop genuine spend. Pair with / gate on a compiler bump to >= v0.79.4. Details in githubnext#120. Source `.md` only — regenerate `.lock.yml` in-repo (fork-built locks don't match this repo's cron jitter / action-pin resolution). Fixes githubnext#120 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
The
Aggregate top workflows by AIC usagestep inworkflows/agentic-token-optimizer.mdkeeps everycompletedrun, including runs whose agent skipped (activation/preconditions) and therefore consumed 0 AIC. Those zero-spend runs:run_countfor skip-heavy workflows,avg_ai_credits(the 0s drag the average down), andHigh-frequency, event-driven workflows (e.g. label/PR-triggered) are exactly this case — many
completedruns, agent skipped on most.Full write-up in #120. Distinct from (but compounding) the self-targeting guard in #119 / #121.
Fix
[.runs[] | select(.status == "completed") + | select((.aic // 0) > 0) | { workflow_name, ai_credits: (.aic // 0), ... } ]A "top workflows by AIC spend" ranking should only count runs that actually spent AIC. Applied to both
workflows/(template) and.github/workflows/(active) copies.This is only safe once the compiler reliably computes AIC. On gh-aw < v0.79.4 — including v0.72.1, which this repo currently pins — the Copilot-engine 0-AIC bug is present (provider
github_modelsnot normalized; fixed in v0.79.4 via github/gh-aw#38314, with #38364/#38327/#38353/#38412). There, genuinely-expensive Copilot runs can reportaic == 0, so this filter would drop real spend.Recommendation: pair this with / gate it on bumping these workflows' compiler to ≥ v0.79.4. Once there,
aic == 0reliably means "agent skipped / no consumption" and the filter is correct. We run it in production on v0.79.4.Notes
.mdonly — regenerate.lock.ymlin-repo (fork-built locks carry repo-scoped cron jitter / differing action-pin resolution).gh aw compile --validate --no-emit(v0.72.1): 0 errors, 0 warnings.Fixes #120
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com