Skip to content

Bound Copilot safeoutputs -32602 empty-args retry loops with SDK session circuit-breaker#43555

Closed
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/aw-failures-fix-safe-output-retry-loop
Closed

Bound Copilot safeoutputs -32602 empty-args retry loops with SDK session circuit-breaker#43555
pelikhan with Copilot wants to merge 2 commits into
mainfrom
copilot/aw-failures-fix-safe-output-retry-loop

Conversation

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Reviewer workflows were spending the full step timeout when the Copilot turn repeatedly called write-once safeoutputs tools with empty arguments (-32602: Empty arguments are not allowed) and never converged. This change adds a bounded failure path so those turns terminate quickly instead of burning 15 minutes.

  • SDK guardrail: repeated empty-argument safeoutputs rejection

    • In actions/setup/js/copilot_sdk_session.cjs, added detection for consecutive -32602 empty-argument rejections on the same safeoutputs tool.
    • Introduced a circuit-breaker threshold (2 consecutive failures per tool) and early session disconnect when exceeded.
    • Emits a structured guard event:
      • guard.safeoutputs_empty_args_rejections_exceeded
    • Upgrades terminal guidance in the error path to explicitly stop empty-arg retries and prefer tools/list (single schema inspection) or noop.
  • Failure classification remains scoped

    • Guard only applies to mcpServerName === "safeoutputs" and only on failed tool completions matching the empty-args rejection pattern.
    • Non-matching failures and single occurrences continue through existing retry/error paths.
  • Targeted coverage for the new behavior

    • In actions/setup/js/copilot_sdk_driver.test.cjs, added tests for:
      • fast-fail after repeated empty-arg -32602 rejections for the same safeoutputs tool;
      • no guard trigger on a single rejection.
const isSafeOutputsEmptyArgsRejection =
  mcpServerName === "safeoutputs" &&
  !success &&
  SAFEOUTPUTS_EMPTY_ARGS_REJECTION_PATTERN.test(resultText);

if (isSafeOutputsEmptyArgsRejection) {
  const streak = (safeOutputsEmptyArgsStreakByTool.get(toolKey) ?? 0) + 1;
  if (streak >= SAFEOUTPUTS_EMPTY_ARGS_MAX_CONSECUTIVE) {
    catastrophicSafeOutputsEmptyArgsError = new Error(
      `safeoutputs empty-arguments rejection loop detected ...`
    );
    void session.disconnect();
  }
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix retry loop in Copilot CLI safe-output calls Bound Copilot safeoutputs -32602 empty-args retry loops with SDK session circuit-breaker Jul 5, 2026
Copilot AI requested a review from pelikhan July 5, 2026 13:54
@pelikhan pelikhan closed this Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants