GitHub Agentic Workflows

Assign to Copilot

This page describes how to programmatically assign the GitHub Copilot coding agent to issues or pull requests using the assign-to-agent safe output. This automates the standard GitHub workflow for assigning issues to Copilot.

Use assign-to-agent when you need to programmatically assign Copilot coding agent to existing issues or PRs through workflow automation.

If you’re creating new issues and want to assign Copilot coding agent immediately, use assignees: copilot in your create-issue configuration instead.

safe-outputs:
assign-to-agent:
name: "copilot" # default agent (default: "copilot")
model: "claude-opus-4.6" # default AI model (default: "auto")
custom-agent: "agent-id" # default custom agent ID (optional)
custom-instructions: "..." # default custom instructions (optional)
allowed: [copilot] # restrict to specific agents (optional)
max: 1 # max assignments (default: 1)
target: "triggering" # "triggering" (default), "*", or number
target-repo: "owner/repo" # where the issue lives (cross-repository)
pull-request-repo: "owner/repo" # where the PR should be created (may differ from issue repo)
allowed-pull-request-repos: [owner/repo1, owner/repo2] # additional allowed PR repositories
base-branch: "develop" # target branch for PR (default: target repo's default branch)
github-token: ${{ secrets.GH_AW_AGENT_TOKEN }} # token for permissions

Supported agents: copilot (copilot-swe-agent)

The target parameter determines which issue or PR to assign the agent to:

  • target: "triggering" (default) - Auto-resolves from github.event.issue.number or github.event.pull_request.number
  • target: "*" - Requires explicit issue_number or pull_number in agent output
  • target: "123" - Always uses issue/PR #123

Use pull-request-repo to create pull requests in a different repository than where the issue lives — useful when issues are tracked centrally but code lives elsewhere. The issue repository is determined by target-repo or defaults to the workflow’s repository.

pull-request-repo is automatically included in the allowed list; use allowed-pull-request-repos for additional repositories. Use base-branch to target a specific branch (defaults to the target repo’s default branch).

When an allowed list is configured, existing agent assignees not in the list are removed while regular user assignees are preserved.

This safe output requires a fine-grained PAT to authenticate the agent assignment operation. The default GITHUB_TOKEN lacks the necessary permissions.

The required token type and permissions depend on whether you own the repository or an organization owns it.

  1. Create the PAT with Repository permissions: Actions, Contents, Issues, Pull requests (all Write).

  2. Add to repository secrets:

    Terminal window
    gh aw secrets set GH_AW_AGENT_TOKEN --value "YOUR_AGENT_PAT"

Alternatively, you can set the magic secret GH_AW_AGENT_TOKEN to a suitable PAT (see the above guide for creating one). This secret name is known to GitHub Agentic Workflows and does not need to be explicitly referenced in your workflow.

Terminal window
gh aw secrets set GH_AW_AGENT_TOKEN --value "<your-pat-token>"
Creating a fine-grained PAT for organization-owned repositories with permissions for agent assignment