Skip to content

fix: correct assign-to-agent GraphQL mutations per official docs#39941

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-assign-to-agent-js
Jun 18, 2026
Merged

fix: correct assign-to-agent GraphQL mutations per official docs#39941
pelikhan merged 4 commits into
mainfrom
copilot/fix-assign-to-agent-js

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Copilot fails to start on assigned issues because the assign_agent_helpers.cjs GraphQL queries diverged from the official API spec.

Bugs fixed

  • capabilities list notationsuggestedActors was passed capabilities: CAN_BE_ASSIGNED (scalar) in both getAvailableAgentLogins and findAgent; the field is a list type and requires capabilities: [CAN_BE_ASSIGNED]

  • Fallback mutation missing agentAssignment — when replaceActorsForAssignable is forbidden and the code falls back to addAssigneesToAssignable, the agentAssignment block was omitted entirely. Without it Copilot is added as an assignee but receives no task context, producing the "unable to start working" error. The fallback now conditionally builds agentAssignment identically to the primary mutation using the parameters already in scope.

# Before (fallback)
addAssigneesToAssignable(input: { assignableId: $assignableId, assigneeIds: $assigneeIds })

# After (fallback) — mirrors primary mutation
addAssigneesToAssignable(input: {
  assignableId: $assignableId,
  assigneeIds: $assigneeIds,
  agentAssignment: { targetRepositoryId: $targetRepoId, baseRef: $baseRef, model: $model, ... }
})

Test fixes

11 test mocks were returning { addAssigneesToAssignable: ... } as the primary mutation response. Since the primary mutation is replaceActorsForAssignable, response?.replaceActorsForAssignable?.__typename silently returned undefined — the success path was never exercised. Updated to { replaceActorsForAssignable: { __typename: "ReplaceActorsForAssignablePayload" } }.

Copilot AI and others added 3 commits June 18, 2026 01:04
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Use array notation `[CAN_BE_ASSIGNED]` for `capabilities` param
  in both `getAvailableAgentLogins` and `findAgent` queries
- Add `agentAssignment` to fallback `addAssigneesToAssignable`
  mutation so agent task context is included when primary mutation
  is forbidden
- Update stale test mocks from `addAssigneesToAssignable` to
  `replaceActorsForAssignable` (the actual primary mutation)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title fix: correct assign-to-agent GraphQL per official docs fix: correct assign-to-agent GraphQL mutations per official docs Jun 18, 2026
Copilot AI requested a review from pelikhan June 18, 2026 01:18
@pelikhan pelikhan marked this pull request as ready for review June 18, 2026 01:35
Copilot AI review requested due to automatic review settings June 18, 2026 01:35

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 pull request fixes GitHub Copilot “assign to agent” GraphQL usage in the setup action so assignments succeed against the official API schema and so the fallback mutation supplies agentAssignment context needed for the agent to start.

Changes:

  • Fix suggestedActors GraphQL argument type by passing capabilities: [CAN_BE_ASSIGNED] (list) instead of a scalar.
  • Update the forbidden/permission fallback path (addAssigneesToAssignable) to optionally include an agentAssignment block mirroring the primary mutation’s parameters.
  • Correct test mocks so the success path is exercised by returning replaceActorsForAssignable.__typename.
Show a summary per file
File Description
actions/setup/js/assign_to_agent.test.cjs Updates GraphQL mock responses to match the primary replaceActorsForAssignable mutation shape.
actions/setup/js/assign_agent_helpers.cjs Aligns GraphQL queries/mutations with the documented schema; adds agentAssignment to the fallback mutation when applicable.
actions/setup-cli/install.sh Updates a header comment (but currently makes it self-referential; see review comment).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread actions/setup-cli/install.sh Outdated
set +o histexpand

# Kept in sync with install-gh-aw.sh — edit that file, then copy to this path.
# Kept in sync with actions/setup-cli/install.sh — edit this file, then copy to that path.
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

…-agent-js

# Conflicts:
#	actions/setup-cli/install.sh

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and recompile

Done — merged main and recompiled. Resolved a single conflict in actions/setup-cli/install.sh (the sync comment now correctly points to install-gh-aw.sh as the source file). No workflow lock files changed.

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.

3 participants