Repository navigation
fix(github-copilot): accept fine-grained access tokens - #114282
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 27, 2026, 11:30 PM ET / July 28, 2026, 03:30 UTC. ClawSweeper reviewWhat this changesThe branch replaces GitHub Copilot’s retired exchanged-token runtime path with validation of the original GitHub credential, endpoint resolution from Copilot’s user contract, and provider-owned Merge readinessKeep this PR open for maintainer review. It has strong real-provider proof and no concrete patch defect in the reviewed material, but it deliberately changes the Copilot request identity and credential path; the author explicitly could not verify GitHub Enterprise tenant policy behavior, so landing that compatibility-sensitive change needs an owner decision rather than an automatic close or merge verdict. Priority: P1 Review scores
Verification
How this fits togetherThe GitHub Copilot plugin obtains a GitHub credential and prepares runtime auth for OpenClaw’s generic provider pipeline. Agent, compaction, embedding, and image runtimes consume that prepared auth to send Copilot API requests without core code owning Copilot-specific headers or token-exchange policy. flowchart LR
Credential[GitHub credential] --> Plugin[GitHub Copilot plugin]
Plugin --> Validation[Copilot account validation]
Validation --> Prepared[Prepared auth and endpoint]
Prepared --> Agent[Agent and compaction runtime]
Prepared --> Media[Embedding and image runtime]
Agent --> Copilot[Copilot API]
Media --> Copilot
Decision needed
Why: The code and public-account proof support the new contract, but enterprise authorization and allow-list policy can be controlled outside OpenClaw and was not exercised by the supplied evidence. Before merge
Agent review detailsSecurityNone. PR surfaceSource -141, Tests +32, Docs 0, Generated 0. Total -109 across 33 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Copilot request identity and credential handling owned by the Copilot plugin, then merge only after the responsible owner accepts the Enterprise-policy uncertainty or obtains a representative enterprise validation result. Do we have a high-confidence way to reproduce the issue? Yes for the reported fine-grained-token failure: the PR identifies the retired exchange as the rejecting path and provides a live provider run where source-credential validation reaches a streamed response. Enterprise tenant policy behavior is not reproduced or verified. Is this the best way to solve the issue? Yes for the main design direction: moving Copilot-specific validation and request identity into the Copilot plugin avoids duplicate core policy and preserves generic prepared-auth consumption. The remaining question is rollout confidence for enterprise identity policy, not a better competing implementation shape. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7653bcce58b3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
OAuth upgrade-policy follow-up at head dd785104e1cf30868e09745118b73a2ec9a4a555:
Relevant ownership and regression points: src/llm/utils/oauth/github-copilot.ts:572, src/agents/auth-profiles/oauth-manager.ts:621, src/agents/sessions/auth-storage.ts:736, src/agents/auth-profiles/oauth.openai-codex-refresh-fallback.test.ts:226, src/llm/utils/oauth/github-copilot.test.ts:305. |
dd78510 to
9e38cc1
Compare
Related: #108738
What Problem This Solves
Fixes an issue where GitHub Copilot users authenticating with a fine-grained PAT could not use OpenClaw because its retired short-lived token exchange rejected the otherwise valid credential before any model request was attempted.
Why This Change Was Made
OpenClaw now validates the original GitHub credential through Copilot's current
/copilot_internal/usercontract, uses the returned trusted API endpoint, and keeps the source credential for runtime requests as required by the current Copilot SDK. Runtime traffic identifies ascopilot-developer-cli; the legacy device-login exchange remains narrowly unchanged. Custom embeddings endpoints continue to require their own explicit API key and never receive the stored GitHub credential.This is the provider-auth prerequisite for the post-#108738 pure-inference work; it is intentionally separated because the auth path is shared by streaming, catalogs, embeddings, usage, media, and caching.
User Impact
GitHub Copilot users can use supported PAT/OAuth credentials across OpenClaw's existing Copilot runtime surfaces, including fine-grained PATs that the old exchange rejected.
Evidence
Source-credential live proof (prior exact head)
Commit
69ad007387685a0726403c86a8ddc1e0a0cd937ewas exercised with a fine-grained GitHub PAT injected from a scoped secret provider. The credential was not logged. The real provider runtime authenticated, fetched the catalog, and streamed a model response:Existing-profile upgrade proof
The candidate tree that became the exact head was tested with a real device-login OAuth profile in both relevant persisted states. The only subsequent source change was formatting the same provider formatter expression; exact-head focused tests and the PAT live proof above followed it.
{ "unexpiredLegacyProfile": { "agentTurn": "passed", "sourceCredentialPreserved": true, "accessChanged": false, "expiryAdvanced": false }, "forcedExpiredLegacyProfile": { "agentTurn": "passed", "sourceCredentialPreserved": true, "accessChanged": true, "expiryAdvanced": true }, "postMatrixRuntimeAuth": true, "postMatrixLegacyRefresh": true }This proves an existing unexpired profile remains usable without needless refresh, while an expired profile refreshes normally without replacing or expiring its durable source credential.
Integration-identity sibling-surface proof
The same live credential was tested under both the prior
vscode-chatand proposedcopilot-developer-cliidentities:gpt-5.4-minimodel passed under both identitiesgpt-5.4andgpt-5.4-minipassed under both identitiesNo tested sibling surface lost authorization or model availability. Enterprise policy behavior remains untested because no enterprise credential was available. A high-level local media harness stalled before issuing a provider request; direct production vision requests passed under both identities, isolating that harness issue from the identity change.
Provider-owned request identity proof (current exact head)
Current head
d673267fbf71e24d0e031c2f4a6d3b8b616ae4d8contains provider-identity implementation commit1005f522325046a2dbc2670a4d7d87711b63ed5c, which removes the second core-owned Copilot runtime identity and routes core callers through the existing generic provider-prepared auth/header contract. The follow-up commit refreshes the generated SDK hash after the removed core import changes TypeScript declaration alias selection; no SDK export or underlying type changes.Live OpenClaw agent turns using the pushed implementation completed against all three affected Copilot transports:
gpt-5.4claude-sonnet-4.5gemini-2.5-proA direct production vision request with a valid PNG and
gpt-5.4also returned HTTP 200 with non-empty output. The high-level local media harness still stalls before its first provider fetch; focused tests prove prepared headers are applied and sentinel-unwrapped at final media egress, while the direct vision proof isolates the remaining harness stall from Copilot auth or identity.Expired legacy-profile upgrade proof
The current head removes the hidden dependency on the retired token exchange for existing OAuth profiles whose legacy Copilot access token has expired. The stored
refreshfield remains the durable GitHub credential; provider refresh now returns that unchanged bundle, and both OAuth managers avoid rewriting unchanged state.A real expired OAuth profile was created with the same fine-grained PAT previously rejected by
/copilot_internal/v2/token. A local OpenClaw agent turn authenticated through the new runtime path and completed agpt-5.4Responses request with HTTP 200 and the exact marker. The persisted profile retained its original expired access token, expiry, and durable source credential. The matching unexpired-profile control also completed with HTTP 200 and remained unchanged.Automated verification
git diff --check, andplugin-sdk:api:checkpassed.AI-assisted: yes. I understand the implementation and validated it against the installed Copilot SDK source/types, official behavior, upgrade states, and live provider traffic.