From 586903507b3d6df41c54db89544aaba7e020d90b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:53:02 +0000 Subject: [PATCH 1/2] Handle Copilot organization billing failures Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- ...patch-copilot-org-billing-agent-failure.md | 5 ++ actions/setup/js/handle_agent_failure.cjs | 52 ++++++++++++++++-- .../setup/js/handle_agent_failure.test.cjs | 55 +++++++++++++++++++ actions/setup/md/agent_failure_comment.md | 2 +- actions/setup/md/agent_failure_issue.md | 2 +- actions/setup/md/copilot_org_billing_error.md | 9 +++ 6 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 .changeset/patch-copilot-org-billing-agent-failure.md create mode 100644 actions/setup/md/copilot_org_billing_error.md diff --git a/.changeset/patch-copilot-org-billing-agent-failure.md b/.changeset/patch-copilot-org-billing-agent-failure.md new file mode 100644 index 00000000000..694174f5f1b --- /dev/null +++ b/.changeset/patch-copilot-org-billing-agent-failure.md @@ -0,0 +1,5 @@ +--- +"gh-aw": patch +--- + +Added specialized agent-failure guidance for Copilot authorization errors in workflows that use `permissions.copilot-requests: write`, including organization billing checks and the PAT fallback. diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index b2735cf4607..3f48855374f 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -63,6 +63,9 @@ const ELLIPSIS_LENGTH = ELLIPSIS.length; const ENGINE_RATE_LIMIT_429_RE = /(?:\b429\b[\s\S]{0,120}(?:too many requests|rate[\s-]*limit)|\brate_limit_(?:error|exceeded)\b|capierror:\s*429|failed to get response from the ai model[\s\S]{0,120}\b429\b|exceeded your rate limit for utility models)/i; const ENGINE_MAX_RUNS_EXCEEDED_RE = /(?:\bmax_runs_exceeded\b|\bmaximum\s+llm\s+invocations\s+exceeded\b)/i; +const COPILOT_ORG_BILLING_MODE_RE = /API proxy enabled:[^\n]*Copilot=true \(github-token\)/i; +const COPILOT_ORG_BILLING_ERROR_RE = + /(?:awf-reflect: models fetch returned 403\b|Copilot requests authentication failed through the gh-aw API proxy \(HTTP 403\b|Authentication failed with provider at (?:https?:\/\/)?(?:api-proxy|(?:172\.(?:1[6-9]|2\d|3[01])|10|192\.168)\.\d+\.\d+)(?::\d+)?[^\n]*\(HTTP 403\)|Access denied by policy settings|invalid access to inference)/i; const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?.+?)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; /** @@ -1751,6 +1754,19 @@ function buildInferenceAccessErrorContext(hasInferenceAccessError) { return "\n" + template; } +/** + * Build remediation for Copilot failures caused by unavailable organization billing. + * @param {boolean} hasCopilotOrgBillingError + * @returns {string} + */ +function buildCopilotOrgBillingErrorContext(hasCopilotOrgBillingError) { + if (!hasCopilotOrgBillingError) { + return ""; + } + + return "\n" + renderPromptTemplate("copilot_org_billing_error.md"); +} + /** * Build a context string when MCP servers were blocked by enterprise/organization policy. * This is a persistent configuration error — retrying will not help. @@ -2728,6 +2744,27 @@ function hasAgentTerminalReasonCompleted() { return false; } +/** + * Detect Copilot authorization failures while the API proxy is using the + * organization-billed GITHUB_TOKEN supplied by copilot-requests: write. + * @param {string} [stdioLogPathOverride] + * @returns {boolean} + */ +function detectCopilotOrgBillingErrorFromLog(stdioLogPathOverride) { + if (process.env.GH_AW_ENGINE_ID !== "copilot") { + return false; + } + + const agentOutputFile = process.env.GH_AW_AGENT_OUTPUT; + const stdioLogPath = stdioLogPathOverride || (agentOutputFile ? path.join(path.dirname(agentOutputFile), "agent-stdio.log") : "/tmp/gh-aw/agent-stdio.log"); + try { + const logContent = fs.readFileSync(stdioLogPath, "utf8"); + return COPILOT_ORG_BILLING_MODE_RE.test(logContent) && COPILOT_ORG_BILLING_ERROR_RE.test(logContent); + } catch { + return false; + } +} + /** * Detect AWF firewall startup failure signals from log content. * Uses specific failure patterns to avoid false positives on successful runs @@ -3389,6 +3426,7 @@ async function main() { const timeoutMinutes = process.env.GH_AW_TIMEOUT_MINUTES || ""; const { aiCredits, maxAICredits, aiCreditsRateLimitError, maxAICreditsExceeded } = resolveAICreditsFailureState(); const inferenceAccessError = process.env.GH_AW_INFERENCE_ACCESS_ERROR === "true"; + const copilotOrgBillingError = detectCopilotOrgBillingErrorFromLog(); const mcpPolicyError = process.env.GH_AW_MCP_POLICY_ERROR === "true"; const agenticEngineTimeout = process.env.GH_AW_AGENTIC_ENGINE_TIMEOUT === "true"; const modelNotSupportedError = process.env.GH_AW_MODEL_NOT_SUPPORTED_ERROR === "true"; @@ -4041,7 +4079,8 @@ async function main() { const timeoutContext = buildTimeoutContext(isTimedOut, timeoutMinutes); // Build inference access error context - const inferenceAccessErrorContext = buildInferenceAccessErrorContext(inferenceAccessError); + const copilotOrgBillingErrorContext = buildCopilotOrgBillingErrorContext(copilotOrgBillingError); + const inferenceAccessErrorContext = copilotOrgBillingErrorContext ? "" : buildInferenceAccessErrorContext(inferenceAccessError); // Build MCP policy error context const mcpPolicyErrorContext = buildMCPPolicyErrorContext(mcpPolicyError); @@ -4073,7 +4112,7 @@ async function main() { const skillInstallFailureContext = buildSkillInstallFailureContext(hasSkillInstallFailures, skillInstallErrors); // Build credential auth error context (firewall audit.jsonl 401/403 from provider endpoints) - const credentialAuthErrorContext = buildCredentialAuthErrorContext(); + const credentialAuthErrorContext = copilotOrgBillingErrorContext ? "" : buildCredentialAuthErrorContext(); // Create template context const templateContext = { @@ -4086,6 +4125,7 @@ async function main() { secret_verification_context: buildSecretVerificationContext(secretVerificationResult, engineSecretFailureMessage), docker_sbx_secrets_context: buildDockerSbxSecretsContext(dockerSbxSecretsResult), credential_auth_error_context: credentialAuthErrorContext, + copilot_org_billing_error_context: copilotOrgBillingErrorContext, assignment_errors_context: assignmentErrorsContext, assign_copilot_failure_context: assignCopilotFailureContext, skill_install_failure_context: skillInstallFailureContext, @@ -4271,7 +4311,8 @@ async function main() { const timeoutContext = buildTimeoutContext(isTimedOut, timeoutMinutes); // Build inference access error context - const inferenceAccessErrorContext = buildInferenceAccessErrorContext(inferenceAccessError); + const copilotOrgBillingErrorContext = buildCopilotOrgBillingErrorContext(copilotOrgBillingError); + const inferenceAccessErrorContext = copilotOrgBillingErrorContext ? "" : buildInferenceAccessErrorContext(inferenceAccessError); // Build MCP policy error context const mcpPolicyErrorContext = buildMCPPolicyErrorContext(mcpPolicyError); @@ -4303,7 +4344,7 @@ async function main() { const skillInstallFailureContext = buildSkillInstallFailureContext(hasSkillInstallFailures, skillInstallErrors); // Build credential auth error context (firewall audit.jsonl 401/403 from provider endpoints) - const credentialAuthErrorContext = buildCredentialAuthErrorContext(); + const credentialAuthErrorContext = copilotOrgBillingErrorContext ? "" : buildCredentialAuthErrorContext(); // Build optimize token consumption context (shown when a guardrail was the failure root cause) const optimizeTokenConsumptionContext = buildOptimizeTokenConsumptionContext({ maxAICreditsExceeded, hasDailyAICExceeded, hasToolDenialsExceeded, isTimedOut, runUrl }); @@ -4320,6 +4361,7 @@ async function main() { secret_verification_context: buildSecretVerificationContext(secretVerificationResult, engineSecretFailureMessage), docker_sbx_secrets_context: buildDockerSbxSecretsContext(dockerSbxSecretsResult), credential_auth_error_context: credentialAuthErrorContext, + copilot_org_billing_error_context: copilotOrgBillingErrorContext, assignment_errors_context: assignmentErrorsContext, assign_copilot_failure_context: assignCopilotFailureContext, skill_install_failure_context: skillInstallFailureContext, @@ -4463,6 +4505,8 @@ module.exports = { detectAWFFirewallStartupFailureFromLog, buildReportIncompleteContext, buildMCPPolicyErrorContext, + buildCopilotOrgBillingErrorContext, + detectCopilotOrgBillingErrorFromLog, buildModelNotSupportedErrorContext, buildHTTP400ResponseErrorContext, buildMissingDataContext, diff --git a/actions/setup/js/handle_agent_failure.test.cjs b/actions/setup/js/handle_agent_failure.test.cjs index 6ddaa0b9fd9..0aff6d6fc62 100644 --- a/actions/setup/js/handle_agent_failure.test.cjs +++ b/actions/setup/js/handle_agent_failure.test.cjs @@ -3562,6 +3562,61 @@ describe("handle_agent_failure", () => { // buildModelNotSupportedErrorContext // ────────────────────────────────────────────────────── + describe("buildCopilotOrgBillingErrorContext", () => { + let buildCopilotOrgBillingErrorContext; + let detectCopilotOrgBillingErrorFromLog; + const fs = require("fs"); + const path = require("path"); + const os = require("os"); + let tmpDir; + + beforeEach(() => { + vi.resetModules(); + tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "aw-test-copilot-org-billing-")); + const promptsDir = path.join(tmpDir, "gh-aw", "prompts"); + fs.mkdirSync(promptsDir, { recursive: true }); + fs.copyFileSync(path.join(runtimePromptsDir, "copilot_org_billing_error.md"), path.join(promptsDir, "copilot_org_billing_error.md")); + process.env.RUNNER_TEMP = tmpDir; + ({ buildCopilotOrgBillingErrorContext, detectCopilotOrgBillingErrorFromLog } = require("./handle_agent_failure.cjs")); + }); + + afterEach(() => { + delete process.env.RUNNER_TEMP; + delete process.env.GH_AW_ENGINE_ID; + fs.rmSync(tmpDir, { recursive: true, force: true }); + }); + + it("returns billing and PAT guidance for a detected organization-billed failure", () => { + const result = buildCopilotOrgBillingErrorContext(true); + expect(result).toContain("Copilot organization billing is unavailable"); + expect(result).toContain("Allow use of Copilot CLI billed to the organization"); + expect(result).toContain("COPILOT_GITHUB_TOKEN"); + expect(result).toContain("https://github.github.com/gh-aw/reference/billing/"); + }); + + it("returns no guidance when the combined error was not detected", () => { + expect(buildCopilotOrgBillingErrorContext(false)).toBe(""); + }); + + it.each([ + "[copilot-harness] awf-reflect: models fetch returned 403 for http://api-proxy:10002/models", + "Copilot requests authentication failed through the gh-aw API proxy (HTTP 403, model=auto, stage=listing models).", + "Authentication failed with provider at http://172.30.0.30:10002 (HTTP 403).", + ])("detects reported organization-billed Copilot error: %s", errorOutput => { + process.env.GH_AW_ENGINE_ID = "copilot"; + const logPath = path.join(tmpDir, "agent-stdio.log"); + fs.writeFileSync(logPath, `[INFO] API proxy enabled: OpenAI=false, Copilot=true (github-token)\n${errorOutput}`); + expect(detectCopilotOrgBillingErrorFromLog(logPath)).toBe(true); + }); + + it("does not classify PAT-based Copilot failures as organization billing errors", () => { + process.env.GH_AW_ENGINE_ID = "copilot"; + const logPath = path.join(tmpDir, "agent-stdio.log"); + fs.writeFileSync(logPath, "[copilot-harness] awf-reflect: models fetch returned 403 for http://api-proxy:10002/models"); + expect(detectCopilotOrgBillingErrorFromLog(logPath)).toBe(false); + }); + }); + describe("buildModelNotSupportedErrorContext", () => { let buildModelNotSupportedErrorContext; const fs = require("fs"); diff --git a/actions/setup/md/agent_failure_comment.md b/actions/setup/md/agent_failure_comment.md index 96b85dfb3e2..f594ab26403 100644 --- a/actions/setup/md/agent_failure_comment.md +++ b/actions/setup/md/agent_failure_comment.md @@ -1,3 +1,3 @@ Agent job [{run_id}]({run_url}) failed. -{secret_verification_context}{docker_sbx_secrets_context}{credential_auth_error_context}{inference_access_error_context}{mcp_policy_error_context}{model_not_supported_error_context}{http_400_response_error_context}{ai_credits_rate_limit_error_context}{unknown_model_ai_credits_context}{missing_model_pricing_context}{shell_expansion_guard_rejected_context}{app_token_minting_failed_context}{lockdown_check_failed_context}{oauth_token_check_failed_context}{stale_lock_file_failed_context}{daily_ai_credits_exceeded_context}{daily_ai_credits_guardrail_error_context}{assignment_errors_context}{assign_copilot_failure_context}{skill_install_failure_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{push_repo_memory_failure_context}{missing_data_context}{missing_tool_context}{permission_denied_context}{tool_denials_exceeded_context}{report_incomplete_context}{missing_safe_outputs_context}{engine_failure_context}{timeout_context}{fork_context} +{secret_verification_context}{docker_sbx_secrets_context}{copilot_org_billing_error_context}{credential_auth_error_context}{inference_access_error_context}{mcp_policy_error_context}{model_not_supported_error_context}{http_400_response_error_context}{ai_credits_rate_limit_error_context}{unknown_model_ai_credits_context}{missing_model_pricing_context}{shell_expansion_guard_rejected_context}{app_token_minting_failed_context}{lockdown_check_failed_context}{oauth_token_check_failed_context}{stale_lock_file_failed_context}{daily_ai_credits_exceeded_context}{daily_ai_credits_guardrail_error_context}{assignment_errors_context}{assign_copilot_failure_context}{skill_install_failure_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{push_repo_memory_failure_context}{missing_data_context}{missing_tool_context}{permission_denied_context}{tool_denials_exceeded_context}{report_incomplete_context}{missing_safe_outputs_context}{engine_failure_context}{timeout_context}{fork_context} diff --git a/actions/setup/md/agent_failure_issue.md b/actions/setup/md/agent_failure_issue.md index 8de7c8ec3c2..e69cc1ef32b 100644 --- a/actions/setup/md/agent_failure_issue.md +++ b/actions/setup/md/agent_failure_issue.md @@ -4,7 +4,7 @@ **Branch:** {branch} **Run:** {run_url}{pull_request_info} -{secret_verification_context}{docker_sbx_secrets_context}{credential_auth_error_context}{inference_access_error_context}{mcp_policy_error_context}{model_not_supported_error_context}{http_400_response_error_context}{ai_credits_rate_limit_error_context}{unknown_model_ai_credits_context}{missing_model_pricing_context}{shell_expansion_guard_rejected_context}{app_token_minting_failed_context}{lockdown_check_failed_context}{oauth_token_check_failed_context}{stale_lock_file_failed_context}{daily_ai_credits_exceeded_context}{daily_ai_credits_guardrail_error_context}{assignment_errors_context}{assign_copilot_failure_context}{skill_install_failure_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{push_repo_memory_failure_context}{missing_data_context}{missing_tool_context}{permission_denied_context}{tool_denials_exceeded_context}{report_incomplete_context}{missing_safe_outputs_context}{engine_failure_context}{timeout_context}{fork_context} +{secret_verification_context}{docker_sbx_secrets_context}{copilot_org_billing_error_context}{credential_auth_error_context}{inference_access_error_context}{mcp_policy_error_context}{model_not_supported_error_context}{http_400_response_error_context}{ai_credits_rate_limit_error_context}{unknown_model_ai_credits_context}{missing_model_pricing_context}{shell_expansion_guard_rejected_context}{app_token_minting_failed_context}{lockdown_check_failed_context}{oauth_token_check_failed_context}{stale_lock_file_failed_context}{daily_ai_credits_exceeded_context}{daily_ai_credits_guardrail_error_context}{assignment_errors_context}{assign_copilot_failure_context}{skill_install_failure_context}{create_discussion_errors_context}{code_push_failure_context}{repo_memory_validation_context}{push_repo_memory_failure_context}{missing_data_context}{missing_tool_context}{permission_denied_context}{tool_denials_exceeded_context}{report_incomplete_context}{missing_safe_outputs_context}{engine_failure_context}{timeout_context}{fork_context} ### Action Required diff --git a/actions/setup/md/copilot_org_billing_error.md b/actions/setup/md/copilot_org_billing_error.md new file mode 100644 index 00000000000..91432f910ca --- /dev/null +++ b/actions/setup/md/copilot_org_billing_error.md @@ -0,0 +1,9 @@ +> [!WARNING] +> **Copilot organization billing is unavailable**: The workflow uses `permissions.copilot-requests: write`, but GitHub Copilot rejected the built-in `GITHUB_TOKEN`. + +To resolve this: + +1. Ask an organization owner to check **Organization settings → Copilot → Policies → Copilot CLI** and enable **Allow use of Copilot CLI billed to the organization**. +2. If organization billing is unavailable, use individual billing instead: set `permissions.copilot-requests: none`, configure a `COPILOT_GITHUB_TOKEN` repository secret with a fine-grained personal access token from a user with an active Copilot subscription, and recompile the workflow. + +See [Copilot billing](https://github.github.com/gh-aw/reference/billing/) for complete setup instructions. From 8dc686512bfef2c22977a06d4fe58915ee86aef8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 14 Sep 2026 16:45:20 +0000 Subject: [PATCH 2/2] Classify Copilot org billing failures and align proxy host allowlist Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- ...patch-copilot-org-billing-agent-failure.md | 2 +- actions/setup/js/handle_agent_failure.cjs | 14 +++++++++-- .../setup/js/handle_agent_failure.test.cjs | 25 +++++++++++++++++++ .../content/docs/reference/safe-outputs.md | 1 + pkg/parser/schemas/main_workflow_schema.json | 2 +- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/.changeset/patch-copilot-org-billing-agent-failure.md b/.changeset/patch-copilot-org-billing-agent-failure.md index 694174f5f1b..d22b9726eff 100644 --- a/.changeset/patch-copilot-org-billing-agent-failure.md +++ b/.changeset/patch-copilot-org-billing-agent-failure.md @@ -2,4 +2,4 @@ "gh-aw": patch --- -Added specialized agent-failure guidance for Copilot authorization errors in workflows that use `permissions.copilot-requests: write`, including organization billing checks and the PAT fallback. +Added specialized agent-failure guidance for Copilot authorization errors in workflows that use `permissions.copilot-requests: write`, including organization billing checks and the PAT fallback. Such failures are now reported under the `copilot_org_billing_error` category with a dedicated failure issue title. diff --git a/actions/setup/js/handle_agent_failure.cjs b/actions/setup/js/handle_agent_failure.cjs index 3f48855374f..72805253b21 100644 --- a/actions/setup/js/handle_agent_failure.cjs +++ b/actions/setup/js/handle_agent_failure.cjs @@ -64,8 +64,13 @@ const ENGINE_RATE_LIMIT_429_RE = /(?:\b429\b[\s\S]{0,120}(?:too many requests|rate[\s-]*limit)|\brate_limit_(?:error|exceeded)\b|capierror:\s*429|failed to get response from the ai model[\s\S]{0,120}\b429\b|exceeded your rate limit for utility models)/i; const ENGINE_MAX_RUNS_EXCEEDED_RE = /(?:\bmax_runs_exceeded\b|\bmaximum\s+llm\s+invocations\s+exceeded\b)/i; const COPILOT_ORG_BILLING_MODE_RE = /API proxy enabled:[^\n]*Copilot=true \(github-token\)/i; -const COPILOT_ORG_BILLING_ERROR_RE = - /(?:awf-reflect: models fetch returned 403\b|Copilot requests authentication failed through the gh-aw API proxy \(HTTP 403\b|Authentication failed with provider at (?:https?:\/\/)?(?:api-proxy|(?:172\.(?:1[6-9]|2\d|3[01])|10|192\.168)\.\d+\.\d+)(?::\d+)?[^\n]*\(HTTP 403\)|Access denied by policy settings|invalid access to inference)/i; +// Host allowlist kept aligned with isLikelyAWFAPIProxyURL in copilot_harness.cjs: +// awf_reflect rewrites api-proxy to host-bridge addresses for host execution. +const AWF_API_PROXY_HOST_RE_SOURCE = "(?:api-proxy|host\\.docker\\.internal|localhost|127(?:\\.\\d{1,3}){3}|10(?:\\.\\d{1,3}){3}|192\\.168(?:\\.\\d{1,3}){2}|172\\.(?:1[6-9]|2\\d|3[01])(?:\\.\\d{1,3}){2})"; +const COPILOT_ORG_BILLING_ERROR_RE = new RegExp( + `(?:awf-reflect: models fetch returned 403\\b|Copilot requests authentication failed through the gh-aw API proxy \\(HTTP 403\\b|Authentication failed with provider at (?:https?:\\/\\/)?${AWF_API_PROXY_HOST_RE_SOURCE}(?::\\d+)?[^\\n]*\\(HTTP 403\\))`, + "i" +); const ALLOWED_FILES_ERROR_RE = /^(?.*outside the allowed-files list) \((?.+?)\)\. (?Add the files to the allowed-files configuration field or remove them from the (?:patch|bundle)\.)$/; /** @@ -276,6 +281,7 @@ function buildFailureMatchCategories(options) { if (options.secretVerificationFailed) categories.push("secret_verification_failed"); if (options.hasDockerSbxSecretsFailed) categories.push("docker_sbx_secrets_missing"); if (options.inferenceAccessError) categories.push("inference_access_error"); + if (options.copilotOrgBillingError) categories.push("copilot_org_billing_error"); if (options.mcpPolicyError) categories.push("mcp_policy_error"); if (options.modelNotSupportedError) categories.push("model_not_supported_error"); if (options.http400ResponseError) categories.push("http_400_response_error"); @@ -328,6 +334,7 @@ function buildFailureMatchCategories(options) { * @param {boolean} options.http400ResponseError * @param {boolean} options.unknownModelAICredits * @param {boolean} [options.hasDockerSbxSecretsFailed] + * @param {boolean} [options.copilotOrgBillingError] * @param {boolean} [options.missingModelPricingError] * @param {string} [options.missingModelPricingModelName] * @param {boolean} [options.shellExpansionGuardRejected] @@ -358,6 +365,7 @@ function buildFailureIssueTitle(options) { if (options.hasStaleLockFileFailed) return `[aw] ${workflowName} has stale lock file`; if (options.shellExpansionGuardRejected) return `[aw] ${workflowName} hit shell expansion guard rejection`; if (options.hasDockerSbxSecretsFailed) return `[aw] ${workflowName} is missing docker-sbx Docker Hub secrets`; + if (options.copilotOrgBillingError) return `[aw] ${workflowName} hit Copilot organization billing error`; if (options.isTimedOut) return `[aw] ${workflowName} timed out`; if (options.hasToolDenialsExceeded) return `[aw] ${workflowName} exceeded tool denial limit`; if (options.hasCacheMissMisconfiguration) return `[aw] ${workflowName} has cache-memory miss misconfiguration`; @@ -3886,6 +3894,7 @@ async function main() { missingModelPricingError, missingModelPricingModelName, hasDockerSbxSecretsFailed, + copilotOrgBillingError, }); const failureCategories = buildFailureMatchCategories({ agentConclusion, @@ -3906,6 +3915,7 @@ async function main() { secretVerificationFailed: hasSecretVerificationFailed, hasDockerSbxSecretsFailed, inferenceAccessError, + copilotOrgBillingError, mcpPolicyError, modelNotSupportedError, http400ResponseError, diff --git a/actions/setup/js/handle_agent_failure.test.cjs b/actions/setup/js/handle_agent_failure.test.cjs index 0aff6d6fc62..2c479e88520 100644 --- a/actions/setup/js/handle_agent_failure.test.cjs +++ b/actions/setup/js/handle_agent_failure.test.cjs @@ -149,6 +149,7 @@ describe("handle_agent_failure", () => { { flag: "hasMissingTool", expected: "[aw] Test Workflow is missing required tool" }, { flag: "hasMissingData", expected: "[aw] Test Workflow is missing required data" }, { flag: "hasAssignmentErrors", expected: "[aw] Test Workflow failed to assign agent" }, + { flag: "copilotOrgBillingError", expected: "[aw] Test Workflow hit Copilot organization billing error" }, ]; it.each(cases)("returns expected title for isolated $flag", ({ flag, expected }) => { @@ -3615,6 +3616,20 @@ describe("handle_agent_failure", () => { fs.writeFileSync(logPath, "[copilot-harness] awf-reflect: models fetch returned 403 for http://api-proxy:10002/models"); expect(detectCopilotOrgBillingErrorFromLog(logPath)).toBe(false); }); + + it.each(["host.docker.internal", "localhost", "127.0.0.1", "10.1.2.3", "192.168.1.4"])("detects provider auth failures against host-bridge proxy host %s", proxyHost => { + process.env.GH_AW_ENGINE_ID = "copilot"; + const logPath = path.join(tmpDir, "agent-stdio.log"); + fs.writeFileSync(logPath, `[INFO] API proxy enabled: OpenAI=false, Copilot=true (github-token)\nAuthentication failed with provider at http://${proxyHost}:10002 (HTTP 403).`); + expect(detectCopilotOrgBillingErrorFromLog(logPath)).toBe(true); + }); + + it.each(["Access denied by policy settings", "invalid access to inference"])("does not classify generic inference access rejection %s as an organization billing error", errorOutput => { + process.env.GH_AW_ENGINE_ID = "copilot"; + const logPath = path.join(tmpDir, "agent-stdio.log"); + fs.writeFileSync(logPath, `[INFO] API proxy enabled: OpenAI=false, Copilot=true (github-token)\n${errorOutput}`); + expect(detectCopilotOrgBillingErrorFromLog(logPath)).toBe(false); + }); }); describe("buildModelNotSupportedErrorContext", () => { @@ -5693,6 +5708,16 @@ describe("handle_agent_failure", () => { } }); + it("returns copilot_org_billing_error category instead of the agent_failure fallback", () => { + const categories = buildFailureMatchCategories({ + agentConclusion: "failure", + isTimedOut: false, + copilotOrgBillingError: true, + }); + expect(categories).toContain("copilot_org_billing_error"); + expect(categories).not.toContain("agent_failure"); + }); + it("returns http_400_response_error category", () => { const categories = buildFailureMatchCategories({ http400ResponseError: true, diff --git a/docs/src/content/docs/reference/safe-outputs.md b/docs/src/content/docs/reference/safe-outputs.md index f027b2e1552..277e3c1f715 100644 --- a/docs/src/content/docs/reference/safe-outputs.md +++ b/docs/src/content/docs/reference/safe-outputs.md @@ -1773,6 +1773,7 @@ safe-outputs: | `missing_tool` | Required functionality is not available | | `missing_data` | Required data is not accessible | | `inference_access_error` | AI inference endpoint authentication or access failures | +| `copilot_org_billing_error` | Copilot authorization failed because organization billing for Copilot CLI is unavailable | | `mcp_policy_error` | MCP server policy violations | | `ai_credits_rate_limit_error` | AI credits rate limit exceeded | | `max_ai_credits_exceeded` | Maximum AI credits budget exceeded | diff --git a/pkg/parser/schemas/main_workflow_schema.json b/pkg/parser/schemas/main_workflow_schema.json index d4048e7f876..8103e70777c 100644 --- a/pkg/parser/schemas/main_workflow_schema.json +++ b/pkg/parser/schemas/main_workflow_schema.json @@ -12334,7 +12334,7 @@ "description": "List of failure categories that should trigger issue creation. Categories can be prefixed with '!' to exclude them (e.g., '!inference_access_error'). If only non-prefixed categories are specified, only those categories trigger issues. If only prefixed (excluded) categories are specified, all categories except those trigger issues. If both are specified, categories must match included AND not match excluded. Common categories: agent_failure, timed_out, missing_safe_outputs, report_incomplete, missing_tool, missing_data, inference_access_error, mcp_policy_error, ai_credits_rate_limit_error, max_ai_credits_exceeded, daily_ai_credits_unknown.", "items": { "type": "string", - "pattern": "^!?(agent_failure|timed_out|missing_safe_outputs|report_incomplete|missing_tool|missing_data|tool_denials_exceeded|cache_miss_misconfiguration|secret_verification_failed|inference_access_error|mcp_policy_error|model_not_supported_error|ai_credits_rate_limit_error|unknown_model_ai_credits|max_ai_credits_exceeded|app_token_minting_failed|lockdown_check_failed|stale_lock_file_failed|daily_ai_credits_exceeded|daily_ai_credits_unknown|assignment_errors|assign_copilot_failures|skill_install_failures|create_discussion_errors|code_push_failures|repo_memory_validation_errors|push_repo_memory_failure)$" + "pattern": "^!?(agent_failure|timed_out|missing_safe_outputs|report_incomplete|missing_tool|missing_data|tool_denials_exceeded|cache_miss_misconfiguration|secret_verification_failed|inference_access_error|copilot_org_billing_error|mcp_policy_error|model_not_supported_error|ai_credits_rate_limit_error|unknown_model_ai_credits|max_ai_credits_exceeded|app_token_minting_failed|lockdown_check_failed|stale_lock_file_failed|daily_ai_credits_exceeded|daily_ai_credits_unknown|assignment_errors|assign_copilot_failures|skill_install_failures|create_discussion_errors|code_push_failures|repo_memory_validation_errors|push_repo_memory_failure)$" }, "minItems": 1, "uniqueItems": true