Skip to content

[awf] cli-proxy: classic PAT rejected by /models validation when COPILOT_MODEL is set #1896

@lpcox

Description

@lpcox

Problem

Copilot CLI 1.0.21 introduced a startup model validation step: when COPILOT_MODEL is set in the agent environment, the CLI calls GET /models before executing. This endpoint does not accept classic PATs (ghp_*), causing the agent to fail at startup with exit code 1 — before any useful work begins.

AWF propagates COPILOT_GITHUB_TOKEN into the agent environment and, when the DIFC/CLI proxy is active, routes Copilot API calls through it. AWF currently has no mechanism to detect this failure mode or warn users before it manifests.

Context

Original github/gh-aw issue: github/gh-aw#25593

Affected scope:

  • COPILOT_MODEL is set in the agent environment
  • COPILOT_GITHUB_TOKEN is a classic PAT (ghp_*)
  • Workflows not setting COPILOT_MODEL are unaffected

Introduced in gh-aw v0.67.3 (Copilot CLI 1.0.21). Copilot CLI 1.0.20 did not perform model validation.

Root Cause

In src/docker-manager.ts, AWF injects COPILOT_GITHUB_TOKEN into the agent environment (line ~1506) and, when the API proxy is active, COPILOT_API_URL points to the sidecar. The sidecar forwards calls to the GitHub Copilot API. Classic PATs lack the OAuth scope required by the /models validation endpoint — this is a GitHub API restriction outside AWF's control.

AWF has no pre-flight check for the combination of:

  1. Classic PAT token (detectable by ghp_ prefix)
  2. COPILOT_MODEL being set in the injected environment

Proposed Solution

  1. Early warning in src/cli.ts or src/docker-manager.ts: Before starting containers, detect if COPILOT_MODEL is set alongside a ghp_-prefixed COPILOT_GITHUB_TOKEN. Emit a clear [WARN] message explaining that the /models validation step in Copilot CLI 1.0.21+ rejects classic PATs and the workflow will likely fail.

  2. Document in docs/environment.md: Add a note to the COPILOT_GITHUB_TOKEN section explaining the COPILOT_MODEL + classic PAT incompatibility introduced in Copilot CLI 1.0.21.

  3. Optionally: Investigate whether the CLI proxy's Copilot API forwarding path can intercept the 401 from /models and surface a more actionable error in the AWF logs rather than letting the agent exit silently.

Generated by Firewall Issue Dispatcher · ● 1.4M ·

Metadata

Metadata

Assignees

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