Skip to content

[BLOCKED] Use Copilot org billing for the repo's internal agentic workflows instead of a PAT#1733

Draft
MRayermannMSFT wants to merge 1 commit into
mainfrom
dev/mrayermannmsft/other/gh-aw-org-billing-no-pat
Draft

[BLOCKED] Use Copilot org billing for the repo's internal agentic workflows instead of a PAT#1733
MRayermannMSFT wants to merge 1 commit into
mainfrom
dev/mrayermannmsft/other/gh-aw-org-billing-no-pat

Conversation

@MRayermannMSFT

@MRayermannMSFT MRayermannMSFT commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Warning

Blocked / do not merge — a dispatcher↔handler coupling means this needs a maintainer decision first. See the pinned comment.

What Switches the repo's 7 internal (event-triggered) gh-aw agentic workflows from a user-supplied COPILOT_GITHUB_TOKEN PAT to organization billing, so the Copilot engine authenticates with the built-in GITHUB_TOKEN. Each affected workflow's frontmatter gains permissions: copilot-requests: write; recompiling drops the COPILOT_GITHUB_TOKEN secret (and its validation step) and routes Copilot inference through the org's Copilot tenant. Affected (internal) workflows: sdk-consistency-review, issue-triage, issue-classification, release-changelog, cross-repo-issue-analysis, java-codegen-fix, java-adapt-handwritten-code-to-accept-upgrade-changes. ## Deliberately NOT changed: the reusable workflows The 4 reusable (workflow_call) workflows — handle-bug, handle-question, handle-enhancement, handle-documentation — are intentionally left on the PAT. These are designed to be invoked from other repositories, and a non-org caller repo cannot use org billing (copilot-requests: write has no org Copilot tenant to bill against) — it genuinely needs COPILOT_GITHUB_TOKEN. Migrating them would break that cross-repo portability contract and is the maintainers' call, so this PR leaves them untouched. ## Why The repo's own internal workflows depend on a COPILOT_GITHUB_TOKEN PAT that ties CI to one person's account/entitlement, requires managing a secret, and attributes inference to the PAT owner rather than the organization. For workflows that only ever run inside this org-owned repo, gh-aw's copilot-requests: write path uses the Actions token billed centrally to the org, removing the PAT. (github/copilot-agent-runtime adopted this — see github/copilot-agent-runtime#10632 / #10729.) ## Verified before merge A live test (stacked PR, since closed) confirmed sdk-consistency-review runs the org-billing lock successfully: the agent job authenticated via the built-in GITHUB_TOKEN (no PAT in scope, no validate-secret step), proving org billing is enabled for this repo. ## How the diff was kept minimal Recompiled with this repo's existing gh-aw compiler version (v0.77.5), so action pins/structure are unchanged — a no-op recompile produced zero diff. The only edits are +1 line per .md plus the mechanical lock changes gh aw compile generates for the auth swap. ## Prerequisite Org policy must allow Copilot-CLI org billing for this repo (Org → Settings → Copilot → Policies → Copilot CLI). The live test confirmed it is currently enabled. ## Follow-ups (not in this PR) - The 2 hand-rolled workflows (java-codegen-check.yml, java-smoke-test.yml) still use the PAT. - If the repo later upgrades gh-aw past v0.77.5 (gaining the daily-AIC guardrail + confused-deputy bot guard), consider setting GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS (≈50,000, based on measured volume) and bots: ["dependabot"].

@MRayermannMSFT

Copy link
Copy Markdown
Contributor Author

Live test passed ✅

Verified before merge via a stacked test PR (#1734, since closed): a nodejs/** change triggered sdk-consistency-review running this branch's org-billing lock. All jobs (activation → agent → detection → safe_outputs → conclusion) succeeded — the Copilot engine authenticated with the built-in GITHUB_TOKEN (no COPILOT_GITHUB_TOKEN PAT in scope), confirming org billing is enabled for this repo.

Post-merge follow-ups (not in this PR)

These only become relevant if the repo later upgrades gh-aw past v0.77.5, which introduces two guards this version predates:

  • Daily AI-credit guardrail. Newer gh-aw caps per-workflow daily AIC (default 5,000). Given measured volume (sdk-consistency-review peaks ~44 runs/day), a busy day is roughly 12k–18k AIC, so the default would throttle the reviewer. Recommend setting repo variable GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS to 50000 (≈3× headroom) at that point, and/or a cheaper per-workflow model override.
  • Confused-deputy bot guard. Newer gh-aw blocks bot-authored events unless allowlisted. The only bot pushing to PRs here is dependabot, so add bots: ["dependabot"] under on: then (gh-aw may already exempt it by default — verify at upgrade time).

The two hand-rolled workflows (java-codegen-check.yml, java-smoke-test.yml) still use the PAT and are intentionally left for a follow-up.

@MRayermannMSFT MRayermannMSFT marked this pull request as ready for review June 19, 2026 16:55
@MRayermannMSFT MRayermannMSFT requested a review from a team as a code owner June 19, 2026 16:55
Copilot AI review requested due to automatic review settings June 19, 2026 16:55

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

This PR updates the repo’s 11 gh-aw agentic workflows to authenticate Copilot inference using organization billing via the built-in GITHUB_TOKEN (instead of a user-provided COPILOT_GITHUB_TOKEN PAT), by adding permissions: copilot-requests: write and regenerating the compiled lock workflows accordingly.

Changes:

  • Add permissions: copilot-requests: write to each of the 11 gh-aw source workflows (.md).
  • Regenerate each compiled workflow (*.lock.yml) to drop the COPILOT_GITHUB_TOKEN secret/validation wiring and instead use COPILOT_GITHUB_TOKEN: ${{ github.token }} plus S2STOKENS: true.
  • Update job-level permissions in compiled workflows where explicit permission blocks are present so Copilot requests are allowed.
Show a summary per file
File Description
.github/workflows/sdk-consistency-review.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/sdk-consistency-review.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/release-changelog.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/release-changelog.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/java-codegen-fix.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/java-codegen-fix.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/java-adapt-handwritten-code-to-accept-upgrade-changes.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/java-adapt-handwritten-code-to-accept-upgrade-changes.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/issue-triage.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/issue-triage.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/issue-classification.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/issue-classification.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS, adjust called-job permissions.
.github/workflows/handle-question.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/handle-question.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/handle-enhancement.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/handle-enhancement.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/handle-documentation.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/handle-documentation.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/handle-bug.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/handle-bug.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.
.github/workflows/cross-repo-issue-analysis.md Add copilot-requests: write to enable org-billed Copilot requests.
.github/workflows/cross-repo-issue-analysis.lock.yml Recompiled to stop requiring PAT secret; use github.token + S2STOKENS.

Copilot's findings

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

Comment thread .github/workflows/handle-bug.lock.yml
Comment thread .github/workflows/handle-question.lock.yml
Comment thread .github/workflows/handle-enhancement.lock.yml
Comment thread .github/workflows/handle-documentation.lock.yml
@MRayermannMSFT MRayermannMSFT marked this pull request as draft June 19, 2026 17:07
@MRayermannMSFT MRayermannMSFT force-pushed the dev/mrayermannmsft/other/gh-aw-org-billing-no-pat branch from 91e6a32 to a96c8f9 Compare June 19, 2026 17:08
@MRayermannMSFT MRayermannMSFT changed the title Use Copilot org billing for agentic workflows instead of a PAT Use Copilot org billing for the repo's internal agentic workflows instead of a PAT Jun 19, 2026
@MRayermannMSFT

Copy link
Copy Markdown
Contributor Author

Scope narrowed after review

Per discussion, this PR now migrates only the 7 internal, event-triggered workflows and leaves the 4 reusable (workflow_call) handle-* workflows on COPILOT_GITHUB_TOKEN.

Reason: handle-bug, handle-question, handle-enhancement, and handle-documentation are designed to be called from other repositories. A non-org caller repo cannot use org billing (there's no org Copilot tenant to bill against) and genuinely needs a PAT — so migrating them would break their cross-repo portability contract. That's a deliberate design decision for the maintainers, so this PR no longer touches them. This also resolves the Copilot review comments about the now-stale cross-repo COPILOT_GITHUB_TOKEN guidance (those workflows are unchanged from main).

Re-converted to draft for another look given the narrowed scope.

@MRayermannMSFT

Copy link
Copy Markdown
Contributor Author

⚠️ Blocked — maintainer input needed (do not merge)

While validating, I found that the dispatcher + handlers are a coupled unit: issue-classification calls handle-bug / handle-question / handle-enhancement / handle-documentation locally (uses: ./.github/workflows/handle-*.lock.yml) and passes Copilot auth through to them. So those 5 workflows must share one auth mode — migrating issue-classification to org billing while leaving the handle-* workflows on the PAT means the dispatcher stops passing COPILOT_GITHUB_TOKEN, and the handlers' auth fails at runtime. (The current scoped diff has exactly this inconsistency and is therefore not mergeable as-is.)

Open question for maintainers: does any external / non-org repository invoke these reusable handle-* workflows via uses: github/copilot-sdk/.github/workflows/handle-*.lock.yml@..., or are they only ever called locally by issue-classification within this repo?

  • If only local (org-owned repo): org billing works for them too → migrate the whole unit (all 11) to org billing.
  • If external/non-org callers exist: keep the whole unit (issue-classification + the 4 handle-*) on the PAT, and migrate only the 6 standalone workflows (sdk-consistency-review, issue-triage, release-changelog, cross-repo-issue-analysis, java-codegen-fix, java-adapt-handwritten-code-to-accept-upgrade-changes).

Parking this in draft pending that answer. (Aside: a per-repo runtime gate — org billing in the org repo, PAT otherwise — is conceptually expressible via github.repository_owner, but gh-aw generates the lock and offers no conditional-billing knob today, so it isn't practical without a gh-aw feature.)

@MRayermannMSFT MRayermannMSFT changed the title Use Copilot org billing for the repo's internal agentic workflows instead of a PAT [BLOCKED] Use Copilot org billing for the repo's internal agentic workflows instead of a PAT Jun 19, 2026
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.

2 participants