-
Notifications
You must be signed in to change notification settings - Fork 277
Description
assign-to-agent fails with GitHub App tokens — Copilot assignment API requires a PAT
Summary
When using github-app: authentication in safe-outputs with assign-to-agent, the Copilot assignment fails with:
copilot coding agent (copilot-swe-agent) is not available as an assignee for this repository
The same repository works fine when assigning Copilot via the GitHub UI or using a fine-grained PAT with the same permissions. The root cause is that the GitHub Copilot assignment API does not accept GitHub App installation tokens — it specifically requires a PAT.
Analysis
Root Cause
The assign-to-agent safe output uses the token minted by create-github-app-token when github-app: is configured in safe-outputs. The Copilot assignment API (/repos/{owner}/{repo}/issues/{issue_number}/assignees with copilot-swe-agent) rejects GitHub App installation tokens regardless of the permissions granted.
This was confirmed by:
- ✅ Assigning Copilot to issues manually via the GitHub UI — works
- ✅ Using a fine-grained PAT with
actions:write,contents:write,issues:write,pull-requests:write— works - ❌ Using a GitHub App installation token with the same permissions — fails with "not available as an assignee"
- ❌ Adding
permission-actions: writeandpermission-contents: writeto thecreate-github-app-tokenstep — still fails (rules out missing permissions on the App token)
Affected Files
pkg/workflow/assign_to_agent.go—AssignToAgentConfigstruct and parsing logicactions/setup/js/assign_to_agent.cjs— Runtime script that calls the GitHub API to assign the agentpkg/workflow/compiler_types.go—SafeOutputsConfighas bothGitHubAppandGitHubTokenfieldsdocs/src/content/docs/reference/assign-to-copilot.mdx— Documentation
Secondary Issue: Missing Permissions in Compiled Output
When assign-to-agent is configured with github-app:, the compiler generates a create-github-app-token step requesting:
permission-contents: read(should bewrite)permission-issues: write✅permission-pull-requests: write✅permission-actions: writemissing entirely
The assign-to-copilot docs state the required permissions are: actions: write, contents: write, issues: write, pull-requests: write.
Reproduction
Workflow frontmatter (.md file)
safe-outputs:
github-app:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
assign-to-agent:
max: 3
target: "*"
allowed: [copilot]Steps to reproduce
- Create a workflow
.mdwith the abovesafe-outputsconfig usinggithub-app:auth - Compile with
gh aw compile(tested with v0.53.4) - Create an issue that triggers the workflow
- Observe the
assign_to_agentstep in thesafe_outputsjob logs:copilot coding agent (copilot-swe-agent) is not available as an assignee for this repository
Environment
- gh-aw version: v0.53.4
- GitHub App permissions: Actions (R/W), Contents (R/W), Issues (R/W), Pull requests (R/W)
- Repository: Organization-owned, Copilot coding agent enabled and assignable via UI
- Failed runs: https://github.com/DigitalInnovation/agentic-workflows-poc-/actions/runs/22734628337
Implementation Plan
Option A: Auto-fallback to GH_AW_AGENT_TOKEN (Recommended)
When assign-to-agent is configured and github-app: is the auth method, the compiler should automatically use the GH_AW_AGENT_TOKEN secret for the assignment step instead of the App installation token. The magic secret is already documented but the compiler doesn't wire it up when github-app: is present.
-
Update compiler (
pkg/workflow/safe_outputs.goor equivalent):- When emitting the
assign_to_agentstep in thesafe_outputsjob, check ifgithub-app:is the configured auth and no explicitgithub-token:is set - In that case, use
${{ secrets.GH_AW_AGENT_TOKEN }}as thegithub-tokenfor the assignment step - Keep using the App token for all other safe outputs (
add-comment,create-issue, etc.) which work fine with App tokens
- When emitting the
-
Add validation/warning (
pkg/workflow/validation.goor equivalent):- When
assign-to-agentis configured withgithub-app:and nogithub-token:override, emit a compiler warning:"assign-to-agent requires a fine-grained PAT. Set the GH_AW_AGENT_TOKEN secret or add github-token: to your assign-to-agent config. GitHub App tokens are not supported for Copilot assignment."
- When
-
Update tests (
pkg/workflow/safe_outputs_test.go,actions/setup/js/assign_to_agent.test.cjs):- Test that
assign-to-agentwithgithub-app:auth falls back toGH_AW_AGENT_TOKEN - Test that explicit
github-token:onassign-to-agentoverrides both App token and magic secret - Test that the compiler warning is emitted
- Test that
Option B: Fix permissions (even if Option A is implemented)
-
Fix token permissions (
pkg/workflow/safe_outputs.goor equivalent):- When
assign-to-agentis configured, thecreate-github-app-tokenstep should request:permission-actions: write(currently missing)permission-contents: write(currentlyread)
- This is needed even if Option A is implemented, for cases where a future GitHub API update enables App token support
- When
-
Update documentation (
docs/src/content/docs/reference/assign-to-copilot.mdx):- The "Using a GitHub App" section currently says: "Alternatively, you can use a GitHub App with appropriate permissions instead of a PAT for enhanced security."
- This should be updated to clarify that GitHub App tokens do not currently work for the Copilot assignment API
- Add a note that
GH_AW_AGENT_TOKEN(PAT) is required even when usinggithub-app:for other safe outputs
Follow Guidelines
- Use error message format: "[what's wrong]. [what's expected]. [example]"
- Run
make agent-finishbefore completing