Skip to content

Add pull-request-repo parameter to assign-to-agent for cross-repository PR creation#16293

Merged
pelikhan merged 7 commits intomainfrom
copilot/add-assign-to-agent-repo-selection
Feb 17, 2026
Merged

Add pull-request-repo parameter to assign-to-agent for cross-repository PR creation#16293
pelikhan merged 7 commits intomainfrom
copilot/add-assign-to-agent-repo-selection

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

The assign-to-agent safe output now supports specifying where pull requests should be created via the pull-request-repo parameter, enabling issue tracking in one repository while code lives in another.

Changes

Configuration

  • Added pull-request-repo and allowed-pull-request-repos to assign-to-agent frontmatter
  • target-repo: where the issue lives (existing)
  • pull-request-repo: where the PR should be created (new, automatically allowed)
  • allowed-pull-request-repos: additional repositories beyond pull-request-repo

Implementation

  • GraphQL mutation now includes agentAssignment.targetRepositoryId when pull-request-repo is configured
  • Supports both global configuration and per-item pull_request_repo parameter in agent output
  • Cross-repo validation follows target-repo/allowed-repos pattern where pull-request-repo is automatically allowed
  • allowed-pull-request-repos contains additional repositories beyond the primary pull-request-repo

Specification

  • Updated scratchpad/safe-outputs-specification.md with formal requirements for pull-request-repo pattern
  • Added cross-repository validation section (3.4.5) with auto-allow requirements
  • Added cross-repository support pattern (6.2.1)
  • Added example A.3 demonstrating cross-repository agent assignment

Example

Frontmatter configuration:

safe-outputs:
  assign-to-agent:
    target-repo: "org/issues-repo"
    pull-request-repo: "org/code-repo"  # automatically allowed
    allowed-pull-request-repos: ["org/another-code-repo"]  # additional repos

Agent output:

assign_to_agent(
    issue_number=123,
    pull_request_repo="org/specific-code-repo"
)

Validation Pattern:
The implementation follows the established target-repo/allowed-repos pattern:

  • The repository specified by pull-request-repo is automatically allowed without needing to be listed in allowed-pull-request-repos
  • allowed-pull-request-repos specifies additional repositories where PRs can be created
  • Per-item pull_request_repo values are validated against: global pull-request-repo (default) + allowed-pull-request-repos (additional)

Uses GitHub's native agentAssignment.targetRepositoryId GraphQL parameter, matching UI behavior for cross-repository assignments.

Original prompt

This section details on the original issue you should resolve

<issue_title>Allow assign-to-agent safe output to select the repo that the PR should be created in</issue_title>
<issue_description>Our issues are located in a different repository than our codebases.

Assigning an issue to Copilot and selecting the target repository is available through the GitHub UI (see https://github.com/orgs/community/discussions/173575)

But that doesn't seem to be supported when assigning an issue to Copilot using the agentic workflow: https://github.github.com/gh-aw/reference/safe-outputs/#assign-to-agent-assign-to-agent

The assign-to-agent safe output has a target-repo param, but that seems to be the repo where the issue lives, not the repo where we want to open the pull request in.

Am I missing something or is this a missing feature that might be implemented in the future?</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 17, 2026 06:08
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add selection for target repository in assign-to-agent output Add pr-repo parameter to assign-to-agent for cross-repository PR creation Feb 17, 2026
Copilot AI requested a review from pelikhan February 17, 2026 06:16
@pelikhan
Copy link
Contributor

@copilot rename "pr" to "pull-request" in the field names

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot rename "pr" to "pull-request" in the field names

Done in commit f4ce8eb. Renamed all field names:

  • pr-repopull-request-repo
  • allowed-pr-reposallowed-pull-request-repos
  • pr_repopull_request_repo (in agent output)
  • Updated all related Go/JavaScript variables and environment variables

All tests passing.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add pr-repo parameter to assign-to-agent for cross-repository PR creation Add pull-request-repo parameter to assign-to-agent for cross-repository PR creation Feb 17, 2026
@pelikhan
Copy link
Contributor

@copilot review again the changes

Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot review again the changes

Code review complete. Implementation is production-ready:

Backend (Go): Proper struct fields with YAML tags, environment variable generation
Frontend (JavaScript): GraphQL mutation with agentAssignment.targetRepositoryId, cross-repo validation
Schema: JSON schema and MCP tool schema updated
Tests: 31 passing, covers global and per-item configurations
Documentation: Comprehensive with examples
Naming: Consistent "pull-request" throughout all layers
Security: E004 validation with allowlist

The implementation correctly uses GitHub's native agentAssignment API parameter matching the UI behavior documented at https://github.com/orgs/community/discussions/173575

All files committed in f4ce8eb (latest commit).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan
Copy link
Contributor

@copilot update safe output spec

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot update safe output spec

Updated safe outputs specification in commit 9d6f683:

Section 3.4.5 (Cross-Repository Validation):

  • Added requirements for pull-request-repo parameter validation
  • Documented separation between target-repo and pull-request-repo
  • Specified E004 error code for unauthorized repos

Section 6.2.1 (Cross-Repository Support):

  • Documented optional pull-request-repo and allowed-pull-request-repos pattern
  • Referenced GraphQL agentAssignment.targetRepositoryId usage

Appendix A.3 (New Example):

  • Added complete example showing cross-repository agent assignment
  • Shows issue in one repo, PR created in another repo

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login ignore-path ../../../.prettierignore (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan pelikhan marked this pull request as ready for review February 17, 2026 07:08
Copilot AI review requested due to automatic review settings February 17, 2026 07:08
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 pull request adds support for cross-repository PR creation to the assign-to-agent safe output. It enables workflows to track issues in one repository while creating pull requests in a different repository, using GitHub's native agentAssignment.targetRepositoryId GraphQL API parameter.

Changes:

  • Added pull-request-repo and allowed-pull-request-repos configuration parameters to specify where PRs should be created (separate from where issues live)
  • Implemented GraphQL mutation support for agentAssignment.targetRepositoryId when PR repository is configured
  • Updated formal specification with cross-repository validation requirements and usage examples
  • Added comprehensive test coverage for both global and per-item PR repository configuration

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scratchpad/safe-outputs-specification.md Added formal specification for pull-request-repo pattern including validation requirements (3.4.5) and cross-repository support pattern (6.2.1) with example A.3
pkg/parser/schemas/main_workflow_schema.json Added JSON schema definitions for pull-request-repo and allowed-pull-request-repos configuration fields
pkg/workflow/assign_to_agent.go Added PullRequestRepoSlug and AllowedPullRequestRepos fields to AssignToAgentConfig struct with YAML bindings
pkg/workflow/compiler_safe_outputs_specialized.go Added environment variable injection for GH_AW_AGENT_PULL_REQUEST_REPO and GH_AW_AGENT_ALLOWED_PULL_REQUEST_REPOS
pkg/workflow/js/safe_outputs_tools.json Updated assign_to_agent tool description and schema to include pull_request_repo parameter
actions/setup/js/assign_to_agent.cjs Implemented PR repository validation, GraphQL repository ID fetching, and per-item pull_request_repo parameter support
actions/setup/js/assign_agent_helpers.cjs Modified assignAgentToIssue to conditionally include agentAssignment.targetRepositoryId in GraphQL mutation based on pullRequestRepoId parameter
actions/setup/js/assign_to_agent.test.cjs Added test coverage for global pull-request-repo configuration and per-item pull_request_repo parameter
docs/src/content/docs/reference/safe-outputs.md Added user documentation explaining pull-request-repo parameter usage and cross-repository PR creation patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1150 to +1206
it("should handle pull-request-repo configuration correctly", async () => {
process.env.GH_AW_AGENT_PULL_REQUEST_REPO = "test-owner/pull-request-repo";
process.env.GH_AW_AGENT_ALLOWED_PULL_REQUEST_REPOS = "test-owner/pull-request-repo";
setAgentOutput({
items: [
{
type: "assign_to_agent",
issue_number: 42,
agent: "copilot",
},
],
errors: [],
});

// Mock GraphQL responses
mockGithub.graphql
// Get PR repository ID
.mockResolvedValueOnce({
repository: {
id: "pull-request-repo-id",
},
})
// Find agent
.mockResolvedValueOnce({
repository: {
suggestedActors: {
nodes: [{ login: "copilot-swe-agent", id: "agent-id" }],
},
},
})
// Get issue details
.mockResolvedValueOnce({
repository: {
issue: {
id: "issue-id",
assignees: { nodes: [] },
},
},
})
// Assign agent with agentAssignment
.mockResolvedValueOnce({
replaceActorsForAssignable: {
__typename: "ReplaceActorsForAssignablePayload",
},
});

await eval(`(async () => { ${assignToAgentScript}; await main(); })()`);

expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Using pull request repository: test-owner/pull-request-repo"));
expect(mockCore.info).toHaveBeenCalledWith(expect.stringContaining("Pull request repository ID: pull-request-repo-id"));

// Verify the mutation was called with agentAssignment
const lastGraphQLCall = mockGithub.graphql.mock.calls[mockGithub.graphql.mock.calls.length - 1];
expect(lastGraphQLCall[0]).toContain("agentAssignment");
expect(lastGraphQLCall[0]).toContain("targetRepositoryId");
expect(lastGraphQLCall[1].targetRepoId).toBe("pull-request-repo-id");
});
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test sets both GH_AW_AGENT_PULL_REQUEST_REPO and GH_AW_AGENT_ALLOWED_PULL_REQUEST_REPOS to the same repository value (line 1151-1152). This is inconsistent with the test pattern on lines 1105-1147 which verifies that the default repository is allowed even without an allowlist.

If pull-request-repo is meant to follow the same pattern as target-repo (where the configured value is automatically allowed), then this test should verify that pull-request-repo works WITHOUT needing to be listed in allowed-pull-request-repos. The test should only set GH_AW_AGENT_PULL_REQUEST_REPO and not set GH_AW_AGENT_ALLOWED_PULL_REQUEST_REPOS.

Alternatively, if the intention is that pull-request-repo must be explicitly listed in the allowlist, then:

  1. The comments/documentation claiming "in addition to pull-request-repo" are incorrect
  2. A test should be added to verify that pull-request-repo fails validation if not in the allowlist

This test needs to be updated to match the intended behavior and establish the correct pattern.

Copilot uses AI. Check for mistakes.
Allowed []string `yaml:"allowed,omitempty"` // Optional list of allowed agent names. If omitted, any agents are allowed.
IgnoreIfError bool `yaml:"ignore-if-error,omitempty"` // If true, workflow continues when agent assignment fails
PullRequestRepoSlug string `yaml:"pull-request-repo,omitempty"` // Target repository for PR creation in format "owner/repo" (where the issue lives may differ)
AllowedPullRequestRepos []string `yaml:"allowed-pull-request-repos,omitempty"` // List of additional repositories that PRs can be created in (in addition to pull-request-repo)
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on line 17 says "in addition to pull-request-repo" which implies that pull-request-repo is automatically allowed even if not listed in allowed-pull-request-repos. However, the validation logic in actions/setup/js/assign_to_agent.cjs (lines 137-141 and 237-238) uses validateRepo which checks against the allowlist and does NOT automatically include the pull-request-repo value as an allowed repository.

This creates an inconsistency: the comment suggests that pull-request-repo is implicitly allowed, but the code requires it to be explicitly listed in allowed-pull-request-repos. This differs from the pattern used for target-repo and allowed-repos, where target-repo is the default and allowed-repos contains ADDITIONAL allowed repositories.

Either:

  1. Update the comment to clarify that pull-request-repo must be included in allowed-pull-request-repos if you want to use it, OR
  2. Update the validation logic to automatically include pull-request-repo in the allowed set (similar to how defaultRepo is always allowed in validateRepo)

Recommendation: Follow the established pattern where the primary repo (pull-request-repo) is automatically allowed and allowed-pull-request-repos contains additional repositories.

Suggested change
AllowedPullRequestRepos []string `yaml:"allowed-pull-request-repos,omitempty"` // List of additional repositories that PRs can be created in (in addition to pull-request-repo)
AllowedPullRequestRepos []string `yaml:"allowed-pull-request-repos,omitempty"` // List of repositories that PRs can be created in; pull-request-repo must be included here if it should be allowed

Copilot uses AI. Check for mistakes.
"items": {
"type": "string"
},
"description": "List of additional repositories that pull requests can be created in (in addition to pull-request-repo). Each entry should be in 'owner/repo' format."
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description states "List of additional repositories that pull requests can be created in (in addition to pull-request-repo)" which implies that pull-request-repo is automatically allowed. However, based on the validation logic in actions/setup/js/assign_to_agent.cjs (lines 137-141), pull-request-repo must be explicitly listed in allowed-pull-request-repos to be valid.

This is inconsistent with the established pattern for target-repo and allowed-repos, where target-repo is automatically allowed and allowed-repos lists additional repositories. The validation logic uses validateRepo which treats defaultRepo as always allowed, but uses defaultRepo (the workflow's repository) as the default, not pull-request-repo.

The schema description should either:

  1. Be updated to clarify that pull-request-repo must be included in the allowlist, OR
  2. The validation logic should be updated to automatically allow pull-request-repo without requiring it in allowed-pull-request-repos
Suggested change
"description": "List of additional repositories that pull requests can be created in (in addition to pull-request-repo). Each entry should be in 'owner/repo' format."
"description": "List of repositories that pull requests are allowed to be created in. Each entry should be in 'owner/repo' format. When pull-request-repo is specified, it must also be included in this list."

Copilot uses AI. Check for mistakes.
Comment on lines +716 to +718
- Accept `allowed-pull-request-repos: ["owner/repo1", "owner/repo2"]` for validation
- Use `agentAssignment.targetRepositoryId` in GraphQL mutations when available

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 716 states "in addition to pull-request-repo" which implies that pull-request-repo is automatically allowed without being listed in allowed-pull-request-repos. However, the implementation in actions/setup/js/assign_to_agent.cjs requires explicit validation against the allowlist.

This is inconsistent with the established pattern for target-repo/allowed-repos where the primary repository is automatically allowed. The specification should clarify whether:

  1. pull-request-repo must be explicitly listed in allowed-pull-request-repos, OR
  2. pull-request-repo is automatically allowed and allowed-pull-request-repos contains additional repositories

For consistency with the existing target-repo/allowed-repos pattern, option 2 would be more appropriate.

Suggested change
- Accept `allowed-pull-request-repos: ["owner/repo1", "owner/repo2"]` for validation
- Use `agentAssignment.targetRepositoryId` in GraphQL mutations when available
- Accept `allowed-pull-request-repos: ["owner/repo1", "owner/repo2"]` for validation of additional repositories beyond `pull-request-repo`
- Use `agentAssignment.targetRepositoryId` in GraphQL mutations when available
Implementations MUST treat the repository specified by `pull-request-repo` as implicitly allowed for pull request creation; it does not need to be listed in `allowed-pull-request-repos`. The `allowed-pull-request-repos` list, when provided, MUST be used as an allowlist for any additional repositories (other than `pull-request-repo`) where pull requests may be created.

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Contributor

@copilot review comments make it behave like target repo

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot review comments make it behave like target repo

Fixed in commit 38069dd to match target-repo pattern:

Validation behavior:

  • pull-request-repo is automatically allowed (like target-repo)
  • allowed-pull-request-repos contains additional repositories (like allowed-repos)
  • Per-item pull_request_repo validated against global pull-request-repo + allowed-pull-request-repos

Updated:

  • JavaScript validation logic to pass pull-request-repo as default to validateRepo
  • Comments, documentation, schema descriptions to clarify auto-allow behavior
  • Tests: removed redundant allowlist entries, added test verifying auto-allow
  • Specification with explicit requirement to auto-allow pull-request-repo

All tests passing (32 passed, 3 skipped).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan pelikhan merged commit ac09021 into main Feb 17, 2026
122 checks passed
@pelikhan pelikhan deleted the copilot/add-assign-to-agent-repo-selection branch February 17, 2026 07:29
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.

Allow assign-to-agent safe output to select the repo that the PR should be created in

3 participants