You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: use gh aw logs for token analysis workflows (#1884)
Replace manual artifact downloading (gh run download --name firewall-audit-logs)
with gh aw logs --json in all 4 token analysis workflows. This aligns with
the approach used by gh-aw's own token-audit and token-optimizer workflows.
Benefits:
- Eliminates dependency on knowing the correct artifact name
(the root cause of the bug fixed in PR #1883)
- Gets pre-aggregated structured data (token counts, costs, turns)
instead of parsing raw token-usage.jsonl
- Handles artifact naming backward/forward compat automatically
- Pre-downloads data in steps block (faster, more reliable)
Changes:
- copilot-token-usage-analyzer.md: replaced manual run discovery +
artifact download with gh aw logs --engine copilot --json pre-step
- claude-token-usage-analyzer.md: same for --engine claude
- copilot-token-optimizer.md: added gh aw logs --engine copilot
pre-step for 7-day data, removed manual artifact download
- claude-token-optimizer.md: same for --engine claude
- shared/mcp/gh-aw.md: new shared component to install gh-aw CLI
(mirroring upstream gh-aw's shared/mcp/gh-aw.md)
Refs: #1883, github/gh-aw#25683
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@@ -57,7 +87,7 @@ From the report's **Workflow Summary** table, identify the workflow with:
57
87
58
88
Extract these key metrics for the target workflow:
59
89
- Total tokens per run
60
-
- Cache hit rate (read and write separately — Anthropic exposes both)
90
+
- Cache hit rate (read and write separately \u2014 Anthropic exposes both)
61
91
- Cache write rate
62
92
- Input/output ratio
63
93
- Number of LLM turns (request count)
@@ -81,53 +111,32 @@ cat "$WORKFLOW_FILE"
81
111
```
82
112
83
113
Analyze:
84
-
-**Tools loaded**— List all tools in the `tools:` section. Flag any that may not be needed.
85
-
-**Network groups**— List network groups in `network.allowed:`. Flag unused ones.
86
-
-**Prompt length**— Estimate the markdown body size. Is it verbose?
87
-
-**Pre-agent steps**— Does it use `steps:` to pre-compute deterministic work?
88
-
-**Post-agent steps**— Does it use `post-steps:` for validation?
114
+
-**Tools loaded**\u2014 List all tools in the `tools:` section. Flag any that may not be needed.
115
+
-**Network groups**\u2014 List network groups in `network.allowed:`. Flag unused ones.
116
+
-**Prompt length**\u2014 Estimate the markdown body size. Is it verbose?
117
+
-**Pre-agent steps**\u2014 Does it use `steps:` to pre-compute deterministic work?
118
+
-**Post-agent steps**\u2014 Does it use `post-steps:` for validation?
89
119
90
-
## Step 4: Analyze Recent Run Artifacts
120
+
## Step 4: Analyze Recent Run Data
91
121
92
-
Download the most recent successful run's artifacts to understand actual tool usage:
122
+
The pre-agent step downloaded the last 7 days of Claude workflow logs to `/tmp/gh-aw/token-audit/claude-logs.json`. Filter this data for the target workflow:
93
123
94
124
```bash
95
-
# Find the latest successful run using the resolved workflow file
0 commit comments