Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

Summary

Enhances the assign_copilot_to_issue tool to automatically poll for the PR created by the Copilot coding agent after assignment, similar to how the remote server's sweagentd service 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_status separately. 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

  • Added findLinkedCopilotPR() function to query issue timeline for CrossReferencedEvent items from PRs authored by copilot-swe-agent
  • Added polling loop (9 attempts, 1s delay) matching remote server's observed p90 latency (~7s)
  • Enhanced JSON response to include PR details when found, or helpful instructions otherwise
  • Added PollConfig struct with ContextWithPollConfig() for test configurability (allows disabling polling in tests)
  • Added GraphQLFeaturesTransport for GraphQL feature flag header support

Response 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

  • Tool schema or behavior changed

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

  • No security or limits impact

Polling is bounded (max 9 attempts) and uses standard GitHub GraphQL API.

Tool renaming

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed (schema unchanged, behavior enhanced)

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
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner January 14, 2026 12:51
Copilot AI review requested due to automatic review settings January 14, 2026 12:51
Copy link
Contributor

Copilot AI left a 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 PollConfig and context helpers for test configurability
  • Implements findLinkedCopilotPR() to query issue timeline for PRs from copilot-swe-agent bot
  • Changes response format from plain text to JSON with PR details or helpful instructions
  • Adds GraphQLFeaturesTransport for 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.
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