Skip to content

Fix GitHub Enterprise authentication in Agent Host - #337722

Merged
roblourens merged 8 commits into
mainfrom
copilot/fix-ghe-agent-auth
Sep 24, 2026
Merged

roblourens merged 8 commits into
mainfrom
copilot/fix-ghe-agent-auth

Conversation

Copilot AI commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • authenticate the Copilot SDK client directly for GitHub Enterprise hosts so COPILOT_GH_HOST is honored
  • use that host-aware client identity for model discovery, session creation, and session resume
  • restart the enterprise client safely after an actual credential update while preserving GitHub.com per-request and session-level authentication behavior
  • keep client restart idle-safe so an active turn is not terminated
  • add regression coverage for enterprise model discovery, token changes, session materialization, resume-session credential projection, and credential modes

Expiring 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-client
  • focused Agent Host authentication regressions through npm run test-node -- --grep ... (the runner completed the full node suite: 18,992 passing, 214 pending)
  • npm run typecheck-client
  • npm 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.ts
  • git diff --check
  • pre-commit hygiene on the changed files

(Written by Copilot)

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>
Copilot AI requested a balanced review from Copilot and removed request for Copilot September 24, 2026 15:07
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>
Copilot AI requested a balanced review from Copilot and removed request for Copilot September 24, 2026 17:24
@roblourens
roblourens marked this pull request as ready for review September 24, 2026 18:22
Copilot AI balanced review requested due to automatic review settings September 24, 2026 18:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 High severity · 1 Medium severity

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.

Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts Outdated
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgent.ts Outdated
@roblourens
roblourens marked this pull request as draft September 24, 2026 18:30
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>
@roblourens
roblourens marked this pull request as ready for review September 24, 2026 18:36
@roblourens
roblourens marked this pull request as draft September 24, 2026 18:37
@roblourens
roblourens marked this pull request as ready for review September 24, 2026 18:37
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>
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: a6e06b50 Current: f001d4bf

Changed (3)

chat/scrollAnchoring/chatScrollAnchoring/CompletedVisibleHeader/Dark
Before After
before after
chat/scrollAnchoring/chatScrollAnchoring/CompletedVisibleHeader/Light
Before After
before after
chat/scrollAnchoring/chatScrollAnchoring/CompletedOffscreenHeader/Dark
Before After
before after

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>
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 roblourens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@roblourens
roblourens merged commit 8d9acb2 into main Sep 24, 2026
35 checks passed
@roblourens
roblourens deleted the copilot/fix-ghe-agent-auth branch September 24, 2026 23:53
@vs-code-engineering vs-code-engineering Bot added this to the 1.140.0 milestone Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants