Skip to content

Commit d42ce0f

Browse files
authored
fix: token optimizer's self-exclusion bug
2 parents 635ac65 + a0c57d6 commit d42ce0f

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

.github/workflows/agentic-token-optimizer.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/agentic-token-optimizer.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,28 @@ steps:
9595
echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/all-runs.json
9696
fi
9797
98+
BEFORE_COUNT=$(jq '(.runs // []) | length' /tmp/gh-aw/token-audit/all-runs.json)
99+
jq '
100+
(.runs // [])
101+
| map(select(
102+
(.workflow_path // "") != ".github/workflows/agentic-token-optimizer.lock.yml"
103+
and (.workflow_path // "") != ".github/workflows/agentic-token-audit.lock.yml"
104+
and (.workflow_name // "") != "Agentic Workflow AIC Usage Optimizer"
105+
and (.workflow_name // "") != "Daily Agentic Workflow AIC Usage Audit"
106+
)) as $runs
107+
| {
108+
summary: {
109+
total_runs: ($runs | length),
110+
total_tokens: ($runs | map(.token_usage // 0) | add // 0),
111+
total_aic: ($runs | map(.aic // 0) | add // 0)
112+
},
113+
runs: $runs
114+
}
115+
' /tmp/gh-aw/token-audit/all-runs.json > /tmp/gh-aw/token-audit/all-runs.filtered.json
116+
mv /tmp/gh-aw/token-audit/all-runs.filtered.json /tmp/gh-aw/token-audit/all-runs.json
117+
AFTER_COUNT=$(jq '(.runs // []) | length' /tmp/gh-aw/token-audit/all-runs.json)
118+
echo "🚫 Excluded AIC monitoring family from candidate pool: $((BEFORE_COUNT - AFTER_COUNT)) run(s) removed"
119+
98120
- name: Aggregate top workflows by AIC usage
99121
run: |
100122
set -euo pipefail
@@ -199,7 +221,7 @@ Treat missing numeric fields (`aic`, `token_usage`, `turns`, `action_minutes`) a
199221

200222
- Start from `top-workflows.json`.
201223
- Exclude workflows optimized in the last 14 days (use `optimization-log.json`).
202-
- Exclude workflows with "Token" in the name to avoid self-targeting.
224+
- Exclude the AIC monitoring family — the `agentic-token-optimizer` and `agentic-token-audit` workflows (display names "Agentic Workflow AIC Usage Optimizer" and "Daily Agentic Workflow AIC Usage Audit") — to avoid self-targeting. These workflows are pre-filtered from `all-runs.json` and `top-workflows.json`, but never select them even if a stale snapshot still lists them.
203225
- Choose the highest AI-credit-spend workflow that remains.
204226
- If no snapshot/history exists, derive candidates directly from `all-runs.json`.
205227

0 commit comments

Comments
 (0)