Repository navigation
agentHost/claude: Phase 3 reference grounding + Phase 4 ClaudeAgent skeleton - #313780
Merged
Merged
Conversation
The Copilot extension at extensions/copilot/src/extension/chatSessions/claude/ already ships a working integration of @anthropic-ai/claude-agent-sdk 0.2.112 with a local proxy. That implementation is higher-fidelity evidence than any ad-hoc spike could produce. Replace the Phase 3 'spike + findings' narrative with a reference-grounded scoping for Phase 4: 1. Required-for-Phase-4 Options table — the minimum set to produce a working turn, each row citing the line in claudeCodeAgent.ts where the production code uses it and the reason it's required. 2. Deferred-concerns table — every additional knob the extension uses (mcpServers, plugins, settingSources, OTel env, ripgrep PATH, hook events, edit/settings trackers, etc.) mapped to the phase that should pull it in. 3. The one genuine open question the extension cannot answer for us: byte-equivalence between our ClaudeProxyService and the extension's ClaudeLanguageModelServer, to be closed by a Phase 4 unit test that points the SDK (with a stubbed CAPI) at our proxy. Stance: use the extension as a reference and a guiding path, not a verbatim blueprint. The extension has accreted ~20 concerns layered on top of the core SDK <-> proxy contract; copying it whole on day one would obscure which pieces are essential and make incremental review impossible. Also align downstream phases: - Phase 6: enableFileCheckpointing note now points at Phase 8 owning the validation step rather than a spike. - Phase 8: undo mechanism keeps the rewind path as preferred and the in-agent edit-history mechanism as the fallback if rewind misbehaves. - Phase 9: abortSession defaults to _abortController.abort() (matching the reference), with Query.interrupt() as a follow-up only if the default path orphans the subprocess. - Phase 15 + Open questions: drop 'Phase 3 spike answers' framing in favor of phase-owned validation steps.
Adds an IAgent provider for Claude that exposes id, descriptor, protected resources, models observable, and authentication. All session/turn/permission/tool methods throw 'TODO: Phase N' so the roadmap stays the source of truth for what each follow-up phase owns. Setting + env-var gate ---------------------- The provider is only registered when chat.agentHost.claudeAgent.enabled is true (default false, Insiders-only via included: product.quality !== 'stable'). The workbench setting is forwarded to the agent host process via VSCODE_AGENT_HOST_ENABLE_CLAUDE=1 by both starters (electron + node) and consumed in agentHostMain / agentHostServerMain. Shared GitHub Copilot resource constant --------------------------------------- Both Copilot CLI and Claude consume the same GitHub Copilot bearer token. Their getProtectedResources() returns and authenticate() resource gates now reference a single GITHUB_COPILOT_PROTECTED_RESOURCE constant exported from common/agentService.ts so the URL, scopes, and authorization servers exist in exactly one place. Auth dispatcher fan-out fix --------------------------- AgentService.authenticate() previously used Promise.all over every matching provider, so any single rejection sank all the others. With two providers sharing https://api.github.com a transient proxy bind failure in Claude would have made Copilot CLI auth appear to fail too. Replaced with Promise.allSettled and per-provider error logging: authenticated is true if any provider fulfilled true, false if every match either returned false or rejected. ClaudeAgent.authenticate() ordering fix --------------------------------------- The previous draft set _githubToken before awaiting start(). If the proxy failed to bind, the token was recorded but no proxy was running, and the next authenticate() call with the same token short-circuited on tokenChanged === false and falsely returned true. Reordered so the new IClaudeProxyHandle is acquired and only then the token / handle fields commit; the old handle is disposed last. The proxy server's refcount stays >= 1 throughout the swap. Regression tests ---------------- - agentService.test.ts: fan-out delivers token to every matching provider; one provider's rejection does not sink the others; all matches rejecting reports authenticated: false. - claudeAgent.test.ts: a transient start() failure leaves state untouched and the next authenticate() with the same token retries start() rather than short-circuiting. Also adds smoke.md, a repeatable manual smoke plan for the live provider registration / model filtering path that future phases will extend as session, sendMessage, and permissions land.
# Conflicts: # src/vs/workbench/contrib/chat/browser/chat.contribution.ts
Contributor
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the in-tree Claude agent roadmap to be grounded in the existing production Copilot extension implementation, and introduces a gated Phase 4 ClaudeAgent compilation unit in the agent host (plus supporting wiring/tests) so future phases can land incrementally.
Changes:
- Add a setting + env-var gate to optionally register a new
ClaudeAgentprovider in the agent host without exposing TODO stubs by default. - Centralize the shared GitHub Copilot protected resource metadata and harden auth fan-out to tolerate per-provider failures.
- Add unit tests for the new Claude agent skeleton and for the auth fan-out behavior; add Phase 4 smoke/plan/roadmap docs.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/chat.contribution.ts | Registers chat.agentHost.claudeAgent.enabled setting (insiders-only, default off) to gate provider registration. |
| src/vs/platform/agentHost/common/agentService.ts | Adds Claude gate constants and introduces GITHUB_COPILOT_PROTECTED_RESOURCE shared metadata. |
| src/vs/platform/agentHost/node/agentService.ts | Changes authenticate() to fan out to all matching providers using Promise.allSettled, isolating failures. |
| src/vs/platform/agentHost/node/agentHostMain.ts | Conditionally registers ClaudeAgent based on VSCODE_AGENT_HOST_ENABLE_CLAUDE. |
| src/vs/platform/agentHost/node/agentHostServerMain.ts | Adds --enable-claude-agent and registers Claude DI/services + provider behind the gate. |
| src/vs/platform/agentHost/node/nodeAgentHostStarter.ts | Forwards the workbench setting (or inherited env override) to the agent host child process via env var. |
| src/vs/platform/agentHost/electron-main/electronAgentHostStarter.ts | Same gate forwarding for the utility-process starter. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Switches to the shared GITHUB_COPILOT_PROTECTED_RESOURCE constant. |
| src/vs/platform/agentHost/node/claude/claudeAgent.ts | Adds the Phase 4 ClaudeAgent skeleton: descriptor/auth/models; other methods stubbed with TODO: Phase N. |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Adds regression tests for auth fan-out + failure isolation behavior. |
| src/vs/platform/agentHost/test/node/claudeAgent.test.ts | Adds unit tests covering descriptor/resources/auth ordering, model filtering, stale-write guard, disposal, and stubs. |
| src/vs/platform/agentHost/node/claude/roadmap.md | Reframes Phase 3 as reference-grounding and updates later-phase notes accordingly. |
| src/vs/platform/agentHost/node/claude/phase4-plan.md | Adds a detailed Phase 4 implementation plan (gating, registration sites, test list, acceptance criteria). |
| src/vs/platform/agentHost/node/claude/smoke.md | Adds a repeatable live-system smoke plan for Phase 4+. |
Copilot's findings
- Files reviewed: 14/14 changed files
- Comments generated: 1
… in dispose test Addresses Copilot review comment on PR #313780. The 'dispose disposes the proxy handle and is idempotent' test created an InstantiationService without adding it to the suite's disposables store, while the three other tests in the same file already used disposables.add(new InstantiationService(...)). Aligning the one outlier keeps the test harness consistent and prevents untracked leaks.
TylerLeonhardt
enabled auto-merge (squash)
May 1, 2026 20:52
Connor Peet (connor4312)
approved these changes
May 1, 2026
TylerLeonhardt
added a commit
that referenced
this pull request
May 2, 2026
- roadmap.md: mark Phase 4 as DONE, link merged PR #313780. - phase4-plan.md: record live-system smoke completion in §7.8; disabled-gate run skipped (covered by unit tests + env-var guard). - claudeAgent.test.ts: drop gratuitous 'as unknown as' cast in the CCAModel fixture (literal already matches CCAModelBilling exactly; plan §7.4 forbids unsafe casts in tests).
TylerLeonhardt
added a commit
that referenced
this pull request
May 5, 2026
* agentHost/claude: post-Phase-4 cleanup - roadmap.md: mark Phase 4 as DONE, link merged PR #313780. - phase4-plan.md: record live-system smoke completion in §7.8; disabled-gate run skipped (covered by unit tests + env-var guard). - claudeAgent.test.ts: drop gratuitous 'as unknown as' cast in the CCAModel fixture (literal already matches CCAModelBilling exactly; plan §7.4 forbids unsafe casts in tests). * agentHost/claude: lock Phase 5 implementation plan Handoff plan for Phase 5 (replace 7 throwing stubs in claudeAgent.ts). Locked against post-PR-#313841 reality (provisional sessions, onDidMaterializeSession, 30s empty-session GC) and the IAgent contract on origin/main. Decisions captured: - Non-fork createSession is synchronous and in-memory; fork deferred to Phase 6 (throws TODO). - IClaudeAgentSdkService surface mirrors IAgent (no dir parameter on listSessions); SDK loader caches resolved module, retries on failure, logs once. - listSessions joins SDK enumeration with workbench session DB metadata via ISessionDataService; per-entry try/catch resilience. - shutdown() routes per-session teardown through the same SequencerByKey<string> used by disposeSession() so concurrent shutdown/disposeSession cannot double-dispose a wrapper in Phase 6. - 14 unit tests defined (12 lifecycle + 2 resolved-config), including log-once contract and shutdown/disposeSession race guard. * agentHost/claude: Phase 5 — IAgent provider skeleton Lands the ClaudeAgent IAgent provider behind the 'chat.agentHost.claudeAgent.enabled' setting (env gate VSCODE_AGENT_HOST_ENABLE_CLAUDE=1). Pins @anthropic-ai/[email protected] in workspace + remote/. Implemented in this phase: * createSession - non-fork, in-memory wrapper only. Honors config.session for restore. The fork path and SDK session creation are deferred to Phase 6. * listSessions - SDK is source of truth; per-session DB read is a best-effort overlay (failure never excludes an entry). * disposeSession / shutdown - routed through a per-session SequencerByKey to serialize teardown. * getDescriptor, getProtectedResources, models, onDidSessionProgress, setClientCustomizations, setClientTools, onClientToolCallComplete, setCustomizationEnabled, authenticate, respondTo*Request - minimal Phase-5 wiring. Stubbed for Phase 6 (throw async 'TODO: Phase 6'): sendMessage, abortSession, changeModel, getSessionMessages, plus the createSession fork path. Tests: 29 unit tests in claudeAgent.test.ts cover the createSession restore-id path, listSessions overlay resilience, dispose serialization, and stub surfaces. Note: provisional / onDidMaterializeSession is intentionally omitted in Phase 5 (see plan section 3.3.1) - the workbench needs an immediate sessionAdded until the agent has real materialization work, which arrives in Phase 6 alongside SDK query() startup. * agentHost/claude: Phase 6 — sendMessage, single-turn, no tools Implements the Phase 6 plan: provisional sessions materialize on first sendMessage, route a single-turn prompt through the Anthropic Claude Agent SDK's WarmQuery, and stream SDKMessages back as protocol AgentSignals via a pure mapSDKMessageToAgentSignals reducer. Tools remain denied (canUseTool: 'deny'); fork moves to Phase 6.5; Plan Mode UI moves to Phase 7. Highlights: - ClaudeAgent.sendMessage routes through _sessionSequencer to collapse concurrent first sends into one materialize + N ordered sends. - _materializeProvisional has two abort gates (post-startup + post-customizationDirectory write) so disposeSession landing mid-materialize cannot leak a WarmQuery subprocess. - ClaudeAgentSession owns the prompt iterator + per-turn deferreds; mapSDKMessageToAgentSignals is a pure reducer with state owned by the session. - IClaudeAgentSdkService gains startup() alongside listSessions(). Tests: 43 unit + 2 proxy-backed integration. Council-review fixes (C1 dispose race, C2 missing integration test, S1 cwd-less ratification) included. * agentHost/claude: address PR review (listSessions resilience, dispose abort) Two Copilot-reviewer comments on #314216: 1. listSessions: wrap _sdkService.listSessions() in try/catch. AgentService.listSessions fans out across providers via Promise.all; an SDK dynamic-import failure would otherwise nuke every other provider's session list. Now logs and returns []. 2. dispose: abort _provisionalSessions AbortControllers before super.dispose(). Previously a racing first sendMessage parked inside _writeCustomizationDirectory could pass the materialize abort gates and call _sessions.set on a disposed DisposableMap, orphaning the WarmQuery. Aborting first triggers the existing post-customization-write abort gate, which asyncDisposes the WarmQuery. Tests: 2 new regressions (listSessions empty on SDK throw; agent.dispose() during racing materialize disposes the WarmQuery). 45/45 unit + 2/2 integration pass.
TylerLeonhardt
added a commit
that referenced
this pull request
May 5, 2026
- roadmap.md: mark Phase 4 as DONE, link merged PR #313780. - phase4-plan.md: record live-system smoke completion in §7.8; disabled-gate run skipped (covered by unit tests + env-var guard). - claudeAgent.test.ts: drop gratuitous 'as unknown as' cast in the CCAModel fixture (literal already matches CCAModelBilling exactly; plan §7.4 forbids unsafe casts in tests).
TylerLeonhardt
added a commit
that referenced
this pull request
May 6, 2026
…e-land) (#314533) * agentHost/claude: post-Phase-4 cleanup - roadmap.md: mark Phase 4 as DONE, link merged PR #313780. - phase4-plan.md: record live-system smoke completion in §7.8; disabled-gate run skipped (covered by unit tests + env-var guard). - claudeAgent.test.ts: drop gratuitous 'as unknown as' cast in the CCAModel fixture (literal already matches CCAModelBilling exactly; plan §7.4 forbids unsafe casts in tests). * agentHost/claude: lock Phase 5 implementation plan Handoff plan for Phase 5 (replace 7 throwing stubs in claudeAgent.ts). Locked against post-PR-#313841 reality (provisional sessions, onDidMaterializeSession, 30s empty-session GC) and the IAgent contract on origin/main. Decisions captured: - Non-fork createSession is synchronous and in-memory; fork deferred to Phase 6 (throws TODO). - IClaudeAgentSdkService surface mirrors IAgent (no dir parameter on listSessions); SDK loader caches resolved module, retries on failure, logs once. - listSessions joins SDK enumeration with workbench session DB metadata via ISessionDataService; per-entry try/catch resilience. - shutdown() routes per-session teardown through the same SequencerByKey<string> used by disposeSession() so concurrent shutdown/disposeSession cannot double-dispose a wrapper in Phase 6. - 14 unit tests defined (12 lifecycle + 2 resolved-config), including log-once contract and shutdown/disposeSession race guard. * agentHost/claude: Phase 5 — IAgent provider skeleton Lands the ClaudeAgent IAgent provider behind the 'chat.agentHost.claudeAgent.enabled' setting (env gate VSCODE_AGENT_HOST_ENABLE_CLAUDE=1). Pins @anthropic-ai/[email protected] in workspace + remote/. Implemented in this phase: * createSession - non-fork, in-memory wrapper only. Honors config.session for restore. The fork path and SDK session creation are deferred to Phase 6. * listSessions - SDK is source of truth; per-session DB read is a best-effort overlay (failure never excludes an entry). * disposeSession / shutdown - routed through a per-session SequencerByKey to serialize teardown. * getDescriptor, getProtectedResources, models, onDidSessionProgress, setClientCustomizations, setClientTools, onClientToolCallComplete, setCustomizationEnabled, authenticate, respondTo*Request - minimal Phase-5 wiring. Stubbed for Phase 6 (throw async 'TODO: Phase 6'): sendMessage, abortSession, changeModel, getSessionMessages, plus the createSession fork path. Tests: 29 unit tests in claudeAgent.test.ts cover the createSession restore-id path, listSessions overlay resilience, dispose serialization, and stub surfaces. Note: provisional / onDidMaterializeSession is intentionally omitted in Phase 5 (see plan section 3.3.1) - the workbench needs an immediate sessionAdded until the agent has real materialization work, which arrives in Phase 6 alongside SDK query() startup. * agentHost/claude: Phase 6 — sendMessage, single-turn, no tools Implements the Phase 6 plan: provisional sessions materialize on first sendMessage, route a single-turn prompt through the Anthropic Claude Agent SDK's WarmQuery, and stream SDKMessages back as protocol AgentSignals via a pure mapSDKMessageToAgentSignals reducer. Tools remain denied (canUseTool: 'deny'); fork moves to Phase 6.5; Plan Mode UI moves to Phase 7. Highlights: - ClaudeAgent.sendMessage routes through _sessionSequencer to collapse concurrent first sends into one materialize + N ordered sends. - _materializeProvisional has two abort gates (post-startup + post-customizationDirectory write) so disposeSession landing mid-materialize cannot leak a WarmQuery subprocess. - ClaudeAgentSession owns the prompt iterator + per-turn deferreds; mapSDKMessageToAgentSignals is a pure reducer with state owned by the session. - IClaudeAgentSdkService gains startup() alongside listSessions(). Tests: 43 unit + 2 proxy-backed integration. Council-review fixes (C1 dispose race, C2 missing integration test, S1 cwd-less ratification) included. * agentHost/claude: address PR review (listSessions resilience, dispose abort) Two Copilot-reviewer comments on #314216: 1. listSessions: wrap _sdkService.listSessions() in try/catch. AgentService.listSessions fans out across providers via Promise.all; an SDK dynamic-import failure would otherwise nuke every other provider's session list. Now logs and returns []. 2. dispose: abort _provisionalSessions AbortControllers before super.dispose(). Previously a racing first sendMessage parked inside _writeCustomizationDirectory could pass the materialize abort gates and call _sessions.set on a disposed DisposableMap, orphaning the WarmQuery. Aborting first triggers the existing post-customization-write abort gate, which asyncDisposes the WarmQuery. Tests: 2 new regressions (listSessions empty on SDK throw; agent.dispose() during racing materialize disposes the WarmQuery). 45/45 unit + 2/2 integration pass. * Drop stale @anthropic-ai/sandbox-runtime dep from merge resolution * Bump @anthropic-ai/claude-agent-sdk 0.2.112 → 0.2.128 The new SDK no longer vendors native binaries inside the main package. It now ships a ~200MB `claude` executable per platform via 8 optional platform-specific packages, mirroring the @github/copilot pattern: @anthropic-ai/claude-agent-sdk-{darwin,win32}-{x64,arm64} @anthropic-ai/claude-agent-sdk-linux-{x64,arm64}{,-musl} The SDK loader picks the right package at runtime via process.platform /process.arch (and tries -musl first on linux). To strip off-target packages from the build output: - build/lib/claudeAgentSdk.ts mirrors build/lib/copilot.ts - gulpfile.vscode.ts and gulpfile.reh.ts apply the filter alongside the existing copilot one - gulpfile.vscode.ts asar-unpacks @anthropic-ai/claude-agent-sdk-* so the executable stays on disk (asar would break exec permissions) - alpine-{arch} maps to linux-{arch}-musl (claude is statically linked against libc and must match the host) cglicenses.json gets 8 new entries mirroring the parent SDK's "© Anthropic PBC. All rights reserved." text. The new SDK Query interface adds a `readFile` method; FakeQuery and RoundTripQuery test doubles get matching stubs. Co-authored-by: Copilot <[email protected]> * build: cross-copy @anthropic-ai/claude-agent-sdk darwin packages for universal app Mirror the existing @github/copilot pattern in create-universal-app.ts. Each darwin arch build only contains its own platform package (npm only installs the optionalDependency matching the host CPU), so the universal merger fails with files unique to one side. Cross-copy node_modules/@anthropic-ai/claude-agent-sdk-{darwin-x64,darwin-arm64}/ between the two builds, skip them from the equality comparison, and tag the per-arch `claude` executable as arch-specific so the merger keeps both. Also extend verify-macho's skip list to ignore the single-arch `claude` binaries inside the universal app. * agentHost/claude: address PR review - claudeAgent: rewrite `rgPath` from node_modules.asar → node_modules.asar.unpacked before putting it on the Claude subprocess PATH. Mirrors copilotAgent.ts and the workbench search engine helpers; without this, packaged builds advertise a path that doesn't exist on disk. - cglicenses.json: add "// Reason: …" justification comments to the parent @anthropic-ai/claude-agent-sdk entry and each of the 8 new platform sub-packages, matching the file's convention. * build: bump DMG volume size from 1g to 2g The universal macOS app now carries platform-specific binaries for both x64 and arm64 — @github/copilot-darwin-* (~128MB each) and the new @anthropic-ai/claude-agent-sdk-darwin-* (~207MB each) — so the source filesystem the DMG is built from has crossed 1GB. dmgbuild fails with `No space left on device` when ditto can't fit the app inside the volume. Output DMG is LZMA-compressed (format = 'ULMO') so this only changes the build-time staging size, not the shipped artifact size. * agentHost/claude: don't bundle claude-agent-sdk; load it from a user-specified path Move `@anthropic-ai/claude-agent-sdk` from `dependencies` to `devDependencies` so the ~200MB-per-arch platform binaries are no longer shipped with VS Code. The SDK becomes opt-in and externally-installed. User-facing surface: - Replace boolean setting `chat.agentHost.claudeAgent.enabled` with string setting `chat.agentHost.claudeAgent.path`. When the setting is non-empty, the Claude provider registers; when empty (the default), it does not. - The setting value is forwarded to the agent host via the `VSCODE_AGENT_HOST_CLAUDE_SDK_PATH` env var (replacing the previous `VSCODE_AGENT_HOST_ENABLE_CLAUDE` flag). - `agentHostServerMain` exposes a `--claude-sdk-path <path>` CLI flag in place of the previous `--enable-claude-agent` flag. Runtime loader: - `ClaudeAgentSdkService._loadSdk()` now reads the env var and dynamic-imports from there. If the path is a directory, the package's main entry is resolved from `package.json` (`exports['.']` / `main`) before the import — Node ESM does not support directory imports of `file://` URLs. Build/packaging cleanup (no longer needed once the SDK is gone from production deps): - Drop `build/lib/claudeAgentSdk.ts` and its callers in `gulpfile.{vscode,reh}.ts`. - Drop the `@anthropic-ai/claude-agent-sdk-*` glob from the asar-unpack list in `gulpfile.vscode.ts`. - Revert universal-app cross-copy + filesToSkip + x64ArchFiles entries in `build/darwin/create-universal-app.ts` and the corresponding skip patterns in `build/darwin/verify-macho.ts`. - Revert DMG volume size from 2g back to 1g in `build/darwin/dmg-settings.py.template` (was bumped earlier in this branch to fit the bundled SDK; no longer needed). - Remove the 9 `@anthropic-ai/claude-agent-sdk*` entries from `cglicenses.json` (no longer shipped, no manifest to license). Type imports of `@anthropic-ai/claude-agent-sdk` continue to work via the devDependency, so source code that does `import type` from the package still typechecks. * revert cglicenses change --------- Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Combines what was previously a doc-only Phase 3 PR (#313686, now closed) with the Phase 4 code so the whole roadmap update + first compilation unit lands together.
Two commits
1.
agentHost/claude: ground Phase 3 in the production reference— doc-only roadmap update.The Copilot extension at
extensions/copilot/src/extension/chatSessions/claude/already ships a working integration of@anthropic-ai/claude-agent-sdk0.2.112 with a local proxy. That production code is higher-fidelity evidence than any ad-hoc spike could produce. Replaces the original "Phase 3 spike + findings" framing with a reference-grounded scoping for Phase 4:Optionstable — minimum set to produce a working turn, each row citing the line inclaudeCodeAgent.tswhere the production code uses it and why it's required.mcpServers, plugins,settingSources, OTel env, ripgrep PATH, hook events, edit/settings trackers, …) mapped to the phase that should pull it in.ClaudeProxyServiceand the extension'sClaudeLanguageModelServer, closed by a Phase 4 unit test pointing the SDK at our proxy.Stance: the extension is a reference and guiding path, not a verbatim blueprint. It has accreted ~20 concerns on top of the core SDK ↔ proxy contract; copying it whole on day one would obscure which pieces are essential and make incremental review impossible.
2.
agentHost/claude: Phase 4 ClaudeAgent skeleton behind a setting gate— first compilation unit.Adds an
IAgentprovider for Claude that exposes id, descriptor, protected resources, models observable, and authentication. All session/turn/permission/tool methods throwError('TODO: Phase N')so the roadmap stays the source of truth for what each follow-up phase owns.Setting + env-var gate
The provider is only registered when
chat.agentHost.claudeAgent.enabledis true.false.included: product.quality !== 'stable'.VSCODE_AGENT_HOST_ENABLE_CLAUDE=1by both starters (ElectronAgentHostStarter,NodeAgentHostStarter).agentHostMain.ts/agentHostServerMain.ts; the agent host process must be restarted for changes to take effect.This keeps the
TODO: Phase Nstubs from being reachable for any user who hasn't explicitly opted in, while still letting the Phase 5+ work merge incrementally.Shared
GITHUB_COPILOT_PROTECTED_RESOURCEBoth Copilot CLI and Claude consume the same GitHub Copilot bearer token. Their
getProtectedResources()returns andauthenticate()resource gates now reference a singleGITHUB_COPILOT_PROTECTED_RESOURCEconstant exported fromcommon/agentService.ts, so the URL, scopes, and authorization servers exist in exactly one place. Drift between providers would silently route the same token down separate code paths.Bug fixes uncovered during council review
1. Auth dispatcher fan-out —
Promise.allrejection cascadeAgentService.authenticate()previously usedPromise.allover every matching provider, so any single rejection sank all the others. With two providers sharinghttps://api.github.coma transient proxy bind failure in Claude would have made Copilot CLI auth appear to fail too. Replaced withPromise.allSettledand per-provider error logging:authenticated: trueif any provider fulfilledtrue.authenticated: falseif every match either returnedfalseor rejected.2.
ClaudeAgent.authenticate()token-before-start orderingThe previous draft set
_githubToken = tokenbefore awaitingstart(). If the proxy failed to bind, the token was recorded but no proxy was running, and the nextauthenticate()call with the same token short-circuited ontokenChanged === falseand falsely returnedtrue. Reordered so the newIClaudeProxyHandleis acquired first and only then the token / handle fields commit; the old handle is disposed last. The proxy server's refcount stays ≥ 1 throughout the swap.Regression tests
agentService.test.tsauthenticated: false.claudeAgent.test.tsstart()failure leaves_githubToken/_proxyHandleuntouched.authenticate()with the same token retriesstart()rather than short-circuiting.All 58 affected tests pass.
Validation
npm run valid-layers-check✅agentService.test.ts+claudeAgent.test.tsOut of scope
createSession/disposeSession— Phase 5.sendMessageand SDK subprocess wiring — Phase 6.smoke.mdcovers the live registration + model-filter path that future phases will extend.