Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ For negotiated supported protocol versions `2026-07-28` or newer, the consolidat
- `base_ref`: Git reference (e.g., branch) that the agent will start its work from. If not specified, defaults to the repository's default branch (string, optional)
- `custom_instructions`: Optional custom instructions to guide the agent beyond the issue body. Use this to provide additional context, constraints, or guidance that is not captured in the issue description (string, optional)
- `issue_number`: Issue number (number, required)
- `model`: Copilot cloud agent model ID, for example gpt-6.2-astra (GPT-6.2 Astra), gpt-6.2-sol, or claude-sonnet-5.5. To see which models your plan and organization allow, open the issue on GitHub and select Assignees > Copilot. Omit this field for automatic model selection (string, optional)
- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)

Expand Down
6 changes: 5 additions & 1 deletion pkg/github/__toolsnaps__/assign_copilot_to_issue.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"readOnlyHint": false,
"title": "Assign Copilot to issue"
},
"description": "Assign Copilot to a specific issue in a GitHub repository.\n\nThis tool can help with the following outcomes:\n- a Pull Request created with source code changes to resolve the issue\n\n\nMore information can be found at:\n- https://docs.github.com/en/copilot/concepts/agents/cloud-agent/about-cloud-agent\n",
"description": "Assign Copilot to a specific issue in a GitHub repository.\n\nThis tool can help with the following outcomes:\n- a Pull Request created with source code changes to resolve the issue\n\n\nMore information can be found at:\n- https://docs.github.com/en/copilot/concepts/agents/cloud-agent/about-cloud-agent\n- https://docs.github.com/en/copilot/how-tos/use-copilot-agents/cloud-agent/changing-the-ai-model#supported-models\n",
"icons": [
{
"mimeType": "image/png",
Expand All @@ -31,6 +31,10 @@
"description": "Issue number",
"type": "number"
},
"model": {
"description": "Copilot cloud agent model ID, for example gpt-6.2-astra (GPT-6.2 Astra), gpt-6.2-sol, or claude-sonnet-5.5. To see which models your plan and organization allow, open the issue on GitHub and select Assignees \u003e Copilot. Omit this field for automatic model selection",
"type": "string"
},
"owner": {
"description": "Repository owner",
"type": "string"
Expand Down
22 changes: 19 additions & 3 deletions pkg/github/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
},
referenceLinks: []string{
"https://docs.github.com/en/copilot/concepts/agents/cloud-agent/about-cloud-agent",
"https://docs.github.com/en/copilot/how-tos/use-copilot-agents/cloud-agent/changing-the-ai-model#supported-models",
},
}

Expand Down Expand Up @@ -190,6 +191,14 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
Type: "number",
Description: "Issue number",
},
"model": {
// Les modèles disponibles dépendent du compte et des politiques GitHub.
// Les exemples figurent dans le texte que les clients MCP affichent.
Type: "string",
Description: "Copilot cloud agent model ID, for example gpt-6.2-astra (GPT-6.2 Astra), gpt-6.2-sol, or claude-sonnet-5.5. " +
"To see which models your plan and organization allow, open the issue on GitHub and select Assignees > Copilot. " +
"Omit this field for automatic model selection",
},
"base_ref": {
Type: "string",
Description: "Git reference (e.g., branch) that the agent will start its work from. If not specified, defaults to the repository's default branch",
Expand All @@ -208,6 +217,7 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
Owner string `mapstructure:"owner"`
Repo string `mapstructure:"repo"`
IssueNumber int32 `mapstructure:"issue_number"`
Model string `mapstructure:"model"`
BaseRef string `mapstructure:"base_ref"`
CustomInstructions string `mapstructure:"custom_instructions"`
}
Expand Down Expand Up @@ -326,6 +336,7 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
// Prepare agent assignment input
emptyString := githubv4.String("")
agentAssignment := &AgentAssignmentInput{
Model: githubv4.String(params.Model),
CustomAgent: &emptyString,
CustomInstructions: &emptyString,
TargetRepositoryID: getIssueQuery.Repository.ID,
Expand Down Expand Up @@ -355,9 +366,13 @@ func AssignCopilotToIssue(t translations.TranslationHelperFunc) inventory.Server
} `graphql:"updateIssue(input: $input)"`
}

// Add the GraphQL-Features header for the agent assignment API
// The header will be read by the HTTP transport if it's configured to do so
ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, "issues_copilot_assignment_api_support")
// GitHub expose le champ model avec cet en-tête seul. Les appels sans
// modèle conservent leur en-tête historique.
feature := "issues_copilot_assignment_api_support"
if params.Model != "" {
feature = "coding_agent_model_selection"
}
ctxWithFeatures := ghcontext.WithGraphQLFeatures(ctx, feature)

// Capture the time before assignment to filter out older PRs during polling
assignmentTime := time.Now().UTC()
Expand Down Expand Up @@ -876,6 +891,7 @@ type AgentAssignmentInput struct {
BaseRef *githubv4.String `json:"baseRef,omitempty"`
CustomAgent *githubv4.String `json:"customAgent,omitempty"`
CustomInstructions *githubv4.String `json:"customInstructions,omitempty"`
Model githubv4.String `json:"model,omitempty"`
TargetRepositoryID githubv4.ID `json:"targetRepositoryId"`
}

Expand Down
79 changes: 79 additions & 0 deletions pkg/github/copilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"github.com/github/github-mcp-server/v2/internal/githubv4mock"
"github.com/github/github-mcp-server/v2/internal/toolsnaps"
"github.com/github/github-mcp-server/v2/pkg/http/headers"
"github.com/github/github-mcp-server/v2/pkg/http/transport"
"github.com/github/github-mcp-server/v2/pkg/translations"
"github.com/google/go-github/v92/github"
"github.com/google/jsonschema-go/jsonschema"
Expand Down Expand Up @@ -883,6 +885,83 @@ func TestAssignCopilotToIssue(t *testing.T) {
}
}

// Un modèle vide ou omis doit conserver la mutation historique, y compris son
// en-tête. Le test vérifie le JSON reçu par GitHub indépendamment des types Go.
func TestAssignCopilotToIssueModel(t *testing.T) {
t.Parallel()

tool := AssignCopilotToIssue(translations.NullTranslationHelper)
for _, tc := range []struct {
name string
model *string
}{
{name: "omitted"},
{name: "empty", model: new("")},
{name: "selected", model: new("example-model")},
} {
t.Run(tc.name, func(t *testing.T) {
args := map[string]any{
"owner": "owner",
"repo": "repo",
"issue_number": 7,
"base_ref": "release",
"custom_instructions": "Follow the release guidelines.",
}
if tc.model != nil {
args["model"] = *tc.model
}

mutations := 0
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var payload struct {
Query string
Variables struct {
Input struct {
AgentAssignment map[string]any
}
}
}
require.NoError(t, json.NewDecoder(r.Body).Decode(&payload))
features := r.Header.Get(headers.GraphQLFeaturesHeader)
switch {
case strings.Contains(payload.Query, "suggestedActors"):
assert.Empty(t, features)
_, _ = w.Write([]byte(`{"data":{"repository":{"suggestedActors":{"nodes":[{"id":"BOT","login":"copilot-swe-agent","__typename":"Bot"}]}}}}`))
case strings.Contains(payload.Query, "issue(number:"):
assert.Empty(t, features)
_, _ = w.Write([]byte(`{"data":{"repository":{"id":"REPO","issue":{"id":"ISSUE","assignees":{"nodes":[]}}}}}`))
case strings.Contains(payload.Query, "updateIssue(input:"):
mutations++
wantAssignment := map[string]any{
"baseRef": "release",
"customAgent": "",
"customInstructions": "Follow the release guidelines.",
"targetRepositoryId": "REPO",
}
wantFeature := "issues_copilot_assignment_api_support"
if tc.model != nil && *tc.model != "" {
wantAssignment["model"] = *tc.model
wantFeature = "coding_agent_model_selection"
}
assert.Equal(t, wantAssignment, payload.Variables.Input.AgentAssignment)
assert.Equal(t, wantFeature, features)
_, _ = w.Write([]byte(`{"data":{"updateIssue":{"issue":{"id":"ISSUE","number":7,"url":"https://github.com/owner/repo/issues/7"}}}}`))
default:
t.Fatalf("unexpected GraphQL operation: %s", payload.Query)
}
})
client := &http.Client{Transport: &transport.GraphQLFeaturesTransport{Transport: recorderTransport{handler: handler}}}
deps := BaseDeps{GQLClient: githubv4.NewClient(client)}
ctx := ContextWithPollConfig(ContextWithDeps(t.Context(), deps), PollConfig{MaxAttempts: 0})
request := createMCPRequest(args)
result, err := tool.Handler(deps)(ctx, &request)
require.NoError(t, err)
require.False(t, result.IsError, "%v", result.Content)
assert.Equal(t, 1, mutations)
})
}
}

func Test_RequestCopilotReview(t *testing.T) {
t.Parallel()

Expand Down
15 changes: 8 additions & 7 deletions pkg/github/typed_copilot_ui_outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ func normalizeAssignCopilotToIssueArguments(raw json.RawMessage) (json.RawMessag
if err := mapstructure.WeakDecode(args, &input); err != nil {
return nil, &inventory.ToolInputError{Message: err.Error()}
}
return json.Marshal(map[string]any{
"owner": input.Owner,
"repo": input.Repo,
"issue_number": input.IssueNumber,
"base_ref": input.BaseRef,
"custom_instructions": input.CustomInstructions,
})
// Seuls les anciens paramètres nécessitent une conversion de compatibilité.
// Les options de lancement gardent leur type pour la validation par le SDK.
args["owner"] = input.Owner
args["repo"] = input.Repo
args["issue_number"] = input.IssueNumber
args["base_ref"] = input.BaseRef
args["custom_instructions"] = input.CustomInstructions
return json.Marshal(args)
}

func normalizeAssignCopilotToIssueWithIntentArguments(raw json.RawMessage) (json.RawMessage, error) {
Expand Down
7 changes: 4 additions & 3 deletions pkg/skills/catalog/skills/copilot-task-delegation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ reproduced. Say which of these applies rather than delegating and hoping.
Two tools do this, and the difference is whether the choice is recorded.

- `assign_copilot_to_issue` launches directly. Correct when someone has explicitly asked
for this issue to be delegated.
- `assign_copilot_to_issue_with_intent` is preferred where it is available, because it
carries `rationale` and `confidence` alongside the assignment, and because
for this issue to be delegated. If they specify a model for that launch, use this
tool and pass its identifier in `model`. Omit it to let Copilot choose.
- For other assignments, prefer `assign_copilot_to_issue_with_intent` where available. It
carries `rationale` and `confidence` alongside the assignment, and
`is_suggestion` lets you record the intent without launching anything. Use
`is_suggestion` set to true whenever you are proposing a candidate rather than acting
on an instruction — it is the honest form of "this one looks suitable".
Expand Down