Skip to content

Commit 1115d07

Browse files
authored
Restricting daily optimizer application to downstream repositories only
2 parents fb7af89 + 1472ece commit 1115d07

2 files changed

Lines changed: 37 additions & 23 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: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ steps:
4949
WORKFLOW_ID=$(sed -n 's/^tracker-id:[[:space:]]*//p' "$workflow" | head -n 1 | tr -d '\r' | sed 's/[[:space:]]*$//')
5050
[ -n "$WORKFLOW_ID" ] || continue
5151
52+
# Skip the AIC monitoring family in downstream repositories.
53+
# In the source repo (githubnext/agentic-ops) they remain valid targets;
54+
# in any other repo, optimization suggestions for them belong upstream.
55+
if [[ "$GITHUB_REPOSITORY" != "githubnext/agentic-ops" && \
56+
("$WORKFLOW_ID" == "agentic-token-optimizer" || "$WORKFLOW_ID" == "agentic-token-audit") ]]; then
57+
echo "⏭️ Skipping $WORKFLOW_ID (AIC monitoring family — optimize in githubnext/agentic-ops, not here)"
58+
continue
59+
fi
60+
5261
FOUND_WORKFLOW=1
5362
SAFE_WORKFLOW_ID=$(printf '%s' "$WORKFLOW_ID" | tr -cs 'A-Za-z0-9._-' '_')
5463
PART_FILE="$PARTS_DIR/$SAFE_WORKFLOW_ID.json"
@@ -96,26 +105,31 @@ steps:
96105
fi
97106
98107
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"
108+
if [[ "$GITHUB_REPOSITORY" != "githubnext/agentic-ops" ]]; then
109+
jq '
110+
(.runs // [])
111+
| map(select(
112+
(.workflow_path // "") != ".github/workflows/agentic-token-optimizer.lock.yml"
113+
and (.workflow_path // "") != ".github/workflows/agentic-token-audit.lock.yml"
114+
and (.workflow_name // "") != "Agentic Workflow AIC Usage Optimizer"
115+
and (.workflow_name // "") != "Daily Agentic Workflow AIC Usage Audit"
116+
)) as $runs
117+
| {
118+
summary: {
119+
total_runs: ($runs | length),
120+
total_tokens: ($runs | map(.token_usage // 0) | add // 0),
121+
total_aic: ($runs | map(.aic // 0) | add // 0)
122+
},
123+
runs: $runs
124+
}
125+
' /tmp/gh-aw/token-audit/all-runs.json > /tmp/gh-aw/token-audit/all-runs.filtered.json
126+
mv /tmp/gh-aw/token-audit/all-runs.filtered.json /tmp/gh-aw/token-audit/all-runs.json
127+
AFTER_COUNT=$(jq '(.runs // []) | length' /tmp/gh-aw/token-audit/all-runs.json)
128+
echo "🚫 Excluded AIC monitoring family from candidate pool: $((BEFORE_COUNT - AFTER_COUNT)) run(s) removed"
129+
else
130+
echo "ℹ️ Running in source repo — AIC monitoring family remains in candidate pool"
131+
AFTER_COUNT=$BEFORE_COUNT
132+
fi
119133
120134
- name: Aggregate top workflows by AIC usage
121135
run: |
@@ -221,7 +235,7 @@ Treat missing numeric fields (`aic`, `token_usage`, `turns`, `action_minutes`) a
221235

222236
- Start from `top-workflows.json`.
223237
- Exclude workflows optimized in the last 14 days (use `optimization-log.json`).
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.
238+
- 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") — **unless this workflow is running in `githubnext/agentic-ops`** (the source repository that ships them). In downstream repositories these workflows are not valid optimization targets; any optimization suggestions for them belong in `githubnext/agentic-ops`. In downstream repos they are pre-filtered from `all-runs.json` and `top-workflows.json`, but never select them even if a stale snapshot still lists them.
225239
- Choose the highest AI-credit-spend workflow that remains.
226240
- If no snapshot/history exists, derive candidates directly from `all-runs.json`.
227241

0 commit comments

Comments
 (0)