Repository navigation
Stop retrying Copilot cybersecurity-policy rejections - #77351
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot extend this to any harness using GitHub provider |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ Matt Pocock Skills ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ PR Specification Reviewer completed successfully! Commit pushed:
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
Reviewed the changed content-filter classification and regression coverage. The exact top-level query/sdk_driver policy rejection handling is scoped to root sessions and preserves retry behavior for unrelated or nested events. No blocking correctness issues found.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review to run again
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Reviewed head c37225a against Copilot SDK Driver Specification v1.0.2. The PR intentionally extends main-session content-filter evidence to top-level session.error events for errorType query/sdk_driver with the exact cybersecurity-risk 422 prefix, while preserving nested, quoted, unrelated, and failure/noop semantics. Synchronized docs/src/content/docs/specs/copilot-sdk-driver-specification.md to v1.0.3: updated Section 7.2, added T-CSD-301..305 and checklist coverage, and changelog entry. The specification commit is queued for publication to the same-repository PR branch. No blocking conformance findings.
Generated by PR Specification Reviewer for #77351 · copilot · gpt50 · ~4 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review-specs to run again
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the provider policy-rejection handling change.
No open issues 🎉
What changed in this PR
This PR updates the Copilot harness to stop retrying explicit provider cybersecurity-policy rejections, reusing the existing terminal content_filter handling.
Changes:
- Recognize the exact rejection prefix in top-level
queryandsdk_drivererror events. - Preserve failure status even when noop output exists, while excluding quoted, unrelated, and sub-agent errors.
- Extend regression coverage for both error formats and single-attempt subprocess behavior.
| File | Description |
|---|---|
actions/setup/js/copilot_harness.test.cjs |
Adds policy-rejection classification cases and expands retry/noop regression coverage. |
actions/setup/js/copilot_harness.cjs |
Classifies matching top-level provider policy errors as terminal content-filter failures. |
Review effort: Balanced (dynamic)
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /codebase-design. The fix is correct and the change is small. Two non-blocking suggestions are inline.
📋 Key Themes & Highlights
Key Themes
- Terminal classification: the new
session.errorbranch correctly reuses the existingcontent_filterstop path, so the retry is suppressed and the attempt stays failed. - Trust boundary: the new branch is not gated the way
assistant.messageis (rte: true). Impact looks bounded, but it should be stated in the PR description. - Duplicated literal: the policy prefix is hand-copied between the harness and the tests.
Positive Highlights
- ✅ Nested and sub-agent errors are excluded through
copilotSessionContext, and the tests cover that. - ✅ The
sdk_driverevent shape matches the producer incopilot_sdk_session.cjs, so the new branch matches real output. - ✅ The subprocess test checks single-attempt behavior with both noop states.
Validation Note
vitest is not installed in this environment (npm ci failed on a TLS certificate error), so I could not run the suite. I exercised the predicate directly with Node: all 3 positive cases return true, and all 9 negative cases from the test table return false. Please confirm CI runs copilot_harness.test.cjs.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| if (context.agentId === undefined && !context.parentToolUseId && getCopilotMessageRefusal(event.data)?.reason === "content_filter") return true; | ||
| if (context.agentId !== undefined || context.parentToolUseId) continue; | ||
| if (event.type === "assistant.message" && getCopilotMessageRefusal(event.data)?.reason === "content_filter") return true; | ||
| if (event.type === "session.error" && ["query", "sdk_driver"].includes(event.data?.errorType) && typeof event.data?.message === "string" && /^422 This content was flagged for possible cybersecurity risk\./.test(event.data.message)) |
There was a problem hiding this comment.
[/codebase-design] The provider rejection prefix is now inline in this regex, and the same wording is hand-copied into the test file. Hoist it into a named constant beside COPILOT_CONTENT_FILTER_MESSAGE in copilot_session.cjs (the existing pattern for this failure class) and reuse it in the tests, so a provider wording change is a one-line edit. Pulling the compound condition into a named helper would also make this 235-character line easier to read.
💡 Suggested shape
// copilot_session.cjs
const COPILOT_CYBERSECURITY_POLICY_PREFIX = "422 This content was flagged for possible cybersecurity risk.";Then check event.data.message.startsWith(COPILOT_CYBERSECURITY_POLICY_PREFIX). For a literal prefix this is equivalent to the current ^-anchored regex.
@copilot please address this.
There was a problem hiding this comment.
Exported CYBERSECURITY_POLICY_REJECTION_PREFIX from the shared provider detector and reused it across the Copilot, Claude, Codex, and shared detector tests. This also keeps the literal centralized for future wording changes. Commit: a682537.
| function isCopilotContentFilterError(output) { | ||
| for (const event of iterateJsonl(output)) { | ||
| if (event?.type !== "assistant.message") continue; | ||
| if (event?.type !== "assistant.message" && event?.type !== "session.error") continue; |
There was a problem hiding this comment.
[/diagnosing-bugs] Question on the trust boundary: this scan runs over combined stdout/stderr, which can include tool output. A tool result that echoes a session.error JSON line with this prefix would now suppress retries. The assistant.message branch requires rte: true, but the new session.error branch has no equivalent gate. The impact looks bounded (it only suppresses a retry on an attempt that already failed, and the attempt is still marked failed), so this is probably acceptable. Please confirm that and state the assumption in the PR description.
@copilot please address this.
There was a problem hiding this comment.
Confirmed: because the classifier scans combined process output, tool output could echo a matching top-level session.error and suppress a retry. The consequence is limited to not retrying an attempt that already failed; content_filter remains a failure and cannot become success/noop. I cannot edit the PR description through the available GitHub interface, so this assumption still needs to be copied into the description before merge.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Extended terminal cybersecurity-policy rejection handling to Copilot, Claude, and Codex when routed through a GitHub provider, with regression coverage. Commit: |
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Ran the PR finisher. The shared-prefix test cleanup is committed as |
| */ | ||
| function isTopLevelEvent(event) { | ||
| const data = event?.data ?? {}; | ||
| return ![event?.agentId, event?.agent_id, data.agentId, data.agent_id, event?.parentToolUseId, event?.parent_tool_use_id, data.parentToolUseId, data.parent_tool_use_id, event?.parentToolCallId, data.parentToolCallId].some( |
|
🎉 This pull request is included in a new release. Release: |
The failing Actions job received a provider HTTP 422 cybersecurity-policy rejection. The harness classified it as partial execution and retried the unchanged request three times.
queryandsdk_drivererror events; reuse the existingcontent_filterstop path.This addresses futile retries, not the underlying provider-access restriction.