Repository navigation
Claude agent host: native (BYOK) transport (Phases 18–19) - #323037
Merged
Merged
Conversation
…hed models (Phases 18–19) - Phase 18: single transport-branched model source. Proxy mode fetches Claude models from CAPI; native mode enumerates via the SDK's query().supportedModels(). - Phase 19: direct (non-proxied) Claude access. claudeUseCopilotProxy: false routes the SDK to Anthropic on the user's own credentials, no proxy in path. - Native auth comes from the subprocess env (ANTHROPIC_API_KEY, or CLAUDE_CODE_OAUTH_TOKEN from `claude setup-token`). Fixes the SDK >=0.3 env-replace semantics by spreading process.env in native mode so the token + PATH actually reach the claude subprocess. - IClaudeAgentSdkService keeps its 1:1-with-SDK contract: adds a query() passthrough; enumeration orchestration moved to the caller and closes the throwaway query (leak guard, covered by a new test). - Cleanup: removed the speculative native-binary-path feature; moved ClaudeTransport into claudeProxyService.ts; dropped a trivial model-list helper; tightened buildSubprocessEnv env construction.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a host-level “native” (BYO-Anthropic) transport for the Claude agent host, so the Claude Agent SDK can talk directly to Anthropic using user credentials when claudeUseCopilotProxy: false, while keeping the existing Copilot-proxied flow as the default. The change also introduces a transport-branched model source (CAPI models in proxy mode vs Query.supportedModels() in native mode), and updates subprocess environment handling to preserve the user’s auth/PATH in native mode.
Changes:
- Introduce a
ClaudeTransportdiscriminated union and thread it through session materialization and SDK option construction (proxy vs native). - Implement native model enumeration via an ephemeral SDK
query()+supportedModels()+close()flow; add projectionModelInfo -> IAgentModelInfowithout Copilot commercial metadata. - Add RootConfigState key
claudeUseCopilotProxy(default true) and tests covering env inheritance, transport behavior, and native model enumeration/cleanup.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/common/agentHostCustomizationConfig.ts | Adds claudeUseCopilotProxy root config key + schema metadata (default proxy). |
| src/vs/platform/agentHost/node/claude/claudeProxyService.ts | Defines ClaudeTransport union (proxy/native). |
| src/vs/platform/agentHost/node/claude/claudeSdkOptions.ts | Refactors buildOptions/buildSubprocessEnv for transport; adds native model-enumeration Options. |
| src/vs/platform/agentHost/node/claude/claudeAgentSdkService.ts | Adds 1:1 query() passthrough binding to the SDK (lazy-load shim). |
| src/vs/platform/agentHost/node/claude/claudeAgent.ts | Resolves transport mode from root config; implements native model enumeration and proxy/native auth/resource behavior. |
| src/vs/platform/agentHost/node/claude/claudeAgentSession.ts | Threads transport through materialize/rematerialize; gates Copilot credit overlays on proxy transport; persists transport in overlay update. |
| src/vs/platform/agentHost/node/claude/claudeSessionMetadataStore.ts | Persists/reads forward-compat claude.transport session overlay metadata. |
| src/vs/platform/agentHost/test/node/claudeSdkOptions.test.ts | Adds coverage for native env inheritance and proxy-vs-native buildOptions env behavior. |
| src/vs/platform/agentHost/test/node/claudeAgent.test.ts | Adds native transport tests (protected resources, model enumeration + query close, proxy not started). |
| src/vs/platform/agentHost/test/node/claudeSubagentResolver.test.ts | Updates test fake to match new IClaudeAgentSdkService.query() signature. |
| src/vs/platform/agentHost/test/node/claudeAgent.integrationTest.ts | Updates integration fake to implement new query() method. |
| src/vs/platform/agentHost/node/claude/roadmap.md | Documents Phase 18/19 completion and rationale/background. |
| src/vs/platform/agentHost/node/claude/phase18-plan.md | Adds Phase 18 plan doc (implemented). |
| src/vs/platform/agentHost/node/claude/phase19-plan.md | Adds Phase 19 plan doc (implemented), but currently has drift vs implementation (see comments). |
Copilot's findings
- Files reviewed: 14/14 changed files
- Comments generated: 4
- _fetchNativeModels: abort the enumeration options' abortController in the finally (alongside query.close()) so teardown is explicit. - buildModelEnumerationOptions doc: the caller, not the SDK service, aborts the controller at teardown. - phase19-plan: reflect the 1:1 query() passthrough (enumeration lifecycle lives in ClaudeAgent, not a supportedModels() service method); fix the ClaudeTransport home (claudeProxyService.ts) and helper signatures.
TylerLeonhardt
marked this pull request as ready for review
June 25, 2026 23:17
TylerLeonhardt
enabled auto-merge (squash)
June 25, 2026 23:18
Alexandru Dima (alexdima)
approved these changes
Jun 25, 2026
4 tasks
Member
Author
|
/azp run Dependencies Check |
|
No pipelines are associated with this pull request. |
Member
Author
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
auto-merge was automatically disabled
June 25, 2026 23:59
Pull request was closed
TylerLeonhardt
enabled auto-merge (squash)
June 26, 2026 00:00
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.
What
Fixes #314952
Adds native (BYOK) access for the Claude agent host and the transport-branched model source it builds on (roadmap Phases 18 & 19).
When
claudeUseCopilotProxy: false, the Claude Agent SDK uses whatever Claude is configured with directly on the user's own credentials — no Copilot proxy in the request path. Proxy mode (the default) is unchanged.How to use
This is only through the Agent Host, so first apply these VS Code settings:
Then, we need to apply Agent Host Settings so right click on an agent host session in the Agents Window:

Choose "Open Host Settings" and then add
claudeUseCopilotProxy: falseto that.Highlights
query().supportedModels(). Single branch point (_refreshModels→ proxy/native).ANTHROPIC_API_KEY, or a subscription OAuth token inCLAUDE_CODE_OAUTH_TOKEN(fromclaude setup-token). Fixes SDK ≥0.3 env-replace semantics by spreadingprocess.envin native mode so the token +PATHactually reach theclaudesubprocess (previously wiped → "Not logged in").IClaudeAgentSdkServicestays 1:1 with the SDK. Adds aquery()passthrough; the model-enumeration orchestration moved to the caller, whichclose()s the throwaway query (leak guard, covered by a test).claudebuild runs, never the credentials); movedClaudeTransportintoclaudeProxyService.ts; dropped a trivial model-list helper; simplifiedbuildSubprocessEnv.Test plan
./scripts/test.sh --grep "claude|Claude"— all green (incl. native env-inheritance, native model enumeration, and the new close()/leak-guard test).npm run typecheck-client— clean.--agentswithclaudeUseCopilotProxy: false+CLAUDE_CODE_OAUTH_TOKEN; native turns authenticate and the model picker shows native models with no proxy started.Draft — opening for early review.