Start Debugging

How to Estimate GitHub Agentic Workflows AI Credit Spend with gh aw forecast Before Enabling a Workflow

gh aw forecast projects weekly and monthly AI Credit (AIC) spend for GitHub Agentic Workflows from real run history with a 10,000-trial Monte Carlo model. Flags, the JSON fields worth reading, how to seed a forecast for a workflow that has never run, backtesting with --eval, and four places the model undercounts.

This site uses Walter, an AI agent, for research, writing, and maintenance. Editorial and verification process

To estimate what a GitHub Agentic Workflow will cost before you let it run on its real trigger, give it a small, capped sample of real runs (workflow_dispatch with max-ai-credits set), then run gh aw forecast <workflow-id> --json and read p50_aic_per_run and p95_aic_per_run. Multiply those per-run figures by the number of times the real trigger will fire, because the run frequency forecast sees is your manual test cadence, not the future one. Once the workflow has a few weeks of genuine history, plain gh aw forecast (no arguments) projects weekly and monthly AI Credits for every agentic workflow in the repo, and gh aw forecast --eval tells you how far off last period’s projection was.

Everything below is based on the gh-aw source on main (pkg/cli/forecast*.go) and the cost management reference as of December 4, 2026. The latest release marked “Latest” is v1.2.2 (November 10, 2026), with pre-releases up to v1.4.6. The command arrived in PR #31377 on May 11, 2026 as an experimental feature and has since been promoted out of experimental status in the forecast specification. The commands were not executed against a live repository for this article, so treat the output shapes as taken from the renderer code, not from a captured run.

Why per-run cost is the number that matters before go-live

GitHub Agentic Workflows went generally available on October 28, 2026, and its cost unit is the AI Credit. The cost management page is blunt about the conversion: “One AIC equals $0.01 USD.” Every run’s token usage (input, output, cache reads and writes, reasoning) is priced against the model catalog that the Agent Workflow Firewall (AWF) maintains and reported as AIC by gh aw logs, gh aw audit, and the run footer.

The default guardrails are also in AIC: 1,000 AIC per run (max-ai-credits) and 5,000 AIC per workflow per rolling 24 hours (max-daily-ai-credits). That is $10 per run and $50 per workflow per day before anything else kicks in. Those caps stop a runaway, but they do not tell you what normal looks like. A triage workflow on issues: opened in a busy repo that costs 40 AIC per run is cheap; the same workflow at 600 AIC per run will hit the daily cap by lunch and start skipping issues silently. You want to know which one you have before you merge the workflow file, and that is what forecast is for.

If you have not used gh-aw yet, the overview of what Agentic Workflows adds on top of Actions covers the compile step, engines, and safe-outputs this post assumes.

What gh aw forecast actually computes

The command’s help text summarizes it: it samples recent completed runs, derives per-run AIC, duration, and success rate, then projects the observed frequency forward “using a statistical simulation that models three sources of uncertainty: run count (Poisson), per-run AIC usage (bootstrap resampling), and per-run success (Bernoulli).”

Concretely, for each workflow:

  1. It lists runs of the compiled .lock.yml in the history window (--days, 7 or 30) and keeps at most --sample of them (default 100). Runs that never dispatched a job (skipped, action_required) are dropped. In-progress runs are kept and count as non-success.
  2. For each run it looks up the AIC. It first reads the run_summary.json that gh aw logs caches under .github/aw/logs/run-<id>/, then a forecast-specific cache, and only then downloads the run’s usage artifact (8 downloads in parallel by default, --concurrency to change it).
  3. It computes the deterministic numbers: average AIC, P50 and P95 AIC per run, success rate, and observed_runs_per_period = sampled_runs / history_days * period_days.
  4. It runs 10,000 Monte Carlo trials. Each trial draws a run rate from a Gamma posterior (Jeffreys prior, so a small sample widens the spread), draws a run count from Poisson, and for each simulated run that “succeeds”, adds a bootstrap-resampled AIC value. The P10, P50, and P90 of those 10,000 totals become the confidence interval, and P50 becomes projected_aic.

A projection is flagged as unreliable (an asterisk in the table) when fewer than 10 runs have AIC data. That threshold matters for the pre-launch case below.

The flags, straight from the source

# gh-aw v1.2.x / main as of 2026-12-04
gh aw forecast [workflow-id...] \
  --days 30          # history window: 7 or 30 only, anything else is an error
  --period month     # week | month; drives projected_aic and the eval window
  --sample 100       # max runs sampled per workflow
  --eval             # backtest: train on the window before the last period, compare
  --timeout 10       # minutes (or "10m"); 0 = no timeout, exits 124 on timeout
  --concurrency 0    # parallel usage-artifact downloads, 0 = default of 8
  --repo owner/repo  # remote mode, no local checkout needed
  --json             # full result on stdout

The forecast specification also documents a --max-age flag, but forecast_command.go does not register one. If a doc example with --max-age fails, that is why; go by gh aw forecast --help on your installed version.

With no workflow arguments, every agentic workflow in the repo is forecast and sorted by projected P50, with a TOTAL row. With one or more IDs, you also get a “Sampled runs used in computation” table listing each run ID, date, and AIC, which is the fastest way to spot one outlier run dragging the average.

The console table goes to stderr and has these columns, regardless of --period:

Workflow | Runs | P50 AIC/Run | P95 AIC/Run | Weekly AIC (P50) | Monthly AIC (P50) | Success Rate

Values of 1,000 or more are abbreviated with K and M. The P10/P90 interval only appears in --json.

Seeding a forecast for a workflow that has never run

Here is the catch with “before enabling a workflow”: forecast has no simulator. It reads past runs. A workflow with zero runs in the window returns sampled_runs: 0, a zero projection, and no monte_carlo object. So you need a sample first, and you want that sample to be cheap and bounded.

Add workflow_dispatch next to the real trigger and put a tight per-run cap on it while you measure:

---
# .github/workflows/issue-triage.md, gh-aw v1.2.x
on:
  issues:
    types: [opened]
  workflow_dispatch:
    inputs:
      issue_number:
        description: "Issue to triage"
        required: true
permissions:
  contents: read
  issues: read
  copilot-requests: write
model: router/economy
max-ai-credits: 200
max-daily-ai-credits: 1000
safe-outputs:
  add-labels:
    max: 3
  add-comment:
---

Triage the issue that triggered this run: the opened issue, or on a manual
run the issue number passed in the `issue_number` input. Read the issue, apply up to three existing labels, and leave one comment
asking for a repro if none is present.

max-ai-credits: 200 is a hard stop per run ($2), and max-daily-ai-credits: 1000 keeps the whole measurement exercise under $10 a day. The cost management page notes that router/economy “is not a guaranteed spending cap”, which is exactly why the explicit cap sits next to it.

If you do not want the real trigger live yet, leave issues: out during this phase and add it back afterwards. Compile and push, then dispatch it against a spread of real issues, short and long, so the bootstrap has realistic variance:

gh aw compile issue-triage
git add .github/workflows/issue-triage.md .github/workflows/issue-triage.lock.yml
git commit -m "Add issue-triage (dispatch only, capped)"
git push

for n in 412 418 431 437 440 452 455 461 470 478 483 490; do
  gh workflow run issue-triage.lock.yml -f issue_number="$n"
done

Twelve runs clears the 10-observation reliability threshold with a little room for one or two that fail. After they finish, warm the cache and forecast just that workflow:

gh aw logs issue-triage --json > /dev/null   # caches run_summary.json per run
gh aw forecast issue-triage --days 7 --json > forecast.json
jq '.workflows[0] | {sampled_runs, success_rate, avg_aic, p50_aic_per_run, p95_aic_per_run}' forecast.json

Ignore weekly_projected_aic and monthly_projected_aic here. They are built from observed_runs_per_period, which right now is “twelve runs in seven days because I fired them by hand”. The per-run numbers are the real output of this phase.

Now do the frequency part yourself. Pull how often the real trigger fires from the repo’s own history, for example issues opened in the last 30 days:

gh issue list --state all --search "created:>=2026-11-04" --limit 1000 --json number | jq length

Say that returns 180 issues, so about 6 a day. With a P50 of 45 AIC per run and a P95 of 140:

  • Typical month: 180 runs x 45 AIC = 8,100 AIC, about $81.
  • Bad month, every run at P95: 180 x 140 = 25,200 AIC, about $252.
  • Daily ceiling check: 6 runs x 140 AIC = 840 AIC, under the 1,000 daily cap. A day with 10 issues at P95 (1,400 AIC) would hit it and skip triage for the rest of the day.

That last line is the decision you actually needed: either raise max-daily-ai-credits, accept skipped triage on busy days, or make the prompt cheaper. If you prefer setting the daily ceiling at the org level, gh aw env update takes default_max_ai_credits and default_max_daily_ai_credits, documented on the same cost management page.

Once it is live: the normal forecast and backtesting

After two to four weeks on the real trigger, drop the manual math and let the tool do the projection:

gh aw forecast                      # all workflows, 30-day history, monthly
gh aw forecast --period week --days 7
gh aw forecast --repo my-org/api --json | jq '.workflows[] | {workflow_id, monthly: .monthly_monte_carlo.p50_projected_aic, p90: .monthly_monte_carlo.p90_projected_aic}'

Budget against p90_projected_aic, not P50. P50 is the month you expect; P90 is the month you should be able to pay for without a surprise.

Then check whether the model deserves your trust with --eval. It shifts the training window back by one period, forecasts that period from the older data, and compares against what actually happened:

gh aw forecast issue-triage --eval --period week --days 30

The JSON evaluation object carries actual_runs, actual_aic, p50_error_abs, p50_error_pct, and in_ci, which is true when the actual spend landed inside P10 to P90. If in_ci is false for several weeks in a row, your workload is not stationary (a release week, a spam wave of issues) and the forecast is a floor, not an estimate.

gh-aw itself runs this on a schedule: its own daily-spending-forecast.md workflow calls forecast --repo "$REPOSITORY" --days 30 --period month --sample 100 --concurrency 8 --timeout 10, after a first pass with --timeout 25 purely to pre-download usage artifacts into the cache. Copying that two-pass pattern into your own scheduled job keeps the second, real run fast.

Four places the forecast undercounts

Reading forecast_compute.go and forecast_montecarlo.go turns up a few behaviors that all bias the number down. None of them are bugs exactly, but you should know them before you put a forecast in a budget.

Failed runs contribute zero credits in the simulation. Each simulated run is skipped when the Bernoulli draw says it failed: if rng.Float64() >= successRate { continue }. A failed agent run still spent tokens up to the point it failed. A workflow with a 70% success rate will be projected roughly 30% low on the runs that fail. Check success_rate first, and if it is low, use the deterministic avg_aic * observed_runs_per_period or your own manual math as the upper reference.

The sample cap also caps frequency. observed_runs_per_period is computed from the number of sampled runs, and the sample is truncated at --sample. A workflow that fired 400 times in 30 days, sampled at the default 100, is treated as running 100 times in 30 days, so the monthly projection is about four times too low. For high-frequency workflows use --days 7 or raise --sample well above the real run count.

Missing usage data shrinks the sample. Runs whose AIC cannot be loaded are skipped from the statistics, and an expired artifact (past the repository’s retention) is one way to get there. Running gh aw logs regularly caches run_summary.json locally so that older runs stay countable.

Rate limits skip a workflow with only a warning. If listing runs hits the GitHub API rate limit, the workflow is returned with an empty result after a “Skipping …: GitHub API rate limit exceeded” line on stderr. In a scheduled job that only parses --json, that workflow simply reads as zero. Check stderr, or compare sampled_runs against what you expect.

Two smaller notes: Monte Carlo results vary slightly between runs because the seed is the current time, so do not diff P50 values to the credit; and AIC is the AWF cost metric, separate from the Copilot credit unit (nano-AIU) that Copilot’s own session telemetry reports.

Where forecast fits with logs, audit, and Copilot billing

gh aw audit <run-id> answers “why did this one run cost what it did”. gh aw logs answers “what did the last N runs cost” and feeds forecast its cache. forecast answers “what will next week or month cost if nothing changes”. None of them is your bill; for that, Copilot billing and the usage metrics API remain the source of truth, and tracking agent usage by client in the Copilot usage metrics API covers that side.

For interactive Copilot CLI and SDK sessions, where there is no workflow history to forecast from, the equivalent control is a per-session budget, covered in setting AI credit session limits in Copilot CLI and the SDK. If you are still choosing between gh-aw and the other ways to run Copilot unattended, dynamic workflows vs fleet vs Agentic Workflows compares them, and running Agentic Workflows on the built-in GITHUB_TOKEN covers the copilot-requests: write permission used in the example above.

Sources

Comments

Sign in with GitHub to comment. Reactions and replies thread back to the comments repo.