Skip to content
Merged
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
7 changes: 5 additions & 2 deletions actions/setup/js/copilot_harness.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ const CAPI_ERROR_400_PATTERN = /CAPIError:\s*400/;
// NOTE: keep in sync with HTTP_400_RESPONSE_ERROR_PATTERN in detect_agent_errors.cjs.
// Also matches "400 400 400 no model endpoints available given user constraints" which is emitted
// by the Copilot SDK when no model endpoints are available for the user's configured constraints.
// The second alternative is anchored to a leading "400" to avoid false positives from unrelated
// Also matches "400 400 400 stream_options: Extra inputs are not permitted" which is emitted when
// the Copilot SDK sends an OpenAI-only field to an Anthropic-type provider.
// The non-first alternatives are anchored to a leading "400" to avoid false positives from unrelated
// diagnostic or informational messages that might contain the phrase.
const HTTP_400_RESPONSE_ERROR_PATTERN = /(?:Response status code does not indicate success:\s*400(?:\s*\(Bad Request\))?|400[^\n]*no model endpoints available given user constraints)/i;
const HTTP_400_RESPONSE_ERROR_PATTERN =
/(?:Response status code does not indicate success:\s*400(?:\s*\(Bad Request\))?|400[^\n]*no model endpoints available given user constraints|400[^\n]*stream_options:\s*Extra inputs are not permitted)/i;

// Pattern to detect MCP servers blocked by enterprise/organization policy.
// This is a persistent policy configuration error — retrying will not help.
Expand Down
13 changes: 13 additions & 0 deletions actions/setup/js/copilot_harness.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,19 @@ describe("copilot_harness.cjs", () => {
const output = 'some prior output\n[copilot-sdk-driver] [sdk-driver] error: 400 400 400 no model endpoints available given user constraints\n{"type":"subagent.failed"}';
expect(isHTTP400ResponseError(output)).toBe(true);
});

it("matches the 'stream_options: Extra inputs are not permitted' Anthropic BYOK error", () => {
expect(isHTTP400ResponseError("[copilot-sdk-driver] [sdk-driver] error: 400 400 400 stream_options: Extra inputs are not permitted")).toBe(true);
});

it("matches the stream_options error embedded in larger output", () => {
const output = 'some prior output\n[copilot-sdk-driver] [sdk-driver] error: 400 400 400 stream_options: Extra inputs are not permitted\n{"type":"subagent.failed"}';
expect(isHTTP400ResponseError(output)).toBe(true);
});

it("does not false-positive on unrelated messages mentioning stream_options", () => {
expect(isHTTP400ResponseError("Configuring stream_options for the request")).toBe(false);
});
});

describe("no-auth-info detection pattern", () => {
Expand Down
7 changes: 5 additions & 2 deletions actions/setup/js/detect_agent_errors.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ const MODEL_NOT_SUPPORTED_PATTERN =
// NOTE: keep in sync with HTTP_400_RESPONSE_ERROR_PATTERN in copilot_harness.cjs.
// Also matches "400 400 400 no model endpoints available given user constraints" which is emitted
// by the Copilot SDK when no model endpoints are available for the user's configured constraints.
// The second alternative is anchored to a leading "400" to avoid false positives from unrelated
// Also matches "400 400 400 stream_options: Extra inputs are not permitted" which is emitted when
// the Copilot SDK sends an OpenAI-only field to an Anthropic-type provider.
// The non-first alternatives are anchored to a leading "400" to avoid false positives from unrelated
// diagnostic or informational messages that might contain the phrase.
const HTTP_400_RESPONSE_ERROR_PATTERN = /(?:Response status code does not indicate success:\s*400(?:\s*\(Bad Request\))?|400[^\n]*no model endpoints available given user constraints)/i;
const HTTP_400_RESPONSE_ERROR_PATTERN =
/(?:Response status code does not indicate success:\s*400(?:\s*\(Bad Request\))?|400[^\n]*no model endpoints available given user constraints|400[^\n]*stream_options:\s*Extra inputs are not permitted)/i;

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] detect_agent_errors.test.cjs directly tests the exported HTTP_400_RESPONSE_ERROR_PATTERN (lines 185–209), but no stream_options cases were added there — only copilot_harness.test.cjs got the new coverage. If the two pattern definitions drift in the future, the dedicated test file won't catch it.

💡 Suggested additions to detect_agent_errors.test.cjs

Add a parallel set of cases inside the existing describe("HTTP_400_RESPONSE_ERROR_PATTERN", ...) block:

it("matches the stream_options: Extra inputs are not permitted Anthropic BYOK error", () => {
  expect(
    HTTP_400_RESPONSE_ERROR_PATTERN.test(
      "[copilot-sdk-driver] [sdk-driver] error: 400 400 400 stream_options: Extra inputs are not permitted"
    )
  ).toBe(true);
});

it("does not false-positive on unrelated messages mentioning stream_options", () => {
  expect(
    HTTP_400_RESPONSE_ERROR_PATTERN.test("Configuring stream_options for the request")
  ).toBe(false);
});

This mirrors the new cases added to copilot_harness.test.cjs and directly guards the exported symbol against drift.

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in ea44e72detect_agent_errors.test.cjs now includes both the positive match case and the false-positive guard for stream_options, mirroring the coverage in copilot_harness.test.cjs.


// Pattern: Copilot/CAPI quota exhaustion and rate-limit responses.
// Matches all observed forms:
Expand Down
8 changes: 8 additions & 0 deletions actions/setup/js/detect_agent_errors.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ describe("detect_agent_errors.cjs", () => {
it("does not match 'no model endpoints available' without a leading 400", () => {
expect(HTTP_400_RESPONSE_ERROR_PATTERN.test("no model endpoints available given user constraints")).toBe(false);
});

it("matches the stream_options: Extra inputs are not permitted Anthropic BYOK error", () => {
expect(HTTP_400_RESPONSE_ERROR_PATTERN.test("[copilot-sdk-driver] [sdk-driver] error: 400 400 400 stream_options: Extra inputs are not permitted")).toBe(true);
});

it("does not false-positive on unrelated messages mentioning stream_options", () => {
expect(HTTP_400_RESPONSE_ERROR_PATTERN.test("Configuring stream_options for the request")).toBe(false);
});
});

describe("detectErrors", () => {
Expand Down
Loading