Skip to content

Reduce scheduled workflow AI-credit burn and stagger the midnight batch#46510

Merged
pelikhan merged 3 commits into
mainfrom
copilot/aw-failures-fix-shared-ai-credit-budget
Jul 19, 2026
Merged

Reduce scheduled workflow AI-credit burn and stagger the midnight batch#46510
pelikhan merged 3 commits into
mainfrom
copilot/aw-failures-fix-shared-ai-credit-budget

Conversation

Copilot AI commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

The shared 1000-AIC pool was exhausted account-wide, causing scheduled agentic runs to hard-fail with 403 Maximum AI credits exceeded before doing useful work. The main burn driver was the Semantic Function Refactoring workflow’s expensive nightly sweep, compounded by several scheduled workflows firing in the same time window.

  • Constrain the highest-burn workflow

    • Added explicit per-run and daily budgets to semantic-function-refactor.
    • Lowered runtime cost by switching from claude-opus-4-8 to claude-sonnet-4.6.
    • Reduced turn budget to keep the run bounded.
  • Replace whole-repo analysis with a bounded deterministic slice

    • Added a pre-step that selects a small rotating package slice and writes the scoped file list to /tmp/gh-aw/agent/semantic-function-refactor/.
    • Updated the workflow prompt to treat that precomputed slice as the source of truth.
    • Explicitly forbids widening the scan or spawning subagent fan-out for duplicate sweeps.
  • Stagger the affected schedule cluster

    • Moved the implicated scheduled workflows off the same burst window so they no longer contend for the shared AIC pool at once:
      • semantic-function-refactor
      • auto-triage-issues
      • detection-analysis-report
      • duplicate-code-detector
      • unbloat-docs
  • Lock the behavior with a focused compile test

    • Added a workflow compilation test that verifies the semantic refactor workflow emits the intended schedule, budget guardrails, model selection, and bounded precompute step.

Example of the new bounded precompute pattern:

max-daily-ai-credits: 300
max-ai-credits: 300
max-turns: 30

steps:
  - name: Precompute semantic refactor slice
    run: |
      mkdir -p /tmp/gh-aw/agent/semantic-function-refactor
      # select a small rotating package slice
      # write targets.txt and go-files.txt for the agent

# Prompt contract:
# - only analyze /tmp/gh-aw/agent/semantic-function-refactor/go-files.txt
# - do not rescan all of pkg/
# - do not spawn subagents

Copilot AI and others added 2 commits July 19, 2026 02:06
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix shared AI-credit budget exhaustion issue Reduce scheduled workflow AI-credit burn and stagger the midnight batch Jul 19, 2026
Copilot AI requested a review from pelikhan July 19, 2026 02:17
@pelikhan
pelikhan marked this pull request as ready for review July 19, 2026 03:25
Copilot AI review requested due to automatic review settings July 19, 2026 03:25
@pelikhan
pelikhan merged commit 26eff5c into main Jul 19, 2026
@pelikhan
pelikhan deleted the copilot/aw-failures-fix-shared-ai-credit-budget branch July 19, 2026 03:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Reduces scheduled AI-credit usage by bounding the semantic-refactoring workflow and staggering related schedules.

Changes:

  • Adds semantic-refactoring budgets, a cheaper model, and rotating scope precomputation.
  • Staggers five scheduled workflows.
  • Adds compilation regression coverage.
Show a summary per file
File Description
.github/workflows/semantic-function-refactor.md Adds cost and scope controls.
.github/workflows/semantic-function-refactor.lock.yml Compiles semantic workflow changes.
.github/workflows/auto-triage-issues.md Staggers triage schedule.
.github/workflows/auto-triage-issues.lock.yml Compiles triage schedule.
.github/workflows/detection-analysis-report.md Staggers analysis schedule.
.github/workflows/detection-analysis-report.lock.yml Compiles analysis schedule.
.github/workflows/duplicate-code-detector.md Staggers duplicate scan.
.github/workflows/duplicate-code-detector.lock.yml Compiles duplicate-scan schedule.
.github/workflows/unbloat-docs.md Staggers documentation workflow.
.github/workflows/unbloat-docs.lock.yml Compiles documentation schedule.
pkg/workflow/semantic_function_refactor_workflow_test.go Tests compiled cost guardrails.

Review details

Tip

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

  • Files reviewed: 11/11 changed files
  • Comments generated: 4
  • Review effort level: Medium

schedule: daily
schedule:
- cron: "17 2 * * *" # Offset from the midnight/22:29 UTC workflow clusters
max-daily-ai-credits: 300
schedule:
- cron: "17 2 * * *" # Offset from the midnight/22:29 UTC workflow clusters
max-daily-ai-credits: 300
max-ai-credits: 300
set -euo pipefail
mkdir -p /tmp/gh-aw/agent/semantic-function-refactor

mapfile -t packages < <(find pkg -mindepth 1 -maxdepth 1 -type d | sort)
`17 2 * * *`,
`GH_AW_MAX_DAILY_AI_CREDITS: "300"`,
`"maxAiCredits":300`,
`claude-sonnet-4.6`,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw-failures] [aw-fix] P0: Shared AI-credit budget exhausted (1006/1000 AIC) — 403 hard-fails agentic runs account-wide

3 participants