Fix GitHub Enterprise authentication in Agent Host - #337722
Conversation
Use the Copilot SDK client authentication path for enterprise hosts so host-aware model discovery and sessions do not fall back to api.github.com. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reconcile short-lived GitHub Enterprise credentials through the Agent Host authentication path before model refresh, then restart the client only after the renewed token arrives. Add renewal and resume-session projection regressions. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Initial one-hour credentials and deferred client restarts can still produce empty catalogs or stale-token requests.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Fixes GitHub Enterprise authentication in Agent Host by moving credentials to the host-aware SDK client and renewing expiring credentials.
Changes:
- Adds client-level enterprise authentication and safe client restarts.
- Adds proactive credential-expiry detection.
- Adds regression tests for discovery, renewal, materialization, and resume flows.
| File | Description |
|---|---|
copilotAgent.ts |
Integrates enterprise client authentication and renewal. |
copilotGitHubCredentials.ts |
Adds refresh detection and client-auth session mode. |
copilotAgent.test.ts |
Covers enterprise authentication workflows. |
copilotGitHubCredentials.test.ts |
Covers expiry and credential modes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Allow one-hour enterprise credentials to complete initial discovery, request renewal inside a bounded 30-minute window, and let deferred client restarts own model refresh so active turns never use a stale client. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Name the regression for the one-hour credential and idle-safe restart guarantees it covers while retriggering checks after an unretryable GitHub Actions startup failure. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat sleep-past-expiry credentials as needing renewal and block new chat creation, cold resume, and turn admission while an authentication-driven client restart waits for existing turns to drain. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Screenshot ChangesBase: Changed (3)2 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details. |
Block new work only while a GitHub Enterprise credential restart drains existing turns. Preserve the previous admission behavior for GitHub.com, proxy, startup configuration, and other ordinary client restarts. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove proactive expiry renewal and new-work restart barriers because expiring GHE credentials only exist in the unreleased Microsoft sign-in flow. Keep client-level GHE auth, idle-safe restart after actual token changes, and create/resume projection coverage. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
71c7ffd
Keep the existing pending-restart behavior unchanged while using the helper result only to defer GHE model refresh until the replacement client starts. Cover active-turn token rotation explicitly. (Written by Copilot) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
left a comment
There was a problem hiding this comment.
Validated the GitHub Enterprise host routing with the real bundled Copilot runtime, reviewed the restart scope, and confirmed all required checks pass. (Written by Copilot)


Summary
COPILOT_GH_HOSTis honoredExpiring GHE credentials are intentionally not handled in this PR. They currently exist only in the unreleased Microsoft-brokered sign-in flow; support can be added with that flow without changing normal Agent Host restart or turn-admission behavior now.
Fixes #337485
Fixes #337562
Fixes #337661
Validation
npm run transpile-clientnpm run test-node -- --grep ...(the runner completed the full node suite: 18,992 passing, 214 pending)npm run typecheck-clientnpm run eslint -- src/vs/platform/agentHost/node/copilot/copilotAgent.ts src/vs/platform/agentHost/node/copilot/copilotGitHubCredentials.ts src/vs/platform/agentHost/test/node/copilotAgent.test.ts src/vs/platform/agentHost/test/node/copilotGitHubCredentials.test.tsgit diff --check(Written by Copilot)