Skip to content

fix: token analyzers look for wrong artifact name#1883

Closed
lpcox wants to merge 3 commits intomainfrom
fix/token-analyzer-artifact-name
Closed

fix: token analyzers look for wrong artifact name#1883
lpcox wants to merge 3 commits intomainfrom
fix/token-analyzer-artifact-name

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Apr 10, 2026

Problem

The token usage analyzer and optimizer workflows were downloading agent-artifacts to find token-usage.jsonl, but the actual artifact uploaded by all AWF workflows is firewall-audit-logs. The token data lives at logs/api-proxy-logs/token-usage.jsonl inside that artifact.

This caused the daily reports to claim 'no token data' for workflows like Smoke Copilot, even though the data was present and accessible.

Fix

Updated all 4 token analysis workflows to download firewall-audit-logs instead of agent-artifacts:

  • copilot-token-usage-analyzer.md
  • claude-token-usage-analyzer.md
  • copilot-token-optimizer.md
  • claude-token-optimizer.md

Impact

Future token usage reports should now correctly capture data from all workflows that use --enable-api-proxy, including Smoke Copilot (which has cli-proxy enabled — useful for measuring cli-proxy token efficiency).

The token usage analyzer and optimizer workflows were downloading
`agent-artifacts` to find `token-usage.jsonl`, but the actual
artifact name is `firewall-audit-logs` (nested under
`logs/api-proxy-logs/token-usage.jsonl`).

This caused the analyzers to report 'no token data' for workflows
like Smoke Copilot even though the data was present.

Updated all 4 workflows:
- copilot-token-usage-analyzer.md
- claude-token-usage-analyzer.md
- copilot-token-optimizer.md
- claude-token-optimizer.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox requested a review from Mossaka as a code owner April 10, 2026 17:48
Copilot AI review requested due to automatic review settings April 10, 2026 17:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the token usage analyzer/optimizer workflow prompts to download the correct artifact (firewall-audit-logs) when locating token-usage.jsonl, aligning the analyzers with how AWF workflows actually upload token usage logs.

Changes:

  • Update Copilot + Claude token usage analyzer prompts to reference firewall-audit-logs (and the logs/api-proxy-logs/ location).
  • Update Copilot + Claude token optimizer prompts to download firewall-audit-logs instead of the previously referenced artifact name.
Show a summary per file
File Description
.github/workflows/copilot-token-usage-analyzer.md Updates analyzer instructions to download firewall-audit-logs and locate token logs within it.
.github/workflows/claude-token-usage-analyzer.md Same as above, scoped to Claude workflows and provider filtering guidance.
.github/workflows/copilot-token-optimizer.md Updates optimizer artifact download instructions to use firewall-audit-logs.
.github/workflows/claude-token-optimizer.md Updates optimizer artifact download instructions to use firewall-audit-logs.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment thread .github/workflows/copilot-token-optimizer.md Outdated
Comment thread .github/workflows/claude-token-optimizer.md Outdated
lpcox and others added 2 commits April 10, 2026 10:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Smoke test results:

  • Merged PR review (MCP): ✅ chore: upgrade gh-aw to v0.68.0 and auto-discover lock files; feat: add historical benchmark storage and trend reporting
  • PR query via safeinputs-gh: ❌ (tool unavailable in this run)
  • Playwright (github.com title contains GitHub): ✅
  • Tavily search: ❌ (Tavily MCP unavailable)
  • File write + bash cat: ✅
  • Discussion oracle comment: ❌ (discussion query tool unavailable)
  • Build (npm ci && npm run build): ✅
    Overall status: FAIL

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

  • ✅ GitHub MCP: "chore: upgrade gh-aw to v0.68.0 and auto-discover lock files", "chore: upgrade gh-aw and recompile all workflows"
  • ✅ Playwright: github.com title contains "GitHub"
  • ✅ File write: /tmp/gh-aw/agent/smoke-test-claude-24256448107.txt created
  • ✅ Bash: file read back successfully

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions github-actions Bot mentioned this pull request Apr 10, 2026
@lpcox lpcox closed this Apr 10, 2026
lpcox added a commit that referenced this pull request Apr 10, 2026
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>
lpcox added a commit that referenced this pull request Apr 10, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants