Skip to content

GITHUB_TOKEN env var incorrectly triggers GitHub Copilot model availability #4485

@Haohui-W

Description

@Haohui-W

What happened?

Description

Setting the common GITHUB_TOKEN environment variable (used by gh CLI, git, CI/CD) causes pi to list all GitHub Copilot models as
"available" in /model and --list-models, even though a standard GitHub PAT cannot authenticate with the Copilot API.

Steps to reproduce

  1. Set GITHUB_TOKEN to any GitHub personal access token:
export GITHUB_TOKEN=github_pat_xxx
  1. Run pi --list-models
  2. Observe that 26 GitHub Copilot models are listed alongside the actually-configured providers

Expected behavior

GITHUB_TOKEN / GH_TOKEN are generic GitHub API tokens used by many developer tools. They should not be treated as valid Copilot
credentials. Only COPILOT_GITHUB_TOKEN (or OAuth login via /login) should unlock Copilot models.

Root cause

In env-api-keys.ts, the github-copilot provider checks three env vars:

  if (provider === "github-copilot") {
      return ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"];
  }

This feeds into AuthStorage.hasAuth() → ModelRegistry.getAvailable() → all 26 Copilot models appear, but they don't actually work when
selected.

Context

  • pi version: 0.74.0
  • OS: Windows (but reproducible on any OS)
  • Many developers have GITHUB_TOKEN set globally for gh CLI, not for Copilot.

Suggested fix

Remove GH_TOKEN and GITHUB_TOKEN from the github-copilot env var list, keeping only COPILOT_GITHUB_TOKEN. Or at minimum, validate the
token against the Copilot API before listing models.

Steps to reproduce

  1. Set GITHUB_TOKEN to any GitHub personal access token:
export GITHUB_TOKEN=github_pat_xxx
  1. Run pi --list-models
  2. Observe that 26 GitHub Copilot models are listed alongside the actually-configured providers

Expected behavior

No response

Version

v0.74.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclosed-because-refactorClosed while the project refactor is in progressinprogressIssue is being worked on

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions