Repository navigation
Fix Copilot token integration identity - #80074
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. for source-level reproduction: current main exchanges the Copilot token without Real behavior proof Next step before merge Security Review detailsBest possible solution: Land this PR or an equivalent canonical fix after redacted live Copilot request proof, preserving the shared identity constant, legacy-cache invalidation, and regression tests while superseding the older header-only duplicate PR. Do we have a high-confidence way to reproduce the issue? Yes for source-level reproduction: current main exchanges the Copilot token without Is this the best way to solve the issue? Yes: aligning the token exchange identity and invalidating legacy cached tokens is the narrow maintainable fix for the reported mismatch. The code direction is stronger than the older header-only duplicate, but it still needs live endpoint proof before merge. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 7458f41e7009. |
cfe6289 to
5ece4dc
Compare
5ece4dc to
0ef1a59
Compare
8c73b91 to
3b9e299
Compare
|
Landed via rebase onto current
Thanks @TurboTheTurtle! |
Summary
Copilot-Integration-Id: vscode-chatduring the GitHub Copilot/copilot_internal/v2/tokenexchange, matching the identity used by downstream Copilot runtime requests.checks-node-agentic-clishard.Fixes #79946.
Root Cause
Runtime Copilot model requests identified as
vscode-chat, but the token exchange that minted the short-lived Copilot API token only sent IDE headers. Tokens minted under the fallback/default identity could then be scoped ascopilot-language-server, so later image-capable model requests still failed even though the runtime request headers containedCopilot-Integration-Id: vscode-chat.Real Behavior Proof
Behavior or issue addressed: Copilot API tokens are now fetched with the same
vscode-chatintegration identity as runtime Copilot requests, and older cached tokens missing that identity are not reused.Real environment tested: Local OpenClaw source checkout at
/Users/andy/openclaw-79946on macOS, using the repo's Copilot token exchange and provider tests with mocked token endpoint responses.Exact steps or command run after this patch:
Evidence after fix:
The new token regression verifies the exchange request includes
Copilot-Integration-Id: vscode-chat. A second regression seeds a still-valid legacy cached token without that identity and verifies OpenClaw ignores it, fetches a fresh token, and storesintegrationId: "vscode-chat"with the new cache payload. After the first CI run, the full CLI shard failure was reproduced locally withsrc/cli/channel-auth.test.tsandsrc/cli/plugins-cli.policy.test.ts; those stale expectations now match the existing shared formatter output and pass with the Copilot tests.Observed result after fix: The token-minting path and runtime request path now use one shared integration id, preventing a valid-but-wrongly-scoped cached token from continuing to route image-capable Copilot requests under the
copilot-language-serveridentity. The previously failing CLI shard assertions now match the actual user-facing command-hint formatting.What was not tested: I did not have live GitHub Copilot credentials for a redacted
github-copilot/gemini-3.1-pro-previewimage-tool request in this session, so live endpoint entitlement validation was not captured.Validation
pnpm test src/agents/github-copilot-token.test.ts extensions/github-copilot/models.test.ts src/plugin-sdk/provider-stream-shared.test.ts extensions/github-copilot/index.test.ts src/agents/pi-hooks/compaction-safeguard.test.ts src/cli/channel-auth.test.ts src/cli/plugins-cli.policy.test.tspnpm exec oxfmt --check --threads=1 src/plugin-sdk/provider-auth.ts src/agents/copilot-dynamic-headers.ts src/agents/github-copilot-token.test.ts extensions/github-copilot/models.test.ts CHANGELOG.md src/cli/channel-auth.test.ts src/cli/plugins-cli.policy.test.tsgit diff --check upstream/mainpnpm check:changed --base upstream/main