Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/aw/safe-outputs-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ description: Safe-output reference for workflow dispatch, code scanning, checks,
custom-instructions: "..." # Optional: additional instructions for the agent
allowed: [copilot] # Optional: restrict to specific agent names
max: 1 # Optional: max assignments (default: 1)
target: "*" # Optional: "triggering" (default), "*", or number
target: "triggering" # Optional: "triggering" (default), "*", or number
target-repo: "owner/repo" # Optional: where the issue lives (cross-repository)
pull-request-repo: "owner/repo" # Optional: where PR should be created (if different)
allowed-pull-request-repos: [owner/repo1] # Optional: additional repos for PR creation
base-branch: "develop" # Optional: target branch for PR (default: repo default)
ignore-if-error: true # Optional: continue workflow on assignment error (default: false)
```

Requires PAT with elevated permissions as `GH_AW_AGENT_TOKEN`.
When target is `"triggering"` (the default), the agent may omit `issue_number`/`pull_number` — the target is auto-resolved from workflow context. Requires PAT with elevated permissions as `GH_AW_AGENT_TOKEN`.
- `assign-to-user:` - Assign users to issues or pull requests

```yaml
Expand Down
2 changes: 2 additions & 0 deletions actions/setup/js/assign_agent_helpers.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ async function assignAgentToIssue(assignableId, agentId, currentAssignees, agent

try {
core.info("Executing agent assignment GraphQL mutation");
core.info(`GraphQL final query:\n${mutation.trim()}`);

// Build debug log message with all parameters
const debugParts = [
Expand Down Expand Up @@ -525,6 +526,7 @@ async function assignAgentToIssue(assignableId, agentId, currentAssignees, agent
}
`;
core.info("Executing fallback agent assignment GraphQL mutation");
core.info(`GraphQL fallback query:\n${fallbackMutation.trim()}`);
core.debug(`Fallback GraphQL mutation with variables: assignableId=${assignableId}, assigneeIds=[${agentId}]`);
const fallbackResp = await githubClient.graphql(fallbackMutation, {
...fallbackVariables,
Expand Down
10 changes: 4 additions & 6 deletions actions/setup/js/safe_output_type_validator.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const SAMPLE_VALIDATION_CONFIG = {
},
assign_to_agent: {
defaultMax: 1,
customValidation: "requiresOneOf:issue_number,pull_number",
// issue_number and pull_number are optional: omit to auto-resolve from workflow context
fields: {
issue_number: { optionalPositiveInteger: true },
pull_number: { optionalPositiveInteger: true },
Expand Down Expand Up @@ -716,15 +716,13 @@ describe("safe_output_type_validator", () => {
expect(result.isValid).toBe(true);
});

it("should fail for assign_to_agent without issue_number or pull_number", async () => {
it("should pass for assign_to_agent without issue_number or pull_number (triggering context)", async () => {
const { validateItem } = await import("./safe_output_type_validator.cjs");

// issue_number and pull_number are optional — handler auto-resolves from workflow context
const result = validateItem({ type: "assign_to_agent", agent: "copilot" }, "assign_to_agent", 1);

expect(result.isValid).toBe(false);
expect(result.error).toContain("requires at least one of");
expect(result.error).toContain("issue_number");
expect(result.error).toContain("pull_number");
expect(result.isValid).toBe(true);
});

it("should fail for update_pull_request when update_branch is false and no title/body is provided", async () => {
Expand Down
66 changes: 33 additions & 33 deletions actions/setup/js/safe_outputs_tools.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/src/content/docs/reference/safe-outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,8 @@ safe-outputs:
github-token: ${{ secrets.SOME_CUSTOM_TOKEN }} # optional custom token for permissions
```

When using `target: "triggering"` (the default), the agent tool can omit `issue_number` and `pull_number` — the handler auto-resolves the target from the workflow context (the issue or PR that triggered the workflow). Explicitly providing `issue_number` or `pull_number` is required only when using `target: "*"` or a specific number.

See **[Copilot Cloud Agent](/gh-aw/reference/copilot-cloud-agent/#assign-to-agent)** for complete configuration options and authorization setup.

If you're creating new issues and want to assign an agent immediately, use `assignees: copilot` in your [`create-issue`](#issue-creation-create-issue) configuration instead.
Expand Down
12 changes: 11 additions & 1 deletion pkg/cli/workflows/test-assign-to-agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ This workflow tests the `assign_to_agent` safe output feature with automatic tar
## Task

**For issues event:**
Assign the Copilot coding agent to the triggering issue using the `assign_to_agent` tool from the `safeoutputs` MCP server. The issue number will be auto-resolved from the workflow context.
Assign the Copilot coding agent to the triggering issue using the `assign_to_agent` tool from the `safeoutputs` MCP server.

With `target: "triggering"` (the default), you can omit the `issue_number` — it is auto-resolved from the workflow context:
```
assign_to_agent(agent="copilot")
```

You may also explicitly provide the issue number:
```
assign_to_agent(issue_number=<number>, agent="copilot")
```

**For workflow_dispatch:**
Assign the Copilot coding agent to issue #${{ github.event.inputs.issue_number }} by providing the explicit issue number.
Expand Down
Loading
Loading