Skip to content

fix(copilot): support GitHub Enterprise endpoints - #78378

Open
adamkrawczyk wants to merge 1 commit into
NousResearch:mainfrom
adamkrawczyk:fix/copilot-ghe-support
Open

fix(copilot): support GitHub Enterprise endpoints#78378
adamkrawczyk wants to merge 1 commit into
NousResearch:mainfrom
adamkrawczyk:fix/copilot-ghe-support

Conversation

@adamkrawczyk

Copy link
Copy Markdown

Summary

  • Route Copilot OAuth, GitHub CLI token lookup, and token exchange through COPILOT_GH_HOST.
  • Route inference, model discovery, credential refresh, and auxiliary clients through explicit or exchange-discovered enterprise endpoints.
  • Centralize Copilot endpoint classification while preserving all public GitHub defaults.
  • Document the enterprise configuration variables and cover the behavior with regression tests.

Closes #11442.

Prior work

This builds on the GitHub Enterprise support proposed by @HearthCore in #6468 and adapts it to the current provider, credential-pool, model-catalog, Responses API, and auxiliary-client architecture.

Configuration

COPILOT_GH_HOST=ghe.example.com
COPILOT_API_BASE_URL=https://copilot-api.ghe.example.com

COPILOT_GH_HOST controls OAuth, gh auth token --hostname, and token exchange. COPILOT_API_BASE_URL is authoritative for inference and model-catalog routing. When unset, token-exchange endpoint metadata is used before the public fallback.

Test plan

  • Added regression coverage for enterprise OAuth, token exchange, endpoint precedence, catalog routing, refresh behavior, Responses mode, auxiliary clients, and Copilot headers.
  • Ran the affected test set: 504 passed.
  • Ran Ruff on all changed Python files.
  • Verified an end-to-end request against a GitHub Enterprise Copilot deployment.

Risk assessment

Low. Public GitHub URLs remain the defaults when enterprise variables are unset. Endpoint matching uses parsed hostnames rather than substring matching, and catalog caches include endpoint identity to avoid cross-account reuse.

Route OAuth, token exchange, model discovery, inference, refresh, and auxiliary clients through configured or exchange-discovered enterprise endpoints while preserving public GitHub defaults.

Builds on the enterprise support proposed by @HearthCore in NousResearch#6468.

Refs NousResearch#11442

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 4, 2026 09:44

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard provider/copilot GitHub Copilot (ACP + Chat) area/auth Authentication, OAuth, credential pools area/config Config system, migrations, profiles sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Aug 4, 2026
@arminanton

Copy link
Copy Markdown
Contributor

This is valuable — enterprise-endpoint support has been a real gap. One data point from running a plan-scoped (business) account that might help harden the resolver:

The token-exchange discovery path (POST /copilot_internal/v2/tokenendpoints.api) returns 403 Forbidden on some accounts, even where Copilot itself works fine. On those same accounts GET /copilot_internal/user returns 200 and carries both copilot_plan and endpoints.api (business → api.business.githubcopilot.com, enterprise → api.enterprise.githubcopilot.com). This looks like the same class as #30624 (picker falls back to a stale list when the token exchange fails but /models is reachable).

Suggestion: try the exchange first (your current path, correct for enterprise-exchange accounts), then fall back to /copilot_internal/user when the exchange 403s — that covers both account shapes. Happy to share the exact resolver shape if useful. Also worth noting one endpoint that must stay pinned: the auto-mode session control-plane (/models/session, /models/session/intent) returns 421 Misdirected Request on the business host, so those specific calls need to stay on api.githubcopilot.com even when inference is routed to the plan host.

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

Labels

area/auth Authentication, OAuth, credential pools area/config Config system, migrations, profiles comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/copilot GitHub Copilot (ACP + Chat) sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support GitHub Copilot on GitHub Enterprise Server (GHE)

4 participants