-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: poll for linked PR after assigning Copilot to issue #1810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Enhances the assign_copilot_to_issue tool to automatically poll for the PR created by the Copilot coding agent after assignment. Changes: - Add findLinkedCopilotPR() to query issue timeline for CrossReferencedEvent items from PRs authored by copilot-swe-agent - Add polling loop (9 attempts, 1s delay) matching remote server latency - Return structured JSON with PR details when found, or helpful note otherwise - Add PollConfig for configurable polling (used in tests to disable) - Add GraphQLFeaturesTransport for feature flag header support The returned response now includes: - issue_number, issue_url, owner, repo - pull_request object (if found during polling) - Note with instructions to use get_copilot_job_status if PR not yet created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the assign_copilot_to_issue tool to automatically poll for PRs created by Copilot after issue assignment, providing immediate feedback similar to the remote server's behavior. It introduces polling logic that attempts to find linked PRs up to 9 times with 1-second delays, and changes the response format from plain text to structured JSON.
Changes:
- Adds polling infrastructure with
PollConfigand context helpers for test configurability - Implements
findLinkedCopilotPR()to query issue timeline for PRs fromcopilot-swe-agentbot - Changes response format from plain text to JSON with PR details or helpful instructions
- Adds
GraphQLFeaturesTransportfor reusable GraphQL feature flag header support
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/github/transport.go | Adds new GraphQLFeaturesTransport type for adding GraphQL-Features headers to requests |
| pkg/github/transport_test.go | Comprehensive tests for GraphQLFeaturesTransport behavior including edge cases |
| pkg/github/issues.go | Implements polling logic, timeline query function, and JSON response format |
| pkg/github/issues_test.go | Updates tests to disable polling and verify new JSON response structure |
When polling for a linked PR after assigning Copilot to an issue, we now capture the assignment time before the mutation and filter to only return PRs created after that time. This prevents the tool from incorrectly returning old PRs from previous Copilot assignments.
- Document GraphQLFeaturesTransport is for library consumers - Convert githubv4.Int/String to native Go types in result map - Remove misleading log comment since tool handlers lack logger access
Replace inline GraphQL-Features header logic in bearerAuthTransport with the exported GraphQLFeaturesTransport. This removes code duplication and ensures the transport is actually used, not just exported.
Summary
Enhances the
assign_copilot_to_issuetool to automatically poll for the PR created by the Copilot coding agent after assignment, similar to how the remote server'ssweagentdservice handles job status polling.Why
After assigning Copilot to an issue, users currently have to manually look up the linked PR or use
get_copilot_job_statusseparately. This enhancement provides immediate feedback by polling for the PR and including it in the response.Related to issue tracking for issue assignment improvements.
What changed
findLinkedCopilotPR()function to query issue timeline forCrossReferencedEventitems from PRs authored bycopilot-swe-agentPollConfigstruct withContextWithPollConfig()for test configurability (allows disabling polling in tests)GraphQLFeaturesTransportfor GraphQL feature flag header supportResponse format
When PR is found during polling:
{ "message": "successfully assigned copilot to issue - pull request created", "issue_number": 123, "issue_url": "https://github.com/owner/repo/issues/123", "owner": "owner", "repo": "repo", "pull_request": { "number": 456, "url": "https://github.com/owner/repo/pull/456", "title": "...", "state": "OPEN" } }When PR is not yet created:
{ "message": "successfully assigned copilot to issue - pull request pending", "issue_number": 123, "issue_url": "https://github.com/owner/repo/issues/123", "owner": "owner", "repo": "repo", "note": "The pull request may still be in progress. Use get_copilot_job_status with the pull request number once created, or check the issue timeline for updates." }MCP impact
The tool now returns structured JSON instead of a simple string message, with additional PR information when available.
Prompts tested (tool changes only)
Security / limits
Polling is bounded (max 9 attempts) and uses standard GitHub GraphQL API.
Tool renaming
Lint & tests
./script/lint./script/testDocs