-
Notifications
You must be signed in to change notification settings - Fork 36
Add branch parameter to assign-to-agent safe output type #10607
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
Conversation
- Add optional 'branch' field to AssignToAgentItem TypeScript interface - Add DefaultBranch field to AssignToAgentConfig struct - Update safe_outputs_tools.json to document branch parameter - Update assign_to_agent.cjs to handle branch parameter: - Extract branch from item or use default branch - Add comment to issue with branch information when branch is specified - Include branch in summary and staged preview - Update Issue Monster workflow to instruct agent to extract base branch from issue body - Build and format successful, unit tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add test for branch parameter handling in agent output - Verify branch comment is created when branch is specified - Verify branch is included in summary output - All tests passing (22 passed, 2 skipped) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
actions/setup/js/assign_to_agent.cjs
Outdated
| // Assign agent using GraphQL mutation - uses built-in github object authenticated via github-token | ||
| // Pass the allowed list so existing assignees are filtered before calling replaceActorsForAssignable | ||
| core.info(`Assigning ${agentName} coding agent to ${type} #${number}...`); | ||
| const success = await assignAgentToIssue(assignableId, agentId, currentAssignees, agentName, allowedAgents); |
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.
@copilot this function API call must take the branch and apply it in the API call.
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.
Fixed in 3ec5193. When a branch is specified, the handler now calls gh agent-task create #<issue_number> --base <branch> which properly passes the branch parameter to the agent task creation API. Falls back to standard GraphQL assignment if the CLI command fails.
When a branch is specified for assign-to-agent, now uses the gh CLI 'agent-task create' command with the --base flag instead of just assigning via GraphQL (which doesn't support branch specification). This properly passes the branch information to the agent task creation API, ensuring the agent creates PRs based on the correct branch. - Modified assign_to_agent.cjs to call 'gh agent-task create #<issue> --base <branch>' - Falls back to standard GraphQL assignment if gh CLI fails - Updated tests to mock exec.getExecOutput and verify correct CLI invocation - All tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot review the agent-task source to discover how to update the graphql calls |
After reviewing gh CLI source code (pkg/cmd/agent-task/capi/job.go), discovered that agent tasks use a REST API endpoint, not GraphQL. Changed implementation to call the Copilot API directly: - POST https://api.github.com/agents/swe/v1/jobs/{owner}/{repo} - Payload includes pull_request.base_ref: "refs/heads/{branch}" - This matches how gh CLI implements branch support Benefits over gh CLI execution: - Direct API call is more reliable and efficient - Better error handling and integration with existing code - No dependency on gh CLI being installed/configured Updated tests to mock github.request() instead of exec.getExecOutput() All tests passing (22 passed, 2 skipped) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Reviewed gh CLI source code and discovered the solution in 248e31e. The The implementation now calls {
"pull_request": {
"base_ref": "refs/heads/{branch}"
}
}This matches how gh CLI implements it in |
The
assign-to-agentsafe output type now supports an optionalbranchparameter to specify the base branch for agent work.Changes
branch?: stringfield toAssignToAgentIteminterface and MCP tools schemaDefaultBranchfield toAssignToAgentConfigfor YAML frontmatter configurationassign_to_agent.cjsto:POST https://api.github.com/agents/swe/v1/jobs/{owner}/{repo}) withpull_request.base_refparameterImplementation Details
After reviewing the gh CLI source code (
pkg/cmd/agent-task/capi/job.go), discovered that agent task creation uses the Copilot REST API endpoint rather than GraphQL. The implementation now makes a direct REST API call, which is more reliable than shelling out to theghCLI and provides better integration with the existing codebase.Usage
When a branch is specified for an issue, the handler calls the Copilot API with the payload:
{ "problem_statement": "Work on issue #123", "event_type": "gh_cli", "pull_request": { "base_ref": "refs/heads/develop" } }This ensures the agent task is created with the correct base branch, and PRs are created from the specified branch.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.