Skip to content

feat: update assign-to-agent to use REST API instead of GraphQL#5898

Merged
mrjf merged 1 commit intomainfrom
rest-api-assign-agent
Dec 8, 2025
Merged

feat: update assign-to-agent to use REST API instead of GraphQL#5898
mrjf merged 1 commit intomainfrom
rest-api-assign-agent

Conversation

@mrjf
Copy link
Contributor

@mrjf mrjf commented Dec 8, 2025

Summary

Updates the assign-to-agent safe output to use the new REST API for assigning the Copilot coding agent to issues, as announced in the GitHub December 2025 changelog.

Key Changes

JavaScript Implementation

  • assign_agent_helpers.cjs: Added new assignAgentToIssueRest() function using github.rest.issues.addAssignees() REST endpoint
  • assign_agent_helpers.cjs: Added isAgentAssigned() to check assignment status via REST API
  • assign_agent_helpers.cjs: Updated assignAgentToIssueByName() to try REST API first with GraphQL fallback
  • assign_to_agent.cjs: Simplified to use REST API directly, removed GraphQL-specific code
  • GraphQL methods marked as deprecated but kept for backwards compatibility

Go Changes

  • assign_to_agent.go: Reduced permissions from NewPermissionsActionsWriteContentsWriteIssuesWritePRWrite() to NewPermissionsContentsReadIssuesWrite()

Documentation

  • Updated safe-outputs.md with REST API details and simplified token requirements
  • Updated test workflow with new permissions and documentation

Tests

  • Added 9 new tests for assignAgentToIssueRest() function
  • Added 5 new tests for isAgentAssigned() function
  • Updated existing tests for REST API flow
  • All 37 assign agent tests pass

Benefits

Before (GraphQL) After (REST API)
4 write permissions required Only issues: write needed
Multiple GraphQL queries Single REST API call
Complex agent ID lookup Direct login name usage
Limited error context HTTP status-specific errors

REST API Endpoint Used

POST /repos/{owner}/{repo}/issues/{issue_number}/assignees
{
  "assignees": ["copilot-swe-agent"]
}

Reference

Updates the assign-to-agent safe output to use the new REST API for
assigning Copilot coding agent to issues, as announced in the GitHub
December 2025 changelog.

Key changes:
- Add assignAgentToIssueRest() using github.rest.issues.addAssignees()
- Add isAgentAssigned() to check assignment status via REST
- Use REST API first with GraphQL fallback for compatibility
- Reduce permissions from 4 write permissions to just issues: write
- Add comprehensive tests for new REST API functions (37 tests pass)
- Update documentation with REST API details and simplified requirements

Reference: https://github.blog/changelog/2025-12-03-assign-issues-to-copilot-using-the-api/
@mrjf
Copy link
Contributor Author

mrjf commented Dec 8, 2025

@copilot Please find out why this dev.md run failed: https://github.com/githubnext/gh-aw/actions/runs/20039762441

Copy link
Contributor

Copilot AI commented Dec 8, 2025

@mrjf I've opened a new pull request, #5899, to work on those changes. Once the pull request is ready, I'll request review from you.

@mrjf mrjf merged commit 52fc933 into main Dec 8, 2025
66 of 68 checks passed
@mrjf mrjf deleted the rest-api-assign-agent branch December 8, 2025 19:47
@mrjf mrjf restored the rest-api-assign-agent branch December 8, 2025 19:59
@mrjf
Copy link
Contributor Author

mrjf commented Dec 8, 2025

What! I didn't merge this!

@pelikhan pelikhan deleted the rest-api-assign-agent branch December 15, 2025 04:50
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.

2 participants