Skip to content

Commit 98a3285

Browse files
authored
Make published workflows agent-agnostic
2 parents ec8e11a + bda6aee commit 98a3285

14 files changed

Lines changed: 304 additions & 315 deletions

workflows/copilot-token-audit.lock.yml renamed to .github/workflows/agentic-token-audit.lock.yml

Lines changed: 61 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Daily audit of Copilot token usage across all agentic workflows with historical trend tracking
2+
description: Daily audit of token usage across all agentic workflows with historical trend tracking
33
on:
44
schedule:
55
- cron: "daily around 12:00 on weekdays"
@@ -9,12 +9,11 @@ permissions:
99
actions: read
1010
issues: read
1111
pull-requests: read
12-
tracker-id: copilot-token-audit
13-
engine: copilot
12+
tracker-id: agentic-token-audit
1413
safe-outputs:
1514
create-issue:
1615
expires: 3d
17-
title-prefix: "[copilot-token-audit] "
16+
title-prefix: "[agentic-token-audit] "
1817
max: 1
1918
close-older-issues: true
2019
upload-asset:
@@ -26,7 +25,7 @@ tools:
2625
- "*"
2726
repo-memory:
2827
branch-name: "memory/token-audit"
29-
description: "Historical daily Copilot token usage snapshots (shared with copilot-token-optimizer)"
28+
description: "Historical daily workflow token usage snapshots (shared with agentic-token-optimizer)"
3029
file-glob: ["*.json", "*.jsonl", "*.csv", "*.md"]
3130
max-file-size: 102400
3231
max-patch-size: 51200
@@ -41,53 +40,52 @@ steps:
4140
- name: Install Python chart dependencies
4241
run: |
4342
python3 -m pip install --quiet --target /tmp/gh-aw/token-audit/site-packages pandas matplotlib seaborn
44-
- name: Download Copilot workflow logs
43+
- name: Download agentic workflow logs
4544
env:
4645
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4746
run: |
4847
set -euo pipefail
4948
mkdir -p /tmp/gh-aw/token-audit
5049
51-
# Download last 24 hours of Copilot logs as JSON
50+
# Download last 24 hours of agentic workflow logs as JSON
5251
# Allow partial results — gh aw logs streams incrementally, so even if
5352
# it hits an API rate limit partway through, the JSON written so far is
5453
# still valid and should be processed by the agent.
5554
LOGS_EXIT=0
5655
gh aw logs \
57-
--engine copilot \
5856
--start-date -1d \
5957
--json \
6058
-c 100 \
61-
> /tmp/gh-aw/token-audit/copilot-logs.json || LOGS_EXIT=$?
59+
> /tmp/gh-aw/token-audit/workflow-logs.json || LOGS_EXIT=$?
6260
63-
if [ -s /tmp/gh-aw/token-audit/copilot-logs.json ]; then
64-
TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/copilot-logs.json)
65-
echo "✅ Downloaded $TOTAL Copilot workflow runs (last 24 hours)"
61+
if [ -s /tmp/gh-aw/token-audit/workflow-logs.json ]; then
62+
TOTAL=$(jq '.runs | length' /tmp/gh-aw/token-audit/workflow-logs.json)
63+
echo "✅ Downloaded $TOTAL agentic workflow runs (last 24 hours)"
6664
if [ "$LOGS_EXIT" -ne 0 ]; then
6765
echo "⚠️ gh aw logs exited with code $LOGS_EXIT (partial results — likely API rate limit)"
6866
fi
6967
else
7068
echo "❌ No log data downloaded (exit code $LOGS_EXIT)"
71-
echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/copilot-logs.json
69+
echo '{"runs":[],"summary":{}}' > /tmp/gh-aw/token-audit/workflow-logs.json
7270
fi
7371
timeout-minutes: 25
7472
---
7573

76-
# Daily Copilot Token Usage Audit
74+
# Daily Agentic Workflow Token Usage Audit
7775

78-
You are the Copilot Token Auditor — a workflow that tracks daily token consumption across all Copilot-powered agentic workflows in this repository and maintains a historical record for trend analysis.
76+
You are the Agentic Workflow Token Auditor — a workflow that tracks daily token consumption across all agentic workflows in this repository and maintains a historical record for trend analysis.
7977

8078
## Mission
8179

82-
1. Parse the pre-downloaded Copilot workflow logs and compute per-workflow token usage metrics.
80+
1. Parse the pre-downloaded agentic workflow logs and compute per-workflow token usage metrics.
8381
2. Persist today's snapshot to repo-memory so the optimizer (and future runs of this audit) can read historical data.
8482
3. Publish a concise audit issue summarizing today's usage, trends, and cost highlights.
8583

8684
## Data Sources
8785

8886
### Pre-downloaded logs
8987

90-
The workflow logs are at `/tmp/gh-aw/token-audit/copilot-logs.json`. The file is the raw JSON output of `gh aw logs --json` with this top-level shape:
88+
The workflow logs are at `/tmp/gh-aw/token-audit/workflow-logs.json`. The file is the raw JSON output of `gh aw logs --json` with this top-level shape:
9189

9290
```json
9391
{
@@ -128,7 +126,7 @@ Previous snapshots live at `/tmp/gh-aw/repo-memory/default/`. Each daily snapsho
128126

129127
Write a Python script to `/tmp/gh-aw/token-audit/process_audit.py` and run it. The script must:
130128

131-
1. Load `/tmp/gh-aw/token-audit/copilot-logs.json` and extract `.runs`.
129+
1. Load `/tmp/gh-aw/token-audit/workflow-logs.json` and extract `.runs`.
132130
2. Filter to `status == "completed"` runs only.
133131
3. Group by `workflow_name` and compute per-workflow aggregates:
134132
- `run_count`, `total_tokens`, `avg_tokens`, `total_cost`, `avg_cost`, `total_turns`, `avg_turns`, `total_action_minutes`, `error_count`, `warning_count`

0 commit comments

Comments
 (0)