Repository navigation
Description
Summary
When a GITHUB_TOKEN is present in the environment (commonly set for gh / the GitHub MCP, and here injected via Bitwarden Secrets Manager), Hermes auto-registers a copilot credential in the gateway credential pool, pointed at https://api.githubcopilot.com. If that token is a classic ghp_* PAT, the Copilot API rejects every request, so the copilot entry is a permanently-broken fallback that gets tried (and fails) on every failover.
Observed
auth.json credential pool entry, auto-created with no explicit Copilot setup:
"copilot": [
{
"label": "GITHUB_TOKEN",
"auth_type": "api_key",
"source": "env:GITHUB_TOKEN",
"base_url": "https://api.githubcopilot.com",
"secret_source": "bitwarden"
}
]Runtime failures (hermes-agent 0.16.0):
Token from GITHUB_TOKEN is not supported: Classic Personal Access Tokens (ghp_*)
are not supported by the Copilot API. Use one of:
→ `copilot login` or `hermes model` to authenticate via OAuth
→ A fine-grained PAT (github_pat_*) with Copilot Requests permission
→ `gh auth login` with the default device code flow (produces gho_* tokens)
API call failed: BadRequestError [HTTP 400]
Provider: copilot Model: gpt-5.x
Error: Personal Access Tokens are not supported for this endpoint
Impact
- A
GITHUB_TOKENset for unrelated reasons (gh CLI, GitHub MCP) silently enrolls a Copilot provider the user never configured. - On any primary-model failure, failover burns a hop on
copilotand 400s, adding log noise and latency. - Confusing UX: users see
copilot/gpt-5.xbeing attempted and reasonably ask "why is Copilot my fallback?" when they never set it up.
Suggested fix
Any one (or combination) of:
- Don't auto-derive a Copilot credential from classic
ghp_*tokens — only enrollgho_*(device-flow) orgithub_pat_*fine-grained tokens that carry Copilot Requests permission. - Mark the credential unhealthy after the first auth rejection so failover skips it instead of retrying every turn (the error is deterministic, not transient).
- Make Copilot auto-derivation from
GITHUB_TOKENopt-in.
The token-type is already detectable (the error message above distinguishes ghp_* / github_pat_* / gho_*), so this can be gated before the credential is ever added to the pool.
Filed via Claude Code while diagnosing an unexpected copilot/gpt-5.x fallback on hermes-agent 0.16.0.
Activity
alt-glitch commentedon Jun 17, 2026
Related: #12650 (Copilot token validation accepts arbitrary strings) and #35946 (spurious Copilot WARNING when GITHUB_TOKEN is set but Copilot unconfigured). This issue adds a distinct angle: don't auto-derive a Copilot credential from classic ghp_* tokens at all, and mark the credential unhealthy after the first deterministic auth rejection so failover skips it.
Ben-Home commentedon Jun 17, 2026
This is a configuration detection issue -- Hermes sees a GITHUB_TOKEN env var and assumes it's a valid Copilot credential without checking the token type first.
The fix should be a pre-validation step in the credential auto-registration:
Check token prefix before registering: ghp_* (classic PAT) -> skip Copilot registration entirely. github_pat_* (fine-grained) -> check for copilot scope. gho_* (OAuth token) -> check scopes.
Make auto-registration opt-in, not default: The current behavior silently registers a credential that fails 100% of the time for ghp_* tokens. A config flag like auto_register_copilot: false (default) would prevent this entirely. Users who want Copilot can set it to true after verifying their token type.
Validate at registration time, not at call time: A quick GET to the Copilot API user endpoint with the token would catch the classic PAT rejection immediately and log a clear warning instead of silently adding a broken credential to the pool.
The broader issue is that Hermes treats GITHUB_TOKEN as a universal GitHub credential, but Copilot has a completely different auth domain. Environment variable presence does not equal capability availability.
scottymcraig commentedon Jun 18, 2026
Adding the workaround that got this machine unstuck, in case it helps other users or points at the right fix.
In our setup, OAuth would not complete while the existing GitHub token/
gh-derived auth path was visible, because Hermes kept treating that token as the available Copilot credential. The workaround was to temporarily hide the pre-existing GitHub auth source, run the OAuth flow, then restore normal GitHub CLI/git auth afterwards.What worked:
unset/move asideGITHUB_TOKENif it is injected by the shell/secrets manager, and/orghpath/config that Hermes is auto-detecting.hermes model/hermes auth add ..., so it is forced to create a real OAuth credential instead of reusing the PAT-derived one.gh/ the GitHub token source after OAuth succeeds.After doing that here,
gh auth statusshowed the expected logged-in account and git HTTPS operations were wired through!/usr/bin/gh auth git-credential.fix(copilot): don't seed a Copilot pool credential from a classic ghp…
steininger commentedon Jul 24, 2026
Corroborating this issue with a sanitized second-order failure observed on Hermes
v0.18.2.Abstract pool shape:
Failure chain:
Because pool state is persisted, restarting the gateway does not remove this chain. An explicit Copilot auth reset temporarily restores the valid OAuth entry, but the failure recurs when the original model/route error is classified as credential exhaustion.
Recommended acceptance coverage:
ghp_*credentials are never enrolled into the Copilot pool fromGH_TOKEN,GITHUB_TOKEN, orgh auth token;No private repository, account, hostname, or credential data is included here.
GottZ commentedon Aug 3, 2026
Summary
Nineteen PRs address or reference this credential-resolution complex, but only #47718 and #47770 directly fix #47708 by preventing classic
ghp_*tokens from being auto-seeded as Copilot credentials; #20368 touches a separate Copilot pool-resolution path, while the other diffs concern credential discovery, precedence, exhaustion, or profile isolation. #47718 is the best existing fix because it reuses Copilot token validation and tests both rejected and supported token classes, whereas #47770 applies only a prefix guard.Related pull requests
unverified— (+147/-4) — superseded adjacent fix: Added.envlookup and a generic credential-pool fallback for API-key providers, but did not prevent unsupported GitHub tokens from entering the Copilot pool. It remains relevant because its commits were salvaged into fix(auth): resolve API keys from ~/.hermes/.env and credential_pool #16101 with authorship preserved.unverified— (+258/-20) — closed adjacent duplicate: Added another generic pool fallback and ACP project-.envloading, without changing Copilot token admission. It was closed as a duplicate of the fix(auth): resolve API keys from ~/.hermes/.env and credential_pool #15920 work salvaged through fix(auth): resolve API keys from ~/.hermes/.env and credential_pool #16101.unverified— (+233/-4) — merged reference implementation: Landed the.envand healthy-pool fallback for [Bug]: Fallback chain collapses when API key unavailable in os.environ but present in credential_pool #15914/bug(auth): API keys in ~/.hermes/.env not resolved by credential_pool._seed_from_env #15932, establishing adjacent credential-resolution behavior but leaving the unvalidated Copilot environment-seeding path reported in Copilot provider auto-derived from a classicghp_*GITHUB_TOKEN creates a permanently-failing fallback in the credential pool #47708 unchanged.unverified— (+17/-6) — superseded precedence fix: Made.envauthoritative over staleos.environvalues during pool seeding, but did not validate Copilot token types. It remains relevant because its production change was salvaged into fix: prefer ~/.hermes/.env over stale os.environ when seeding credential pool (salvage #18256) #18755.unverified— (+20/-7) — closed precedence alternative: Reversed source precedence globally inget_env_value(), which addresses stale keys rather than classic PAT enrollment. It was closed as superseded by the narrower fix: prefer ~/.hermes/.env over os.environ when seeding credential pool #18256/fix: prefer ~/.hermes/.env over stale os.environ when seeding credential pool (salvage #18256) #18755 implementation.unverified— (+76/-6) — merged adjacent implementation: Landed.env-first pool seeding with regression coverage, fixing stale-environment credentials but not rejectingghp_*values specifically for Copilot.unverified— (+17/-5) — closed test-only cleanup: Updated a stale test for.env-first seeding and made no production change to Copilot admission. The automated close verdict documents that main already removed the stale test in66320de52e9d77c5afc9767a350447011c8577f1and retains replacement coverage attests/agent/test_credential_pool.py:1125from0a6865b328ee6057eb59ee4a150c4886aa72d48c.partial— (+135/-0) — separate partial Copilot fix: Adds a credential-pool fallback for auxiliary Copilot resolution when env andghlookup are empty; it does not stopghp_*credentials from being seeded. Its keep_open review must be addressed separately: the diff treatsget_copilot_api_token()as a scalar despite its token/base-URL tuple contract and loses the pool-derived base URL.unverified— (+65/-15) — superseded rotation fix: Made request-time resolution prefer a freshly rotated.envkey over staleos.environ, not a token-type gate for Copilot. It remains relevant because its substantive fix was rebased, widened, and landed through fix(credentials): prefer ~/.hermes/.env over stale os.environ on key rotation (#20591) #55528 as commit26f39f7b9.unverified— (+81/-2) — closed distinct precedence proposal: Makes a matchingconfig.yamlkey bypass stale pool entries, addressing explicit-config precedence rather than unwanted Copilot enrollment. It was closed voluntarily for the contributor PR limit and remains only unmerged evidence for that separate issue.unverified— (+13/-0) — separate exhaustion fix requiring revision: Reuses a raw pool key whenpeek()returns no available credential, which does not affect how classic GitHub PATs enter the Copilot pool. Its keep_open review blocks the current raw_entriesscan because it can reviveSTATUS_DEADcredentials and lacks exhausted-versus-dead tests.unverified— (+84/-2) — closed exhaustion duplicate: Implements and tests the same raw-entry fallback as fix(auth): return exhausted credential key instead of empty string #40961, unrelated to Copilot provider auto-derived from a classicghp_*GITHUB_TOKEN creates a permanently-failing fallback in the credential pool #47708 token admission. The automated close verdict says current main instead fails closed throughhermes_cli/runtime_provider.py:2010-2023, introduced by8041be795419ee00890bbc6efd075c1459684acd, and then tries configured fallbacks.best fix— (+67/-0) — best existing fix: Validates Copilot environment tokens before pool insertion, rejects classicghp_*PATs, and retains testedgithub_pat_*andgho_*support, directly matching Copilot provider auto-derived from a classicghp_*GITHUB_TOKEN creates a permanently-failing fallback in the credential pool #47708's cause. The automated keep_open review rates this highly salvageable and confirms that current main still mapsGITHUB_TOKENwithout validation while the singleton path already uses the same validator.fixes— (+9/-0) — closed direct duplicate: Adds a literalghp_prefix guard at the same Copilot environment-seeding site, directly fixing the reported cause but without fix(copilot): don't seed a Copilot pool credential from a classic ghp_ GITHUB_TOKEN (#47708) #47718's validator reuse or regression tests. It was closed in favor of the earlier, broader fix(copilot): don't seed a Copilot pool credential from a classic ghp_ GITHUB_TOKEN (#47708) #47718.unverified— (+97/-14) — merged adjacent rotation fix: Extends.env-first live resolution across generic, Anthropic, and Azure Foundry paths, preventing stale-shell-key failures but not unwanted classic-PAT enrollment into Copilot.unverified— (+22/-0) — separate exhaustion duplicate requiring revision: Repeats fix(auth): return exhausted credential key instead of empty string #40961's raw_entriesfallback and does not alter Copilot seeding. Despite its keep_open review, that review identifies the same dead-entry bypass, no regression coverage, and a conflict with the documented cooldown-to-provider-fallback policy.unverified— (+79/-1) — closed profile-isolation partial fix: Scoped direct environment seeding in multiplex mode rather than validating Copilot token types. It was closed as superseded by main commit0583692c2d, while a contributor additionally identified that persisted foreignenv:*rows can remain selectable outside this diff's direct-seeding fix.unverified— (+124/-6) — closed profile-isolation alternative: Routed ordinary seeding through profile-aware secret lookup but retained a reviewed raw-os.environbypass forop://; it does not addressghp_*Copilot admission. It was closed because0583692c2dimplemented the scope-authoritative design and also covered thatop://branch.unverified— (+125/-3) — closed profile-isolation reference: Added scoped and unscoped multiplex regressions, including fail-closedop://handling, without changing Copilot token validation. It was closed after the author verified equivalent behavior on current main1dfe781edd5e96d09511cf27d800a03e63b09789.Duplicates
#47718 and #47770 directly duplicate the #47708 Copilot
ghp_*seed guard; #47718 is canonical because it is earlier, validator-based, and tested. Adjacent duplicate groups are #15920/#15944/#16101, #18256/#18298/#18755, #20602/#55528, #40961/#42475/#57137, and #65945/#66182/#66772 for their respective separate defects.Suggested consolidation
Author action: rebase #47718 onto current main, or split out the part that can merge, preserving the validator-backed guard in
agent/credential_pool.pyand theghp_*,github_pat_*, andgho_*regression cases. This keeps faith with the automated keep_open review on #47718, which confirms the unvalidated environment-ingestion path still exists, while recognizing that #47718 is the best existing fix but is not presently in the eligible lane; keep #47770 closed as its narrower duplicate and handle #20368's auxiliary resolver contract separately.Complex graph
flowchart TD classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937 classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151 classDef best stroke-width:3px,stroke:#b45309 classDef target stroke-width:3px,stroke:#4338ca I15914(["issue NousResearch/hermes-agent#15914 (closed)"]) I15932(["issue NousResearch/hermes-agent#15932 (closed)"]) I18254(["issue NousResearch/hermes-agent#18254 (closed)"]) I21950(["issue NousResearch/hermes-agent#21950 (open)"]) I47708(["issue NousResearch/hermes-agent#47708 (open)"]) P19021["PR NousResearch/hermes-agent#19021 (closed)"] P20368["PR NousResearch/hermes-agent#20368 (open)"] P20602["PR NousResearch/hermes-agent#20602 (closed)"] P21964["PR NousResearch/hermes-agent#21964 (closed)"] subgraph Dup15920 ["PRs duplicating each other"] P15920["PR NousResearch/hermes-agent#15920 (closed)"] P15944["PR NousResearch/hermes-agent#15944 (closed)"] P16101["PR NousResearch/hermes-agent#16101 (merged)"] end subgraph Dup18256 ["PRs duplicating each other"] P18256["PR NousResearch/hermes-agent#18256 (closed)"] P18298["PR NousResearch/hermes-agent#18298 (closed)"] P18755["PR NousResearch/hermes-agent#18755 (merged)"] end subgraph Dup47718 ["PRs duplicating each other"] P47718["PR NousResearch/hermes-agent#47718 (open)"] P47770["PR NousResearch/hermes-agent#47770 (closed)"] end More["+7 more PRs not shown"] MoreI(["+3 more issues not shown"]) P15920 -.->|unverified| I47708 P15944 -.->|unverified| I47708 P16101 -.->|unverified| I47708 P18256 -.->|unverified| I47708 P18298 -.->|unverified| I47708 P18755 -.->|unverified| I47708 P19021 -.->|unverified| I47708 P20368 -.->|partial| I47708 P20602 -.->|unverified| I47708 P21964 -.->|unverified| I47708 P47718 -->|best fix| I47708 P47770 -->|fixes| I47708 P15920 -->|fixes| I15914 P15944 -->|fixes| I15914 P16101 -->|best fix| I15914 P15920 -->|fixes| I15932 P15944 -.->|partial| I15932 P16101 -->|best fix| I15932 P18256 -.->|partial| I18254 P18298 -->|fixes| I18254 P18755 -->|best fix| I18254 P21964 -->|best fix| I21950 class I15914 closed class I15932 closed class I18254 closed class I21950 open class I47708 open class I47708 target class P15920 closed class P15944 closed class P16101 merged class P18256 closed class P18298 closed class P18755 merged class P19021 closed class P20368 open class P20602 closed class P21964 closed class P47718 open class P47770 closed class P16101 best class P16101 best class P18755 best class P21964 best class P47718 best class More closed class MoreI closed click I15914 "https://github.com/NousResearch/hermes-agent/issues/15914" click I15932 "https://github.com/NousResearch/hermes-agent/issues/15932" click I18254 "https://github.com/NousResearch/hermes-agent/issues/18254" click I21950 "https://github.com/NousResearch/hermes-agent/issues/21950" click I47708 "https://github.com/NousResearch/hermes-agent/issues/47708" click P15920 "https://github.com/NousResearch/hermes-agent/pull/15920" click P15944 "https://github.com/NousResearch/hermes-agent/pull/15944" click P16101 "https://github.com/NousResearch/hermes-agent/pull/16101" click P18256 "https://github.com/NousResearch/hermes-agent/pull/18256" click P18298 "https://github.com/NousResearch/hermes-agent/pull/18298" click P18755 "https://github.com/NousResearch/hermes-agent/pull/18755" click P19021 "https://github.com/NousResearch/hermes-agent/pull/19021" click P20368 "https://github.com/NousResearch/hermes-agent/pull/20368" click P20602 "https://github.com/NousResearch/hermes-agent/pull/20602" click P21964 "https://github.com/NousResearch/hermes-agent/pull/21964" click P47718 "https://github.com/NousResearch/hermes-agent/pull/47718" click P47770 "https://github.com/NousResearch/hermes-agent/pull/47770"Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).
Cross-PR triage: Reviewed 19 pull requests and 8 issues in this complex. Each diff was read against this issue; Assessment working set: 108 kB of PR diffs, 55 kB of issue/PR text, 40 kB of discussion (58 comments), 37 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
wang25669 commentedon Aug 8, 2026
Real-world reproduction confirming this issue. Environment: Hermes Agent v0.20.0 (2026.8.3), Linux, install method git.
Setup:
.envcontainsGITHUB_TOKEN=ghp_*(classic PAT, 40 chars,public_reposcope) — used for skills-hub / GitHub API rate limitsCOPILOT_GITHUB_TOKENorGH_TOKENsetcopilot-providerandmodel-providers/copilotare inplugins.disabledSymptoms:
/modelpicker still lists GitHub Copilot with a full model catalog (GPT-5.x, Claude, Gemini, etc.)checking third-party user token: bad request: Personal Access Tokens are not supported for this endpointhermes auth listshowscopilot (1 credentials): GITHUB_TOKEN api_key env:GITHUB_TOKEN— the classic PAT was auto-seeded into the copilot credential pool even though the copilot plugin is disabledRoot cause confirmed via source:
list_authenticated_providers()(hermes_cli/model_switch.py) never checksplugins.enabled— it only checks env var presence / credential pool / auth storeenv:GITHUB_TOKENbecause the copilot profile'senv_varsincludesGITHUB_TOKENas a third-priority candidateghp_*PATs are explicitly "not supported" for the Copilot API — so this auto-derivation always produces a permanently-failing credentialThis is exactly the "auto-derive from classic ghp_* token" case described here. The picker shows a provider that can never work for free-GitHub-account users who only set GITHUB_TOKEN for skills-hub.
sprd-tmu commentedon Oct 4, 2026
Corroboration:
github_pat_*(fine-grained) fails identically — the admission gate is too narrowSecond-order failure on current
main(installed checkoutea81748579, Linux), Copilot Business plan. This extends the issue's scope: the suggested fix and the open PRs (#47718, #47770) only reject classicghp_*, but fine-grained PATs are rejected by the chat endpoint too, and they passvalidate_copilot_token()becausegithub_pat_is in_SUPPORTED_PREFIXES.Failure chain (each step verified live)
COPILOT_GITHUB_TOKENandGITHUB_TOKENin~/.hermes/.envheld the same fine-grained PAT (github_pat_…, len 93) — identicalsecret_fingerprinton bothcredential_pool.copilotentries inauth.json, so pool priority was moot.validate_copilot_token()accepts it (github_pat_is a supported prefix) → credential is enrolled.GET api.github.com/copilot_internal/v2/tokenwithAuthorization: token github_pat_…→ HTTP 404 (PATs cannot exchange).get_copilot_api_token()(hermes_cli/copilot_auth.py:489-499) silently falls back to the raw PAT;base_urlstays on the generichttps://api.githubcopilot.cominstead of the account's real host.api.business.githubcopilot.com, discovered viaGET /copilot_internal/user→copilot_plan: business,endpoints.api), so no host choice rescues a PAT.Why the current advice in the error string is misleading
validate_copilot_token()'s rejection message tells users to use "A fine-grained PAT (github_pat_*) with Copilot Requests permission" — but step 5 shows the chat endpoint rejects PATs categorically ("checking third-party user token"), regardless of type or permissions. The only credential class that works end-to-end is an OAuth token that exchanges (device-flowghu_via theIv1.b507a08c87ecfe98client id →tid=…API token, HTTP 200, chat 200).Suggested acceptance-criteria additions
ghp_*andgithub_pat_*) as non-exchangeable for the chat path: either don't enroll them as copilot credentials, or enroll with a hard "exchange required" flag so the raw-token fallback inget_copilot_api_token()cannot send them to/chat/completions.validate_copilot_token()to stop recommending fine-grained PATs for Copilot API use.Resolution that worked here (no source patch)
Device-code OAuth login with Hermes' shipped client id →
ghu_token inCOPILOT_GITHUB_TOKEN, removed the pool entries, restarted (process env is loaded at startup andos.environbeats.envinresolve_copilot_token()). Exchange then returned 200 withendpoints.api=https://api.business.githubcopilot.comand chat completed 200. Side effect worth noting: while the exchange was failing, the model picker silently served the stale curated list (see NousResearch/hermes-labs-plugins#49) — the plan's real catalog (e.g.claude-sonnet-5.5) only appeared after auth was fixed, which made the broken state harder to diagnose.No credentials, org names, or hostnames included; token values reduced to prefix/length/fingerprint only.
teknium1 commentedon Oct 26, 2026
Closing as fixed by the move. GitHub Copilot moved out of core into the
github-copilotHermes Labs plugin in #144788 (0591b66).Thanks @tcconnally for the detailed
auth.jsonevidence.ghp_*GITHUB_TOKENbecoming a permanently failingcopilotpool row.ghp_included (credentials.py#L41-L70), so its seeder returns no row; core's generic env loop does not seed a provider whose profile seeds itself (credential_pool.py#L2635-L2661). A home that doesn't use Copilot doesn't load the plugin at all.If you still see this with the github-copilot plugin installed (
hermes plugins list), open an issue on NousResearch/hermes-labs-plugins.