github/github-mcp-server · error
failed to update issue with agent assignment: %w
Error message
failed to update issue with agent assignment: %w
What it means
The GraphQL updateIssue mutation carrying AssigneeIDs (the copilot-swe-agent bot) and the AgentAssignment input failed during assign_copilot_to_issue. The mutation runs on a context tagged with the issues_copilot_assignment_api_support feature so GitHub can gate the private AgentAssignment field; GitHub rejects it when the feature is unavailable, Copilot is not enabled, or the token lacks permission. This is a server-side rejection of the assignment, after the suggested-actor lookup already succeeded.
Source
Thrown at pkg/github/copilot.go:360
// Add the GraphQL-Features header for the agent assignment API
// The header will be read by the HTTP transport if it's configured to do so
ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issues_copilot_assignment_api_support")
// Capture the time before assignment to filter out older PRs during polling
assignmentTime := time.Now().UTC()
if err := client.Mutate(
ctxWithFeatures,
&updateIssueMutation,
UpdateIssueInput{
ID: getIssueQuery.Repository.Issue.ID,
AssigneeIDs: actorIDs,
AgentAssignment: agentAssignment,
},
nil,
); err != nil {
return nil, nil, fmt.Errorf("failed to update issue with agent assignment: %w", err)
}
// Poll for a linked PR created by Copilot after the assignment
pollConfig := getPollConfig(ctx)
// Get progress token from request for sending progress notifications
progressToken := request.Params.GetProgressToken()
// Send initial progress notification that assignment succeeded and polling is starting
if progressToken != nil && request.Session != nil && pollConfig.MaxAttempts > 0 {
_ = request.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{
ProgressToken: progressToken,
Progress: 0,
Total: float64(pollConfig.MaxAttempts),
Message: "Copilot assigned to issue, waiting for PR creation...",
})
}
View on GitHub (pinned to 0ea1f775a7)
Solutions
- Enable the Copilot coding agent for the repository/org (docs.github.com Copilot cloud-agent) and retry
- Use a PAT or GitHub App token with write access to issues in that repository
- Check the wrapped GraphQL error message for FORBIDDEN/NOT_FOUND to distinguish permissions from feature unavailability
- Verify the issue is open and the repo is not archived, then retry
Example fix
// before
if err := client.Mutate(ctxWithFeatures, &updateIssueMutation, input, nil); err != nil {
return nil, nil, fmt.Errorf("failed to update issue with agent assignment: %w", err)
}
// after — classify the GraphQL rejection for the caller
if err := client.Mutate(ctxWithFeatures, &updateIssueMutation, input, nil); err != nil {
msg := err.Error()
if strings.Contains(msg, "FORBIDDEN") {
return utils.NewToolResultError("copilot assignment denied: enable the Copilot coding agent and use a token with issue write access"), nil, nil
}
return nil, nil, fmt.Errorf("failed to update issue with agent assignment: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: confirm Copilot agent availability before assigning
copilotActor, err := findCopilotSuggestedActor(ctx, client, owner, repo)
if err != nil {
return err // suggested-actors query itself failed
}
if copilotActor == nil {
return errors.New("copilot is not available as an assignee for this repo — enable the Copilot coding agent first")
} Try / catch
if err := client.Mutate(ctxWithFeatures, &updateIssueMutation, input, nil); err != nil {
msg := err.Error()
switch {
case strings.Contains(msg, "FORBIDDEN"):
// permissions/Copilot disabled — surface actionable guidance, no retry
case strings.Contains(msg, "NOT_FOUND"):
// stale issue/repo — refetch and optionally retry once
default:
return fmt.Errorf("failed to update issue with agent assignment: %w", err)
}
} Prevention
- Enable the Copilot coding agent org-wide before building automation around assignment
- Use tokens with issue write permission for assignment workflows
- Check suggested actors first — the code already degrades gracefully when copilot is absent
- Keep GitHub App permissions (issues:write) in sync when the assignment feature rolls out
When it happens
Trigger: Calling assign_copilot_to_issue on a repo/org where the Copilot coding agent (cloud agent) is disabled, with a token lacking write/issue-assign permission, on a GitHub instance whose schema does not accept the AgentAssignment input (feature flag not honored), or when the issue cannot accept agent assignment (locked, archived repo).
Common situations: Org policy disabling Copilot coding agent, fine-grained PAT without Issues:write, GHES version predating agent assignment API, race where the issue was closed between lookup and mutation.
Related errors
- failed to get GitHub client: %w
- failed to get issue ID: %w
- perPage value %d exceeds maximum of 100
- perPage value %d cannot be negative
- mutation_unconfirmed
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/5d56b437096708ea.
Report an issue: GitHub.