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: write and permission-contents: write to the create-github-app-token step — still fails (rules out missing permissions on the App token)
Affected Files
pkg/workflow/assign_to_agent.go — AssignToAgentConfig struct and parsing logic
actions/setup/js/assign_to_agent.cjs — Runtime script that calls the GitHub API to assign the agent
pkg/workflow/compiler_types.go — SafeOutputsConfig has both GitHubApp and GitHubToken fields
docs/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 be write)
permission-issues: write ✅
permission-pull-requests: write ✅
permission-actions: write missing 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
.md with the above safe-outputs config using github-app: auth
- Compile with
gh aw compile (tested with v0.53.4)
- Create an issue that triggers the workflow
- Observe the
assign_to_agent step in the safe_outputs job logs:
copilot coding agent (copilot-swe-agent) is not available as an assignee for this repository
Environment
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.go or equivalent):
- When emitting the
assign_to_agent step in the safe_outputs job, check if github-app: is the configured auth and no explicit github-token: is set
- In that case, use
${{ secrets.GH_AW_AGENT_TOKEN }} as the github-token for the assignment step
- Keep using the App token for all other safe outputs (
add-comment, create-issue, etc.) which work fine with App tokens
-
Add validation/warning (pkg/workflow/validation.go or equivalent):
- When
assign-to-agent is configured with github-app: and no github-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."
-
Update tests (pkg/workflow/safe_outputs_test.go, actions/setup/js/assign_to_agent.test.cjs):
- Test that
assign-to-agent with github-app: auth falls back to GH_AW_AGENT_TOKEN
- Test that explicit
github-token: on assign-to-agent overrides both App token and magic secret
- Test that the compiler warning is emitted
Option B: Fix permissions (even if Option A is implemented)
-
Fix token permissions (pkg/workflow/safe_outputs.go or equivalent):
- When
assign-to-agent is configured, the create-github-app-token step should request:
permission-actions: write (currently missing)
permission-contents: write (currently read)
- This is needed even if Option A is implemented, for cases where a future GitHub API update enables App token support
-
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 using github-app: for other safe outputs
Follow Guidelines
- Use error message format: "[what's wrong]. [what's expected]. [example]"
- Run
make agent-finish before completing
assign-to-agentfails with GitHub App tokens — Copilot assignment API requires a PATSummary
When using
github-app:authentication insafe-outputswithassign-to-agent, the Copilot assignment fails with: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-agentsafe output uses the token minted bycreate-github-app-tokenwhengithub-app:is configured insafe-outputs. The Copilot assignment API (/repos/{owner}/{repo}/issues/{issue_number}/assigneeswithcopilot-swe-agent) rejects GitHub App installation tokens regardless of the permissions granted.This was confirmed by:
actions:write,contents:write,issues:write,pull-requests:write— workspermission-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— DocumentationSecondary Issue: Missing Permissions in Compiled Output
When
assign-to-agentis configured withgithub-app:, the compiler generates acreate-github-app-tokenstep requesting:permission-contents: read(should bewrite)permission-issues: write✅permission-pull-requests: write✅permission-actions: writemissing entirelyThe assign-to-copilot docs state the required permissions are:
actions: write,contents: write,issues: write,pull-requests: write.Reproduction
Workflow frontmatter (
.mdfile)Steps to reproduce
.mdwith the abovesafe-outputsconfig usinggithub-app:authgh aw compile(tested with v0.53.4)assign_to_agentstep in thesafe_outputsjob logs:Environment
Implementation Plan
Option A: Auto-fallback to
GH_AW_AGENT_TOKEN(Recommended)When
assign-to-agentis configured andgithub-app:is the auth method, the compiler should automatically use theGH_AW_AGENT_TOKENsecret for the assignment step instead of the App installation token. The magic secret is already documented but the compiler doesn't wire it up whengithub-app:is present.Update compiler (
pkg/workflow/safe_outputs.goor equivalent):assign_to_agentstep in thesafe_outputsjob, check ifgithub-app:is the configured auth and no explicitgithub-token:is set${{ secrets.GH_AW_AGENT_TOKEN }}as thegithub-tokenfor the assignment stepadd-comment,create-issue, etc.) which work fine with App tokensAdd validation/warning (
pkg/workflow/validation.goor equivalent):assign-to-agentis configured withgithub-app:and nogithub-token:override, emit a compiler warning:Update tests (
pkg/workflow/safe_outputs_test.go,actions/setup/js/assign_to_agent.test.cjs):assign-to-agentwithgithub-app:auth falls back toGH_AW_AGENT_TOKENgithub-token:onassign-to-agentoverrides both App token and magic secretOption B: Fix permissions (even if Option A is implemented)
Fix token permissions (
pkg/workflow/safe_outputs.goor equivalent):assign-to-agentis configured, thecreate-github-app-tokenstep should request:permission-actions: write(currently missing)permission-contents: write(currentlyread)Update documentation (
docs/src/content/docs/reference/assign-to-copilot.mdx):GH_AW_AGENT_TOKEN(PAT) is required even when usinggithub-app:for other safe outputsFollow Guidelines
make agent-finishbefore completing