Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

[BYOK/CustomOAI] Payload format incorrectly defaults to ChatCompletions when using explicit /responses endpoint - #5111

Open
Simba98 wants to merge 1 commit into
microsoft:mainfrom
Simba98:patch-2
Open

[BYOK/CustomOAI] Payload format incorrectly defaults to ChatCompletions when using explicit /responses endpoint#5111
Simba98 wants to merge 1 commit into
microsoft:mainfrom
Simba98:patch-2

Conversation

@Simba98

@Simba98 Simba98 commented May 11, 2026

Copy link
Copy Markdown

Description:

When configuring a Custom OpenAI or Azure BYOK provider in settings.json with a custom deployment URL ending in /responses (e.g., "https://my-custom-gateway.azure/v1/responses"), the Copilot Chat extension incorrectly sends the payload using the standard /chat/completions JSON format instead of the expected Responses API format.

This causes 400 Bad Request errors on custom backend servers that are explicitly designed to parse the Copilot Responses API schema.

Root Cause Analysis:

I traced the issue to src/extension/byok/vscode-node/customOAIProvider.ts in the AbstractCustomOAIBYOKModelProvider.createOpenAIEndPoint method:

// Current implementation
if (modelCapabilities?.url?.includes('/responses')) {
    modelInfo.supported_endpoints = [
        ModelSupportedEndpoint.ChatCompletions, // <-- The culprit
        ModelSupportedEndpoint.Responses
    ];
}

Why this matters (Use Case):

While /responses is not a standard public OpenAI API endpoint, it is the native protocol used by Copilot to support advanced streaming, thinking parts, and tool calling. Enterprise users and developers often build custom middleware/gateways that implement the /responses endpoint to fully support Copilot's advanced features. When the user explicitly sets the URL to /responses, they expect the client to send the Responses payload, not the legacy ChatCompletions payload.

In future (More Flexible): Do not hardcode this in createOpenAIEndPoint. Instead, allow users to specify supportedEndpoints in settings.json under the model capabilities, and let resolveModelInfo() handle it (it already has logic to parse supportedEndpoints from BYOKModelCapabilities).

Responses endpoint usually do not support chat completions
Copilot AI review requested due to automatic review settings May 11, 2026 11:51

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

Fixes Custom OpenAI/Azure BYOK behavior when a user explicitly configures a deployment URL that already targets the /responses endpoint, ensuring the extension doesn’t advertise/support Chat Completions for that model and thus doesn’t risk producing a Chat Completions-shaped payload for a Responses-only backend.

Changes:

  • Updates Custom OAI BYOK model metadata so URLs containing /responses advertise only the Responses supported endpoint (removing ChatCompletions from the list).

Comment on lines 147 to 152
const modelInfo = resolveModelInfo(model.id, this._name, undefined, modelCapabilities);
if (modelCapabilities?.url?.includes('/responses')) {
modelInfo.supported_endpoints = [
ModelSupportedEndpoint.ChatCompletions,
ModelSupportedEndpoint.Responses
];
}
@alexdima

Copy link
Copy Markdown
Member

Thanks for the contribution! This repository has been archived because the project has moved into the main VS Code repository.

Could you please reopen/recreate this PR against:
https://github.com/microsoft/vscode/tree/main/extensions/copilot

We’ll continue reviewing contributions there. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants