hermes - ✅(Solved) Fix [Feature]: Support GitHub Copilot on GitHub Enterprise Server (GHE) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11442Fetched 2026-04-18 06:01:05
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Root Cause

For GHE Server users, this results in:

  • OAuth login pointing to the wrong host
  • Token exchange returning 401 Bad credentials (because the GHE token is not valid on api.github.com)

Fix Action

Fixed

PR fix notes

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

Description (problem / solution / changelog)

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)

Changed files

  • hermes_cli/auth.py (modified, +22/-0)
  • hermes_cli/copilot_auth.py (modified, +46/-2)
  • hermes_cli/main.py (modified, +5/-2)
  • tests/hermes_cli/test_api_key_providers.py (modified, +18/-0)
  • tests/hermes_cli/test_copilot_auth.py (modified, +44/-0)
RAW_BUFFERClick to expand / collapse

Problem or Use Case

Summary

The current Copilot provider only works with github.com. It does not support GitHub Enterprise Server (GHE) instances where the Copilot token endpoint and proxy are hosted on a custom domain.

Current Behavior

When selecting "GitHub Copilot" via hermes model, the OAuth device code flow always redirects to https://github.com/login/device. The Copilot token endpoint is hardcoded to https://api.github.com/copilot_internal/v2/token.

For GHE Server users, this results in:

  • OAuth login pointing to the wrong host
  • Token exchange returning 401 Bad credentials (because the GHE token is not valid on api.github.com)

Proposed Solution

Add a config option copilot.github_host (default: github.com).

Example config (~/.hermes/config.yaml):

 copilot:
   github_host: "ghe.example.com"

Or via env var: COPILOT_GITHUB_HOST=ghe.example.com

Changes needed:

  1. Auto-detect from ~/.config/github-copilot/apps.json — if a GHE host entry exists, offer it during hermes model setup
  2. OAuth device flow should target https://{github_host}/login/device instead of hardcoded https://github.com/login/device
  3. Token endpoint should use https://{github_host}/api/v3/copilot_internal/v2/token instead of https://api.github.com/copilot_internal/v2/token
  4. Use the endpoints object from the token response dynamically (it returns endpoints.proxy, endpoints.api) instead of hardcoding github.com URLs

Alternatives Considered

Tried using "Enter a token manually" with the GHE OAuth token, but Hermes still calls api.github.com for token exchange, which rejects the GHE token with 401.

Feature Type

Configuration option

Scope

Small (single file, < 50 lines)

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

extent analysis

TL;DR

To fix the issue, add a config option copilot.github_host to allow specifying a custom GitHub host for GitHub Enterprise Server (GHE) instances.

Guidance

  • Introduce a new configuration option copilot.github_host with a default value of github.com to support custom domains.
  • Update the OAuth device flow to target https://{github_host}/login/device instead of the hardcoded https://github.com/login/device.
  • Modify the token endpoint to use https://{github_host}/api/v3/copilot_internal/v2/token and dynamically use the endpoints object from the token response.
  • Consider auto-detecting the GHE host from ~/.config/github-copilot/apps.json during hermes model setup.

Example

copilot:
  github_host: "ghe.example.com"

Alternatively, this can be set via an environment variable: COPILOT_GITHUB_HOST=ghe.example.com.

Notes

This solution assumes that the GHE instance has the same API structure as the main GitHub API. If the GHE API differs, additional modifications may be necessary.

Recommendation

Apply the proposed workaround by adding the copilot.github_host config option to support custom GitHub hosts, as this directly addresses the issue with GHE instances.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING