Skip to content

Standardize Copilot agent-assignment permission guidance#46753

Merged
pelikhan merged 7 commits into
mainfrom
copilot/hippo-standardize-error-messages
Jul 20, 2026
Merged

Standardize Copilot agent-assignment permission guidance#46753
pelikhan merged 7 commits into
mainfrom
copilot/hippo-standardize-error-messages

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Agent-assignment failures were surfacing inconsistent permission and remediation text across CLI/workflow outputs. This update aligns the messaging so assignment failures clearly describe the missing capability, the supported token types, and the expected remediation path.

  • Shared assignment error messaging

    • Normalize the primary permission failure text in assign_agent_helpers.cjs
    • Explicitly call out:
      • GH_AW_AGENT_TOKEN
      • fine-grained PAT permissions (metadata: read, actions|contents|issues|pull requests: write)
      • classic PAT repo scope
      • GitHub App installation tokens are not supported for Copilot assignment
      • repository access / issue-assignment requirements
      • Copilot/org policy checks
    • Add both gh-aw auth docs and GitHub API docs as references
  • Failure summaries and generated remediation

    • Update the step-summary permission block to use the same structure and terminology
    • Refresh assignment failure context in handle_agent_failure.cjs so follow-up issue/comment content points to the same remediation guidance
    • Rewrite the created-issue assignment failure template to match the standardized wording
  • Docs/sample alignment

    • Update the sample test-assign-to-agent workflow note so the embedded guidance matches current supported auth behavior
  • Focused test coverage

    • Extend JS tests to assert the new permission heading, PAT guidance, GitHub App rejection note, and reference links
    • Add coverage for the rendered Copilot-assignment failure template path

Example of the normalized guidance shape:

### ⚠️ Copilot Assignment Permission Requirements

Copilot assignment failed because the workflow token could not update issue assignees via `POST /repos/{owner}/{repo}/issues/{issue_number}/assignees`.

- Set `GH_AW_AGENT_TOKEN` to a PAT with the required permissions
- Do not use a GitHub App installation token for Copilot assignment
- Ensure the token owner can access the repository and assign users to issues
- Verify Copilot coding agent is enabled and org policy allows bot assignments

Copilot AI and others added 3 commits July 20, 2026 07:52
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] Standardize agent-assignment permission error messages and guidance Standardize Copilot agent-assignment permission guidance Jul 20, 2026
Copilot AI requested a review from pelikhan July 20, 2026 08:13
Comment thread actions/setup/js/handle_agent_failure.cjs Outdated
Comment thread actions/setup/js/assign_agent_helpers.cjs Outdated
Copilot AI and others added 2 commits July 20, 2026 08:38
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan July 20, 2026 08:48
@pelikhan
pelikhan marked this pull request as ready for review July 20, 2026 08:58
Copilot AI review requested due to automatic review settings July 20, 2026 08:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Standardizes Copilot assignment permission and remediation guidance across runtime errors, summaries, templates, documentation samples, and tests.

Changes:

  • Moves assignment guidance into reusable Markdown templates.
  • Aligns PAT permissions, unsupported token guidance, and reference links.
  • Expands template-rendering tests and refreshes a generated workflow.
Show a summary per file
File Description
pkg/cli/workflows/test-assign-to-agent.md Updates sample authentication guidance.
actions/setup/md/copilot_assignment_permission_requirements.md Adds summary guidance template.
actions/setup/md/copilot_assignment_permission_references.md Adds reference links template.
actions/setup/md/copilot_assignment_permission_error.md Adds log error template.
actions/setup/md/copilot_assignment_errors_context.md Adds failure context template.
actions/setup/md/assign_copilot_to_created_issues_failure.md Standardizes created-issue failure remediation.
actions/setup/js/test_prompt_templates.js Adds test template synchronization helper.
actions/setup/js/handle_agent_failure.test.cjs Tests rendered failure guidance.
actions/setup/js/handle_agent_failure.cjs Renders assignment errors from templates.
actions/setup/js/assign_agent_helpers.test.cjs Updates permission-message assertions.
actions/setup/js/assign_agent_helpers.cjs Replaces inline guidance with templates.
.github/workflows/daily-vulnhunter-scan.lock.yml Refreshes generated runtime versions.

Review details

Tip

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

Comments suppressed due to low confidence (1)

actions/setup/js/handle_agent_failure.test.cjs:1400

  • This second process-wide environment assignment also needs restoration. Otherwise every subsequent test resolves prompts from runtimePromptsDir, ignoring its own RUNNER_TEMP; notably, the missing-template coverage at line 3555 can no longer exercise the missing-file path.
        process.env.GH_AW_PROMPTS_DIR = runtimePromptsDir;
  • Files reviewed: 12/12 changed files
  • Comments generated: 3
  • Review effort level: Medium

});

it("renders assignment failures with token guidance docs", () => {
process.env.GH_AW_PROMPTS_DIR = runtimePromptsDir;
Comment on lines +1 to +4
import { describe, it, expect, beforeEach, vi } from "vitest";
import { syncRuntimePromptTemplates } from "./test_prompt_templates.js";

syncRuntimePromptTemplates(import.meta.url);

**Required token options**
- **Fine-grained personal access token** — Read access to **metadata** and read/write access to **actions**, **contents**, **issues**, and **pull requests**
- **Classic personal access token****`repo`** scope
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #46753 does not have the 'implementation' label and has only 3 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look clean and consistent. The refactoring extracts hardcoded permission error strings into reusable template files, standardizes the messaging across all assignment failure paths, and accurately documents that GitHub App installation tokens are not supported for Copilot assignment. Tests are updated to match the new template content. No blocking issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 23.7 AIC · ⌖ 6.98 AIC · ⊞ 5K

@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 75/100 — Acceptable

Analyzed 2 test(s): 2 design, 0 implementation, 0 violation(s).

📊 Metrics (2 tests)
Metric Value
Analyzed 2 (Go: 0, JS: 2)
✅ Design 2 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 1 (50%)
Duplicate clusters 0
Inflation YES (handle_agent_failure.test.cjs +28 lines vs prod +7 lines = 4:1)
🚨 Violations 0
Test File Classification Issues
renders assignment failures with token guidance docs handle_agent_failure.test.cjs:1378 design_test / behavioral_contract / high_value Happy-path + 1 negative assertion (not.toContain) ✅
renders standardized copilot assignment remediation guidance handle_agent_failure.test.cjs:1399 design_test / behavioral_contract / high_value Happy-path only; no negative/error assertions
⚠️ Flagged Tests (1)

renders standardized copilot assignment remediation guidance (handle_agent_failure.test.cjs:1399) — behavioral contract, high value. Only positive toContain assertions; consider adding one not.toContain for a permission field that should not appear (e.g. verifying the old copilot-requests: write guidance is absent), matching the pattern in the sibling test.

Note on inflation: The 4:1 ratio is an artifact of prod simplification (net −3 prod lines), not test bloat.

Verdict

Passed. 0% implementation tests (threshold: 30%). No guideline violations. Score docked to 75 due to inflation ratio.

References:

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 38.8 AIC · ⌖ 9.65 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 75/100. 0% implementation tests (threshold: 30%). No guideline violations.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review\n\nApplied /tdd requesting changes on one test correctness issue.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 80.8 AIC · ⌖ 4.43 AIC · ⊞ 6.7K
Comment /matt to run again

import { describe, it, expect, beforeEach, vi } from "vitest";
import { syncRuntimePromptTemplates } from "./test_prompt_templates.js";

syncRuntimePromptTemplates(import.meta.url);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/tdd] The return value of syncRuntimePromptTemplates is discarded here, so GH_AW_PROMPTS_DIR is never set. Unlike handle_agent_failure.test.cjs which captures runtimePromptsDir and sets the env var before each template-exercising test, this file never sets process.env.GH_AW_PROMPTS_DIR. If RUNNER_TEMP is unset, getPromptPath() will throw and every test that indirectly calls logPermissionError or generatePermissionErrorSummary will fail.\n\n

\n💡 Suggested fix\n\njs\nconst { runtimePromptsDir } = syncRuntimePromptTemplates(import.meta.url);\nprocess.env.GH_AW_PROMPTS_DIR = runtimePromptsDir;\n\n\nOr set/restore in beforeEach/afterEach around just the permission-error tests, as done in handle_agent_failure.test.cjs.\n\n
\n\n@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❌ Request Changes — 2 correctness bugs must be fixed

Blocking issues found:

  1. PR failures mislabeled as Issue () — drops (type field), so every PR assignment failure renders as "Issue #N" instead of "PR #N". The sibling does this correctly and this regresses that behavior.

  2. No fallback when templates are missing () — and now throw unhandled exceptions if / is unset or the template file doesn't exist. The previous hard-coded strings were unconditionally safe; the new template path has zero fallback, silencing all permission error output in production when templates fail to load.

Non-blocking observations
  • is set inside test bodies without cleanup — can bleed into subsequent tests and mask real failures. (See comment on .)
  • calls but never sets , relying on being set at module load time — fragile in environments where differs between module init and test execution.

🔎 Code quality review by PR Code Quality Reviewer · 112.9 AIC · ⌖ 4.73 AIC · ⊞ 5.6K
Comment /review to run again

Comments that could not be inline-anchored

actions/setup/js/handle_agent_failure.cjs:2226

PR assignment failures always render as "Issue #N": parts[0] (the type field: &quot;issue&quot; or &quot;pr&quot;) is silently dropped, so every PR failure is mislabeled as an issue in the context block.

<details>
<summary>💡 Suggested fix</summary>

if (parts.length &gt;= 4) {
  const type = parts[0];
  const number = parts[1];
  const error = parts.slice(3).join(&#39;:&#39;);
  issueList += `- ${type === &#39;issue&#39; ? &#39;Issue&#39; : &#39;PR&#39;} #${number}: ${error}\n`;
}

The sibling buildAssignmentErrorsContext al…

actions/setup/js/assign_agent_helpers.cjs:435

Template read failure in logPermissionError silently swallows all error output: if getPromptPath throws (e.g. RUNNER_TEMP unset, GH_AW_PROMPTS_DIR unset) or renderTemplateFromFile cannot read the file, the exception propagates uncaught and the user sees nothing — not even the original "Insufficient permissions" line.

<details>
<summary>💡 Suggested fix</summary>

Wrap the template render in a try/catch and fall back to the essential inline message:

function logPermissionEr…

</details>

<details><summary>actions/setup/js/handle_agent_failure.test.cjs:1401</summary>

**`process.env.GH_AW_PROMPTS_DIR` set in test body but never cleaned up**: tests that run after this one will inherit the fixture prompts dir, potentially masking missing-template bugs in subsequent test cases.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summary&gt;

Use `afterEach` to restore the original value:

```js
let originalPromptsDir;
beforeEach(() =&gt; { originalPromptsDir = process.env.GH_AW_PROMPTS_DIR; });
afterEach(() =&gt; {
  if (originalPromptsDir === undefined) delete process.env.GH_AW_PROM…

</details>

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, refresh the branch if needed, address the unresolved review feedback below, and summarize the next concrete maintainer action after checks are current.

Unresolved review feedback:

Failed checks:

Run: https://github.com/github/gh-aw/actions/runs/29731780198

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • pi.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "pi.dev"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · 13.9 AIC · ⌖ 6.77 AIC · ⊞ 6.9K ·
Comment /souschef to run again

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

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Addressed in fcc498e. I fixed the prompt-template test isolation, reconciled the PAT guidance in copilot-cloud-agent.mdx, and re-ran make fmt, make lint, make test-unit, make test, and make agent-report-progress locally. CI on this new HEAD is stale until a maintainer re-triggers checks.

@pelikhan
pelikhan merged commit f16ffa9 into main Jul 20, 2026
31 of 32 checks passed
@pelikhan
pelikhan deleted the copilot/hippo-standardize-error-messages branch July 20, 2026 10:07
Copilot AI requested a review from gh-aw-bot July 20, 2026 10:07
Copilot stopped work on behalf of gh-aw-bot due to an error July 20, 2026 10:07
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.14

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.

[hippo] Standardize agent-assignment permission error messages and remediation guidance

4 participants