Skip to content

github-copilot plugin: provider.options.headers from config are not sent on the models() request #23816

Closed

Description

@Nepomuceno

Summary

The github-copilot provider plugin ignores user-configured headers (provider.github-copilot.options.headers in opencode.json) when it fetches the list of available models. The same headers are honoured for chat requests via the plugin's fetch wrapper, so the behaviour is inconsistent.

Where

packages/opencode/src/plugin/github-copilot/copilot.ts, the provider.models() hook constructs its header map from scratch and does not read provider.options.headers:

async models(provider, ctx) {
  // ...
  return CopilotModels.get(
    base(auth.enterpriseUrl),
    {
      Authorization: `Bearer ${auth.refresh}`,
      "User-Agent": `opencode/${InstallationVersion}`,
    },
    provider.models,
  )
}

By contrast, the auth.loader().fetch path does spread init.headers into the outgoing request, so config headers reach chat calls.

Why this matters

Users who configure extra headers in opencode.json reasonably expect those headers to apply to all requests the provider makes, including the model discovery call. Today they only apply to chat. This makes the model list returned by opencode models github-copilot (and the model picker) inconsistent with the model set actually reachable on chat requests, depending on what the user sets.

Reproduction

  1. In ~/.config/opencode/opencode.json:
{
  "provider": {
    "github-copilot": {
      "options": {
        "headers": {
          "X-Test-Header": "from-config"
        }
      }
    }
  }
}
  1. Run opencode models github-copilot.
  2. Capture the outgoing request to https://api.githubcopilot.com/models (e.g. via a proxy). The X-Test-Header is not present.
  3. Start a chat with any github-copilot model. The same X-Test-Header is present on the completion request.

Expected

User-configured headers on the github-copilot provider should be sent on every request the plugin makes, including the models discovery call.

Proposed fix

Spread provider.options.headers into the headers object passed to CopilotModels.get(...) in the models() hook, while still letting the plugin set Authorization and User-Agent (so they cannot be accidentally unset).

A PR with this minimal change will be opened.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 22, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions