pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/github/copilot-sdk-java/commit/f05445eceb0033e180d0c43f820bc3ddfa1529a2

tps://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> Refactor issue creation to use GitHub CLI and assign to Copilot Codin… · github/copilot-sdk-java@f05445e · GitHub
Skip to content
This repository was archived by the owner on Jun 17, 2026. It is now read-only.

Commit f05445e

Browse files
committed
Refactor issue creation to use GitHub CLI and assign to Copilot Coding Agent with dynamic agent assignment
1 parent 285a36a commit f05445e

2 files changed

Lines changed: 71 additions & 21 deletions

File tree

.github/scripts/create-issue-assigned-to-copilot.ts

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
44
const GITHUB_REPO_OWNER = process.env.GITHUB_REPO_OWNER;
55
const GITHUB_REPO_NAME = process.env.GITHUB_REPO_NAME;
66

7-
// Known Copilot Coding Agent bot identity
8-
const COPILOT_BOT_LOGIN = 'Copilot';
9-
const COPILOT_BOT_NODE_ID = 'BOT_kgDOC9w8XQ';
7+
const GRAPHQL_FEATURES_HEADER = 'issues_copilot_assignment_api_support,coding_agent_model_selection';
108

119
/**
12-
* Creates a GitHub issue and assigns it to the Copilot Coding Agent (@Copilot).
13-
* Uses GraphQL to create the issue with the bot's known node ID as assignee.
10+
* Creates a GitHub issue and assigns it to the Copilot Coding Agent.
11+
* Follows the official GitHub API docs:
12+
* 1. Query suggestedActors to find copilot-swe-agent and get its node ID
13+
* 2. Get the repository node ID
14+
* 3. Create issue with assigneeIds + agentAssignment, including required GraphQL-Features header
1415
* Returns the issue URL on success, null on failure.
1516
*/
1617
export async function createIssueWithCopilot(description: string): Promise<string | null> {
@@ -25,10 +26,20 @@ export async function createIssueWithCopilot(description: string): Promise<strin
2526
const octokit = new Octokit({ auth: GITHUB_TOKEN });
2627

2728
try {
28-
// Fetch repo node ID
29+
// Step 1: Fetch repo ID and find copilot-swe-agent in suggestedActors
2930
const repoInfo: any = await octokit.graphql(`
3031
query($owner: String!, $name: String!) {
31-
repository(owner: $owner, name: $name) { id }
32+
repository(owner: $owner, name: $name) {
33+
id
34+
suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
35+
nodes {
36+
login
37+
__typename
38+
... on Bot { id }
39+
... on User { id }
40+
}
41+
}
42+
}
3243
}
3344
`, {
3445
owner: GITHUB_REPO_OWNER,
@@ -37,15 +48,39 @@ export async function createIssueWithCopilot(description: string): Promise<strin
3748

3849
const repoId = repoInfo?.repository?.id;
3950
if (!repoId) {
51+
console.error('Could not fetch repository ID');
52+
return null;
53+
}
54+
55+
const copilotBot = repoInfo.repository.suggestedActors.nodes.find(
56+
(node: any) => node.login === 'copilot-swe-agent'
57+
);
58+
59+
if (!copilotBot) {
60+
console.error('copilot-swe-agent not found in suggestedActors. Is Copilot coding agent enabled for this repo?');
4061
return null;
4162
}
4263

64+
console.log(`Found Copilot bot: login=${copilotBot.login}, id=${copilotBot.id}, type=${copilotBot.__typename}`);
65+
4366
const title = description.split('\n')[0].slice(0, 100);
4467

45-
// Create issue with Copilot bot assigned via known node ID
68+
// Step 2: Create issue with agentAssignment and required GraphQL-Features header
4669
const response: any = await octokit.graphql(`
4770
mutation($repoId: ID!, $title: String!, $body: String!, $assigneeIds: [ID!]) {
48-
createIssue(input: { repositoryId: $repoId, title: $title, body: $body, assigneeIds: $assigneeIds }) {
71+
createIssue(input: {
72+
repositoryId: $repoId,
73+
title: $title,
74+
body: $body,
75+
assigneeIds: $assigneeIds,
76+
agentAssignment: {
77+
targetRepositoryId: $repoId,
78+
baseRef: "main",
79+
customInstructions: "",
80+
customAgent: "",
81+
model: ""
82+
}
83+
}) {
4984
issue {
5085
number
5186
title
@@ -58,7 +93,10 @@ export async function createIssueWithCopilot(description: string): Promise<strin
5893
repoId,
5994
title,
6095
body: description,
61-
assigneeIds: [COPILOT_BOT_NODE_ID],
96+
assigneeIds: [copilotBot.id],
97+
headers: {
98+
'GraphQL-Features': GRAPHQL_FEATURES_HEADER,
99+
},
62100
});
63101

64102
const issue = response?.createIssue?.issue;

.github/workflows/copilot-issue.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,29 @@ jobs:
2020
issues: write
2121
steps:
2222
- name: Create issue and assign to Copilot
23-
uses: actions/github-script@v8
24-
with:
25-
script: |
26-
const title = '${{ inputs.title || 'Investigation needed from Copilot Coding Agent' }}';
27-
const issue = await github.rest.issues.create({
28-
owner: context.repo.owner,
29-
repo: context.repo.repo,
30-
title,
31-
assignees: ['Copilot']
32-
});
33-
core.notice(`Created issue #${issue.data.number}: ${issue.data.html_url}`);
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
TITLE="${{ inputs.title || 'Investigation needed from Copilot Coding Agent' }}"
27+
gh api \
28+
--method POST \
29+
-H "Accept: application/vnd.github+json" \
30+
-H "X-GitHub-Api-Version: 2022-11-28" \
31+
/repos/${{ github.repository }}/issues \
32+
--input - <<< "$(jq -n \
33+
--arg title "$TITLE" \
34+
--arg repo "${{ github.repository }}" \
35+
'{
36+
title: $title,
37+
assignees: ["copilot-swe-agent[bot]"],
38+
agent_assignment: {
39+
target_repo: $repo,
40+
base_branch: "main",
41+
custom_instructions: "",
42+
custom_agent: "",
43+
model: ""
44+
}
45+
}')"
3446
3547
create-issue-graphql:
3648
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy