Skip to content

GitHub Copilot Enterprise works in 1.2.4 but fails in 1.3.0 with 400 Bad Request on GHE chat/completions #18935

@jfernandezj-telpark

Description

@jfernandezj-telpark

Bug

GitHub Copilot Enterprise works for a colleague on OpenCode 1.2.4, but fails for me on OpenCode 1.3.0.

In 1.2.4, the provider appears as a dedicated GitHub Copilot Enterprise provider.
In 1.3.0, it appears as GitHub Copilot -> Enterprise.

This looks like a regression in the provider/auth/model mapping after the provider merge.

Environment

  • OpenCode version: 1.3.0
  • Working comparison version: 1.2.4
  • GitHub Enterprise Copilot endpoint: https://copilot-api.<enterprise-domain>.ghe.com
  • OS: Linux

What happens

Enterprise auth appears to complete far enough that requests are sent to the enterprise Copilot endpoint, but inference fails with:

  • 400 Bad Request
  • URL: https://copilot-api.<enterprise-domain>.ghe.com/chat/completions

Example local error payload:

{
  "message": "Bad Request: Bad Request",
  "statusCode": 400,
  "responseBody": "Bad Request\n",
  "metadata": {
    "url": "https://copilot-api.<enterprise-domain>.ghe.com/chat/completions"
  }
}

Why this looks like a regression

On my machine, historical OpenCode session data shows enterprise requests being sent with raw model IDs like:

  • claude-sonnet-4.6
  • gpt-5.4

But the bundled Copilot model mapping in OpenCode appears to expect Copilot-native model IDs such as:

  • duo-chat-sonnet-4-6
  • duo-chat-gpt-5-mini

So it looks like in 1.3.0 the enterprise flow switches the base URL correctly, but does not fully switch to the Copilot Enterprise-safe model mapping.

Comparison with working setup

A colleague using 1.2.4 is able to use GitHub Copilot Enterprise successfully.

The UX differs:

  • 1.2.4: dedicated GitHub Copilot Enterprise provider
  • 1.3.0: GitHub Copilot -> Enterprise

That makes me suspect the regression happened during or after the provider merge/refactor.

Additional local observations

My current auth state is stored under github-copilot with enterprise mode, rather than a separate enterprise provider.

The failing requests are not 401/403; they are 400, which suggests:

  • enterprise auth/base URL selection is at least partially working
  • the request payload itself is invalid for the enterprise Copilot endpoint

Expected behavior

GitHub Copilot -> Enterprise in 1.3.0 should behave equivalently to the working dedicated GitHub Copilot Enterprise provider in 1.2.4.

Actual behavior

Requests to the GitHub Enterprise Copilot chat endpoint fail with 400 Bad Request.

Possible root cause

A regression in one of:

  • enterprise provider/model mapping
  • enterprise auth state migration
  • request shaping for Copilot Enterprise after merging providers
  • raw model IDs being sent where Copilot-native IDs are required

Related work

I noticed these related changes/issues:

  • #17847 fix: github copilot enterprise integration
  • #14189 fix(opencode): exchange OAuth token for Copilot JWT to fix GitHub Enterprise auth
  • #18782 fix(copilot): add token exchange and editor headers for corporate network compatibility

If helpful, I can provide sanitized local logs/error payloads.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions