Skip to content

[awf] API Proxy / Agent: Copilot CLI 1.0.21 model validation fails with classic PAT when COPILOT_MODEL is set #1929

@lpcox

Description

@lpcox

Problem

Copilot CLI 1.0.21 introduced a startup model validation step: when COPILOT_MODEL is set, the CLI calls GET /models before executing. This endpoint rejects classic PATs (ghp_*), causing the workflow to fail with exit code 1 immediately on startup.

Workflows that do not set COPILOT_MODEL are unaffected (default model path skips validation).

Context

Root Cause

In src/docker-manager.ts, COPILOT_MODEL is not in EXCLUDED_ENV_VARS and passes freely through --env-all. When the api-proxy is enabled, COPILOT_GITHUB_TOKEN is replaced with a placeholder for credential isolation (line 651), and the real token is forwarded via the api-proxy sidecar. However, the /models endpoint validation by Copilot CLI 1.0.21 is hit before any proxy interception — it uses whichever COPILOT_GITHUB_TOKEN value is present in the agent environment at startup.

Additionally, the containers/api-proxy/server.js does not proxy the /models endpoint, so even with the api-proxy active, the model validation call may escape to the raw GitHub API using the placeholder token.

Proposed Solution

  1. Short-term: In src/docker-manager.ts, when --enable-api-proxy is active, add /models to the api-proxy routing table in containers/api-proxy/server.js (Copilot listener, port 10002) so model validation calls are handled by the sidecar with a valid token.

  2. Medium-term: Add a warning in AWF CLI (src/cli.ts) when COPILOT_MODEL is set and the token is a classic PAT — advise upgrading to a fine-grained token or OAuth token.

  3. Documentation: Update docs/environment.md to note that COPILOT_MODEL requires a non-classic-PAT token when using Copilot CLI ≥ 1.0.21.

Generated by Firewall Issue Dispatcher · ● 1.6M ·

Metadata

Metadata

Assignees

Labels

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