Skip to content

[Bug]: Copilot provider uses hardcoded context windows and lacks token exchange — breaks account-specific models and enterprise endpoints #7731

@difujia

Description

@difujia

Bug Description

The Copilot provider has several interrelated issues that prevent it from working correctly with account-specific models (e.g. claude-opus-4.6-1m with 1M context) and enterprise Copilot subscriptions.

Problems

  1. Hardcoded context windows from models.dev: The context window resolution for Copilot models falls back to static models.dev data, which does not reflect per-account model availability. For example, claude-opus-4.6-1m (available on some Copilot plans) reports an incorrect context window because models.dev does not list it.

  2. No token exchange: Raw GitHub tokens (ghu_* from device flow) are sent directly to the Copilot API. However, accessing the full model catalog (including internal-only models) requires exchanging these tokens for Copilot API JWTs via the /copilot_internal/v2/token endpoint — the same flow used by VS Code, Copilot CLI, and other first-party clients.

  3. Wrong OAuth Client ID: The current OAuth client ID limits the visible model catalog. VS Code's client ID (Iv1.b507a08c87ecfe98) exposes the full set of models available to the account, including preview and internal-only models.

  4. No enterprise endpoint support: The Copilot base URL is always hardcoded to api.githubcopilot.com. Enterprise Copilot users whose traffic should route through a different endpoint (derivable from the proxy-ep field in the exchanged JWT) cannot use the provider at all. Related: [Feature]: Add support for Github Copilot though Github Enterprise subscription #6455

Expected Behavior

  • Context windows should reflect the actual values from the Copilot /models API for the authenticated account
  • Token exchange should happen transparently so internal-only models are accessible
  • The OAuth client ID should match VS Code's to expose the full model catalog
  • Enterprise Copilot endpoints should be derived automatically from the exchanged token

Steps to Reproduce

  1. Set up Copilot provider via hermes setup
  2. Switch to an account-specific model like claude-opus-4.6-1m using /model
  3. Observe: model may not appear in the catalog, or if manually set, reports wrong context window (128K instead of 1M)
  4. For enterprise users: API calls fail because the wrong base URL is used

Environment

  • Hermes Agent v0.8.0
  • Ubuntu 24.04
  • GitHub Copilot Individual plan (also affects Business/Enterprise)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/cliCLI entry point, hermes_cli/, setup wizardprovider/copilotGitHub Copilot (ACP + Chat)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions