Skip to content

fix: copilot model not show in /model when copilot provider fallback to gh auth token - #9767

Closed
Marvae wants to merge 1 commit into
NousResearch:mainfrom
Marvae:fix/copilot-gh-auth-model-discovery
Closed

fix: copilot model not show in /model when copilot provider fallback to gh auth token#9767
Marvae wants to merge 1 commit into
NousResearch:mainfrom
Marvae:fix/copilot-gh-auth-model-discovery

Conversation

@Marvae

@Marvae Marvae commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

What changed and why

Fixes #9768

/model (the model picker) calls list_authenticated_providers() to discover which providers have valid credentials. It checks:

  1. Environment variables (COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN)
  2. Hermes auth store (~/.hermes/auth.json)
  3. OAuth credential pool

However, many copilot users authenticate solely through the GitHub CLI (gh auth token). These tokens are resolved dynamically by resolve_copilot_token() in copilot_auth.py and don't exist in any of the three stores above. As a result, copilot does not appear in the /model provider list even when the user is actively using it as their provider.

This affects all /model entry points — CLI (cli.py) and Gateway messaging platforms (gateway/run.py) — since they all call the same list_authenticated_providers() function.

Fix

Seed copilot credentials from resolve_copilot_token() in the credential pool's _seed_from_singletons() (agent/credential_pool.py), alongside the existing anthropic and openai-codex seeding logic. This is the correct architectural layer — the credential pool already handles dynamic credential discovery for other providers — rather than adding a one-off fallback in list_authenticated_providers().

How to test

  1. Ensure no copilot env vars are set: unset COPILOT_GITHUB_TOKEN GH_TOKEN GITHUB_TOKEN
  2. Ensure gh auth token returns a valid token
  3. Set provider: copilot in ~/.hermes/config.yaml
  4. Run hermes and type /model
  5. Before fix: copilot does not appear in the provider list
  6. After fix: copilot appears with its models

Screenshots

Before
Screenshot 2026-04-14 at 23 57 44

After
Screenshot 2026-04-15 at 00 23 08
Screenshot 2026-04-15 at 00 23 16

Automated tests

pytest tests/agent/test_credential_pool.py::test_load_pool_seeds_copilot_via_gh_auth_token tests/agent/test_credential_pool.py::test_load_pool_does_not_seed_copilot_when_no_token -v

Two new tests in tests/agent/test_credential_pool.py:

  • test_load_pool_seeds_copilot_via_gh_auth_token — copilot credentials seeded into pool when resolve_copilot_token() succeeds
  • test_load_pool_does_not_seed_copilot_when_no_token — pool stays empty when no token available

Platform tested

  • macOS (Apple Silicon)

@Marvae Marvae changed the title fix(cli): detect copilot provider via gh auth token in /model picker fix: detect copilot provider via gh auth token in /model picker Apr 14, 2026
@Marvae
Marvae force-pushed the fix/copilot-gh-auth-model-discovery branch 3 times, most recently from 4e9fb42 to 1bd5e75 Compare April 14, 2026 17:03
list_authenticated_providers() checks env vars (COPILOT_GITHUB_TOKEN,
GH_TOKEN, GITHUB_TOKEN), the Hermes auth store, and the OAuth credential
pool to decide which providers have valid credentials.  However, copilot
tokens obtained via `gh auth token` (GitHub CLI) don't live in any of
those places — they are resolved dynamically by resolve_copilot_token().

This affects all /model entry points — CLI (cli.py) and Gateway
messaging platforms (gateway/run.py) — since they all call the same
list_authenticated_providers() function.

Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic.  This is the correct architectural layer —
the credential pool already handles dynamic credential discovery for
other providers — rather than adding a one-off fallback in
list_authenticated_providers().

Add regression tests in tests/agent/test_credential_pool.py:
- copilot seeded when resolve_copilot_token() returns a gh CLI token
- copilot pool empty when resolve_copilot_token() returns nothing
@Marvae
Marvae force-pushed the fix/copilot-gh-auth-model-discovery branch from 1bd5e75 to 5c2c7ba Compare April 14, 2026 17:08
@Marvae Marvae changed the title fix: detect copilot provider via gh auth token in /model picker fix: copilot model not show in /model Apr 14, 2026
@Marvae Marvae changed the title fix: copilot model not show in /model fix: copilot model not show in /model when copilot provider fallback to gh auth token Apr 14, 2026
teknium1 pushed a commit that referenced this pull request Apr 14, 2026
Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic. This makes copilot appear in the /model
provider picker when the user authenticates solely through gh auth token.

Cherry-picked from PR #9767 by Marvae.
teknium1 pushed a commit that referenced this pull request Apr 14, 2026
Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic. This makes copilot appear in the /model
provider picker when the user authenticates solely through gh auth token.

Cherry-picked from PR #9767 by Marvae.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #9810. Your copilot seeding commit was cherry-picked onto current main with your authorship preserved in git log. We also added qwen-oauth seeding for the same gap pattern you identified. Thanks for the clean fix, @Marvae!

@teknium1 teknium1 closed this Apr 14, 2026
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic. This makes copilot appear in the /model
provider picker when the user authenticates solely through gh auth token.

Cherry-picked from PR NousResearch#9767 by Marvae.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic. This makes copilot appear in the /model
provider picker when the user authenticates solely through gh auth token.

Cherry-picked from PR NousResearch#9767 by Marvae.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic. This makes copilot appear in the /model
provider picker when the user authenticates solely through gh auth token.

Cherry-picked from PR NousResearch#9767 by Marvae.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Seed copilot credentials from resolve_copilot_token() in the credential
pool's _seed_from_singletons(), alongside the existing anthropic and
openai-codex seeding logic. This makes copilot appear in the /model
provider picker when the user authenticates solely through gh auth token.

Cherry-picked from PR NousResearch#9767 by Marvae.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot provider missing from /model picker when using gh auth token

2 participants