Skip to content

fix(copilot): support GitHub Enterprise host for auth and base URL#11527

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

fix(copilot): support GitHub Enterprise host for auth and base URL#11527
dwc1997 wants to merge 1 commit into
NousResearch:mainfrom
dwc1997:fix/copilot-ghe-host-support

Conversation

@dwc1997

@dwc1997 dwc1997 commented Apr 17, 2026

Copy link
Copy Markdown

What does this PR do?

This PR adds GitHub Enterprise Server (GHE) host support for the copilot provider flow.
Specifically, it makes Copilot auth/runtime host-aware by resolving a GitHub host from:

  1. COPILOT_GH_HOST env var
  2. config.yaml -> copilot.github_host
  3. fallback: github.com
    Then it applies that host in two places:
  • Device code login flow (OAuth device endpoints)
  • gh auth token lookup (--hostname <host> for GHE)
    In addition, when COPILOT_API_BASE_URL is not explicitly set, Copilot runtime base URL is auto-derived for GHE as:
    https://<host>/api/v3/copilot_internal
    This keeps existing default behavior unchanged for github.com, while enabling out-of-the-box GHE support.

Related Issue

Fixes #11442

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Updated hermes_cli/copilot_auth.py:
    • added resolve_copilot_github_host() with env+config fallback chain
    • normalized host parsing for URL/plain host forms
    • updated gh auth token flow to pass --hostname for non-default hosts
  • Updated hermes_cli/main.py:
    • Copilot device login now uses resolved GitHub host
  • Updated hermes_cli/auth.py:
    • added _resolve_copilot_base_url() for GHE base URL derivation
    • integrated this resolver into resolve_api_key_provider_credentials("copilot")
  • Added regression tests:
    • tests/hermes_cli/test_copilot_auth.py
    • tests/hermes_cli/test_api_key_providers.py

How to Test

  1. Set a GHE host via env or config:
    • env: export COPILOT_GH_HOST=ghe.example.com
    • or config:
      copilot:
        github_host: ghe.example.com
  2. Run Copilot model setup/login flow and verify device login uses the GHE host.
  3. Verify resolved copilot base URL becomes:
    • https://ghe.example.com/api/v3/copilot_internal
      when COPILOT_API_BASE_URL is unset.
  4. Confirm explicit override still wins:
    • COPILOT_API_BASE_URL=https://proxy.example/copilot

Screenshots / Logs

N/A (auth/runtime routing + tests)

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard provider/copilot GitHub Copilot (ACP + Chat) area/auth Authentication, OAuth, credential pools labels Apr 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps with #6468 (full GHE Copilot support PR). Maintainers should compare scope — this PR is narrower (host resolution + base URL), #6468 is broader (auth modes, env vars).

@dwc1997 dwc1997 closed this Apr 29, 2026
@dwc1997 dwc1997 reopened this May 1, 2026
Resolve Copilot GitHub host from COPILOT_GH_HOST or config.yaml copilot.github_host, apply it to device login and gh token lookup, and derive a GHES Copilot base URL when no explicit COPILOT_API_BASE_URL is set.
@dwc1997 dwc1997 force-pushed the fix/copilot-ghe-host-support branch from 047fbb0 to 1481be6 Compare May 1, 2026 03:36
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 comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/copilot GitHub Copilot (ACP + Chat) 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)

2 participants