-
Notifications
You must be signed in to change notification settings - Fork 296
[WIP] Improve cost management reference documentation #20128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,61 @@ The agent job invokes an AI engine (Copilot, Claude, Codex, or a custom engine) | |||||
| > [!NOTE] | ||||||
| > For Copilot, inference is charged to the individual account owning `COPILOT_GITHUB_TOKEN`, not to the repository or organization running the workflow. Use a dedicated service account and monitor its premium request usage to track spend per workflow. | ||||||
|
|
||||||
| ## Monitoring Costs with `gh aw logs` | ||||||
|
|
||||||
| The `gh aw logs` command downloads workflow run data and surfaces per-run metrics including elapsed duration, token usage, and estimated inference cost. Use it to see exactly what your workflows are consuming before deciding what to optimize. | ||||||
|
|
||||||
| ### View recent run durations | ||||||
|
|
||||||
| ```bash | ||||||
| # Overview table for all agentic workflows (last 10 runs) | ||||||
| gh aw logs | ||||||
|
|
||||||
| # Narrow to a single workflow | ||||||
| gh aw logs issue-triage-agent | ||||||
|
|
||||||
| # Last 30 days for Copilot workflows | ||||||
| gh aw logs --engine copilot --start-date -30d | ||||||
| ``` | ||||||
|
|
||||||
| The overview table includes a **Duration** column showing elapsed wall-clock time per run. Because GitHub Actions bills compute time by the minute (rounded up per job), duration is the primary indicator of Actions spend. | ||||||
|
|
||||||
| ### Export metrics as JSON | ||||||
|
|
||||||
| Use `--json` to get structured output suitable for scripting or trend analysis: | ||||||
|
|
||||||
| ```bash | ||||||
| # Write JSON to a file for further processing | ||||||
| gh aw logs --start-date -1w --json > /tmp/logs.json | ||||||
|
|
||||||
| # List per-run duration, tokens, and cost across all workflows | ||||||
| gh aw logs --start-date -30d --json | \ | ||||||
| jq '.runs[] | {workflow: .workflow_name, duration: .duration, cost: .estimated_cost}' | ||||||
|
||||||
| jq '.runs[] | {workflow: .workflow_name, duration: .duration, cost: .estimated_cost}' | |
| jq '.runs[] | {workflow: .workflow_name, duration: .duration, tokens: .token_usage, cost: .estimated_cost}' |
Copilot
AI
Mar 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jq example that uses group_by(.workflow_name) will produce incorrect totals unless the input array is sorted by workflow_name first (jq groups only adjacent equal keys). Consider adding sort_by(.workflow_name) before group_by, or use a reduce-based aggregation.
| jq '[.runs[]] | group_by(.workflow_name) | | |
| jq '[.runs[]] | sort_by(.workflow_name) | group_by(.workflow_name) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description checklist mentions adding a concrete meta-agent workflow snippet to the “Agentic Cost Optimization” section, but this file still contains only narrative text in that section (no snippet/example workflow). Either add the promised snippet or update the PR description to match the actual changes.