Skip to content

agentHost: serve BYOK provider groups to agent hosts as model sources - #349506

Open
Logan Ramos (lramos15) wants to merge 21 commits into
mainfrom
agents/vs-code-byok-custom-endpoint-integration
Open

Logan Ramos (lramos15) wants to merge 21 commits into
mainfrom
agents/vs-code-byok-custom-endpoint-integration

Conversation

@lramos15

@lramos15 Logan Ramos (lramos15) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Registers BYOK provider groups with local and remote agent hosts as Agent Host Protocol model sources. The Copilot runtime then calls each provider's endpoint directly with the group's API key, or for an Azure group without a key, the user's Microsoft account token, instead of sending every request back to the window through the BYOK bridge. It's off by default, behind the experimental setting chat.agentHost.byokModels.directEndpoints.enabled.

Important

Builds on the AHP model source registry: microsoft/agent-host-protocol#543 and microsoft/agent-host-protocol#627, both merged. VS Code main is still on AHP 1928cd4e, without AHP main's deferred turns (microsoft/agent-host-protocol#620) and search channel (microsoft/agent-host-protocol#629). So the protocol files apply only the two PRs' types/ changes to that pin as a targeted backport, next to main's existing backport of microsoft/agent-host-protocol#631. .ahp-version stays 1928cd4e, and state/AGENTS.md records the commits and the commands that reproduce the sync. Adopting AHP main later replaces the backport; no AHP release is needed for this PR.

How it works

Window (AgentHostModelSourceRegistrar)

  • Registers each BYOK provider group from chatLanguageModels.json as a model source with root/modelSourceRegisterRequested, with every connected host whose agent reads the format. The source ID comes from the group's configuration key, so every window and device with the group registers the same source.
  • The definition uses a VS Code–owned format, code.visualstudio.com/byok-endpoints@1, which lists each model's resolved endpoint, API, and limits.
  • Sends a key with authenticate only when the host asks for one, and only if the host's copy has the window's own format and definition, so the key reaches no other endpoint. It never caches or replays keys, and doesn't resend a key the host rejected or a client revoked until the user replaces it.
  • An Azure group without a key signs in as the Copilot extension's Azure provider does: with the Microsoft account the user chose for the Copilot extension, for the https://cognitiveservices.azure.com/.default scope, read silently. Without such an account, the group stays on the bridge, whose provider asks the user to pick one. The window sends the token with an expiresIn lease that ends two minutes before the token expires, and renews it three quarters into the lease while the host still holds this account's token. The accountId names the account (a hash of its ID), so switching accounts replaces the credential like a new key.
  • Removes a source only when the user deletes the group, or when policy or the setting turns the feature off on the local host.
  • Asks before using a remote host, which then receives keys and sign-in tokens, sends it only public HTTPS endpoints, and never registers over a relay.
  • The bridge hides a model only while the local host reports its source as ready.

Host (AgentHostModelSourceRegistry)

  • Publishes each source with root/modelSourceSet, for every change including its status. A request with the same provider, format, and definition re-registers the source and keeps its key; a changed definition drops the key. Contributing clients are kept privately; the definition is in root state.
  • Reports status, credentialResource, and accountId, and the required, expired, rejected, and revoked reasons. A later delivery replaces the key the host holds.
  • Keeps keys in memory only, and drops them when an expiresIn lease lapses. Relay and scoped clients can't register sources or deliver keys.
  • When a contributingClient source's last window leaves, the host waits out its 30-second grace period. Then new turns on it fail, and running turns finish before the source is removed.

Copilot agent

  • Each model becomes a runtime provider with a static apiKey, or bearerToken when the definition's endpoint says auth: "bearer" (OpenRouter's Messages API, and Azure sign-in tokens). Safe extra request headers from the group's settings go in headers. A session registers only its selected model's provider, so it never holds another source's key.
  • The definition can carry extra headers only if they can't hold a credential: names like *auth*, *key*, *token*, *secret* or *cookie*, Bearer/Basic values, ${...} references, and headers the providers drop or the runtime sets are rejected, and their models stay on the bridge.
  • Model IDs are a hash of the source, endpoint, and upstream model. Chats saved on a bridged model ID move to the direct model.
  • Each direct model carries the same byokModelIdentifier as its bridged copy (the window's language model identifier, from the definition's first alias). So the window treats it as a BYOK model: it's listed under its provider group's name in the model picker, and hiding the model in the Language Models editor hides it.
  • If a model's source becomes unavailable, the turn ends with a resumable error whose errorCode is ModelSourceUnavailable (-32013), and a request that selects the model fails with that code. It never falls back to another model, and resuming selects the model again first.
  • An endpoint's 401 marks the key as rejected, instead of prompting for GitHub sign-in.
  • Utility requests follow chat.byokUtilityModelDefault. Automations are ready only while the model's key is present.
  • To match the BYOK providers, requests send no output cap on Chat Completions and no reasoning summary on Responses. Sessions launched on a direct model get tool search, so a request with more than 128 tools defers its MCP and client tools.

Vendors

Vendor Direct Stays on the bridge
OpenAI All: Responses with reasoning, otherwise Chat Completions —
Anthropic All, over Messages —
Gemini All, over the runtime's experimental Google provider —
xAI, Ollama All —
OpenRouter All; anthropic/ models over its Messages API with a bearer token —
Custom Endpoint Chat Completions, Messages, and Responses with thinking, with safe extra headers; Authorization: Bearer ${apiKey} on Messages uses a bearer token Responses without thinking, headers that may carry a credential, modelOptions, and streaming: false
Custom OpenAI Compatible The same, with the API picked from the URL The same, plus /messages URLs
Azure Azure OpenAI and Azure AI endpoints, with a key or signed in with the Copilot extension's Microsoft account Groups without a key before the user has chosen an account for the extension, and other hosts

The Custom Endpoint and Azure URL rules live in one import-free module, src/vs/platform/agentHost/common/customEndpointUrl.ts, which the Copilot extension's providers use through the copy copySources.ts makes. So the direct path and the extension resolve the same URLs. The Azure rule now recognizes Azure hosts by domain (*.openai.azure.com, *.models.ai.azure.com, *.inference.ml.azure.com) rather than by text anywhere in the URL, in the extension too. A base URL whose host only contains one of those names, such as https://notmodels.ai.azure.com, is now reported as an unrecognized Azure URL.

Still on the bridge

  • Custom Endpoint, Custom OpenAI Compatible and Azure Responses models without thinking, because of include.
  • Headers that may carry a credential, modelOptions, streaming: false, and third-party vscode.lm providers.

Accepted differences

  • Claude uses the runtime's thinking settings, without manual budgets or betas, and caps output at 32k.
  • Gemini uses the Interactions API rather than generateContent.
  • Utility requests can't use these models outside a session.

Known limits

  • An Azure sign-in lease lapses if every window that delivers it closes: running turns end and the source shows as expired until a window delivers a new token.
  • A sign-in token the endpoint rejects, for example because the account has no access to the resource, isn't sent again until the user switches accounts.
  • Remote hosts can't reach endpoints on this machine or its network, such as Ollama on localhost, by design.

Runtime asks

Ask Why
Leave include: ["reasoning.encrypted_content"] out of Responses requests for models without reasoning Those models stay on the bridge until then.
A tool limit per provider, 128 for OpenAI-compatible APIs Tool search is fixed at launch, so a session that switches to a direct model can still send more than 128 tools.
Redact host-supplied keys from tool results With the bundled runtime, a shell command that prints the key returns it to the model, in tool.execution_complete, and in events.jsonl. The bridge leaks it the same way.

Deferred to github/copilot-agent-runtime#47132 (sessionless inference.chat), which won't land for a while: utility requests on direct models outside a session, and moving the built-in BYOK providers from the Copilot extension into core.

Validation

Run locally against Copilot SDK 2.0.3 (runtime 1.0.116), the version main pins.

  • npx tsc --project ./src/tsconfig.json --noEmit --skipLibCheck: passed.
  • pnpm run oxlint on the changed files, and node build/checker/layersChecker.ts: passed.
  • npm test in agent-host-protocol on the backported protocol tree (AHP 1928cd4e plus Javascript replaced with "(...token: string[]): void #631, [html] Please provide a built-in HTML.tmLanguage file #543 and Bad margins in debug call stack #627's types/ changes): 674 passing.
  • ./scripts/test.sh over src/vs/platform/agentHost/test and src/vs/workbench/contrib/chat/test/browser/agentSessions: 23,207 passing, 0 failing.
    • Keyless Azure, under fake timers: only the account the user chose for the Copilot extension is used, and only if the extension may use it. The token's lease ends two minutes before it expires, and the renewal sends a fresh token three quarters into the lease. Signing out moves the group back to the bridge without picking another account.
    • Definition validation: auth: "bearer" only on Anthropic and Azure endpoints, and no headers that may carry a credential.
  • ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/providerIntegration/copilotByokDirect.integrationTest.ts: 3 passing.
    • Runs a turn each with the bundled runtime over Chat Completions, Responses, Messages, Azure OpenAI with api-key, Gemini, OpenRouter's Messages API with a bearer token, Azure OpenAI with a bearer token, and a keyless endpoint, against a loopback server. Each request carries only its own group's credential in the expected header, and no second auth header. A keyless endpoint gets none, the extra header configured on Chat Completions arrives, and no file the runtime writes contains a key.
    • Checks that tool search keeps a request with too many tools within 128.

End to end in Code OSS (Agents window, local agent host, driven with Playwright over CDP; isolated throwaway profile):

  • Added a Custom Endpoint group through Chat: Manage Language Models → Add Models → Custom Endpoint, entering its API key in the prompt, which stored it in secret storage. Then filled in three models (Chat Completions, Responses with thinking, Messages) pointing at a loopback fake OpenAI/Anthropic-compatible server that accepts only the group's key.
  • With the setting off, a turn went through the bridge: the endpoint saw User-Agent: GitHubCopilotChat/…, and the agent host log showed Wired 3 BYOK model(s) … via loopback proxy.
  • With the setting turned on in the running window, one session ran a turn on each model, switching models between turns. Each request came from the runtime itself (OpenAI/JS for Chat Completions and Responses, Anthropic/JS for Messages) with the group's key in the expected header (bearer or x-api-key), and the agent host logged Wired the selected model of a registered model source.
  • The key wasn't written to the profile, the runtime's session state for these sessions, or recent runtime logs.
  • Turning the setting off mid-session ended the next turn on the direct model with the resumable modelSourceUnavailable error, with no request and no fallback to another model. Picking the bridged model then worked again through the bridge.
  • After a restart with the setting on at startup, turns went direct again, the picker listed the models under the group's name, and hiding one in the Language Models editor removed it from the picker.

End to end on a remote agent host (the same Agents window connected to a standalone scripts/code-agent-host.sh server through chat.remoteAgentHosts, as a direct WebSocket connection):

  • The group's three models used https://127.0.0.1.nip.io:<port>, which passes the remote reachability check. A fourth used http://127.0.0.1, which doesn't. The fake server used a test CA certificate, which only the remote server trusted (NODE_EXTRA_CA_CERTS), so only the remote host's runtime could reach it.
  • The window asked before using the host, with the updated consent text. After Allow, the server's trace log showed root/modelSourceRegisterRequested, then root/modelSourceSet, then authenticate, then Serving 3 model(s) of 1 registered model source(s). The private-network model wasn't sent.
  • In a session on that host, the picker listed the three models under the group's name. One session ran a turn on each, switching models between turns, and all three replied. The fake endpoint saw OpenAI/JS and Anthropic/JS with the group's key in the expected header. The remote server logged Wired the selected model of a registered model source, and the window's local agent host wired nothing.
  • The key wasn't written to the remote host's data, the runtime's session state, or its trace logs.
  • Closing the window removed the source after the 30-second grace period (root/modelSourceRemoved, then Serving 0 model(s)).

Not run: a turn against a real provider, a real Microsoft sign-in, a remote host on another machine (SSH or a dev tunnel), or the Azure cross-platform pipeline.

Copilot AI balanced review requested due to automatic review settings November 20, 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.

🟡 Changes recommended

Unresolved direct-routing flaws can send credentials to unintended endpoints and leave live sessions using withdrawn or stale routes.

5 open issues
What changed in this PR

This PR adds opt-in direct Custom Endpoint BYOK calls from the local agent host’s Copilot runtime, reducing dependence on the window-side bridge while retaining fallback for unsupported configurations.

Changes:

  • Shares endpoint URL and authentication rules between core and the Copilot extension.
  • Adds credential delivery, runtime provider registration, and model-ID translation for direct routing.
  • Adds unit and integration coverage for routing, credentials, history restoration, and key persistence.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​common/​languageModels.ts Updates the null service for credential resolution.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatManagement/​chatModelsViewModel.test.ts Updates the language-model service mock.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostByokLmHandler.test.ts Tests direct discovery and credential gating.
src/​vs/​workbench/​contrib/​chat/​common/​languageModels.ts Adds internal provider-group key resolution.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostByokLmHandler.ts Advertises direct endpoints and serves credentials.
src/​vs/​platform/​agentHost/​test/​node/​providerIntegration/​README.md Documents direct-endpoint integration coverage.
src/​vs/​platform/​agentHost/​test/​node/​providerIntegration/​copilotByokDirect.integrationTest.ts Exercises four wire formats and checks key persistence.
src/​vs/​platform/​agentHost/​test/​node/​mapSessionEvents.test.ts Tests restored direct-model identities.
src/​vs/​platform/​agentHost/​test/​node/​copilotSessionLauncher.test.ts Tests provider synthesis, ID translation, and key withdrawal.
src/​vs/​platform/​agentHost/​test/​node/​byokLmBridgeRegistry.test.ts Tests publication after credential or capability changes.
src/​vs/​platform/​agentHost/​test/​node/​agentHostClientByokLmChannel.test.ts Tests separate credential requests.
src/​vs/​platform/​agentHost/​test/​common/​byokCustomEndpoint.test.ts Tests endpoint mapping and bridge fallbacks.
src/​vs/​platform/​agentHost/​node/​copilot/​mapSessionEvents.ts Translates runtime model IDs during replay.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotSessionLauncher.ts Builds direct providers and translates launch selections.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotByokModelIds.ts Defines stable provider names and ID conversions.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Applies ID translation and tracks live routing configuration.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Syncs live sessions when BYOK models are withdrawn.
src/​vs/​platform/​agentHost/​node/​byokLmBridgeRegistry.ts Detects direct-route and capability changes.
src/​vs/​platform/​agentHost/​common/​customEndpointUrl.ts Centralizes URL and authentication rules.
src/​vs/​platform/​agentHost/​common/​byokCustomEndpoint.ts Maps compatible settings to runtime endpoints.
src/​vs/​platform/​agentHost/​common/​agentService.ts Declares the direct-routing setting ID.
src/​vs/​platform/​agentHost/​common/​agentHostStarter.config.contribution.ts Registers the default-off experimental setting.
src/​vs/​platform/​agentHost/​common/​agentHostClientByokLmChannel.ts Adds credential delivery over local IPC.
src/​vs/​platform/​agentHost/​common/​agentHostByokLm.ts Defines direct-endpoint and credential contracts.
extensions/​copilot/​src/​util/​vs/​platform/​agentHost/​common/​customEndpointUrl.ts Vendors the shared endpoint rules.
extensions/​copilot/​src/​extension/​byok/​vscode-node/​test/​customEndpointProvider.spec.ts Adapts tests to the shared URL helper.
extensions/​copilot/​src/​extension/​byok/​vscode-node/​customEndpointProvider.ts Uses shared URL and authentication helpers.
extensions/​copilot/​script/​setup/​copySources.ts Includes the shared helper in source copying.

Review effort: Balanced

@lramos15
Logan Ramos (lramos15) force-pushed the agents/vs-code-byok-custom-endpoint-integration branch 3 times, most recently from 98df516 to a584811 Compare November 23, 2026 19:06
…untime

Behind the experimental `chat.agentHost.byokModels.customEndpointDirect.enabled`
setting, the local agent host registers Custom Endpoint BYOK models with the
Copilot runtime as real providers (the model's endpoint and the provider group's
API key) instead of routing every request back through the window's bridge.

- Share the Custom Endpoint URL rules between core and the Copilot extension
  (`customEndpointUrl.ts`, vendored by `copySources.ts`) and map each model to
  an `openai` (Chat Completions or Responses), `azure` or `anthropic` runtime
  endpoint that sends the same request and auth header as the extension.
  Models the runtime cannot reach the same way keep using the bridge.
- The window serves each group's key over a separate `credential` call on the
  existing BYOK channel, behind the BYOK policy and the setting; model lists
  never carry keys. The agent host sets it as the provider's static `apiKey`,
  re-syncs on key changes, and drops it from live sessions once the window
  stops reporting the model.
- Each direct model has its own runtime provider; the agent host translates
  its runtime selection id to and from the picker's `vendor/[group/]id`.

Co-authored-by: Copilot <[email protected]>
…irect routing

Addresses review feedback on direct Custom Endpoint BYOK routing:

- A direct provider the window no longer reports (BYOK disabled by policy, the
  group removed or changed, the setting turned off) is pointed at the BYOK
  bridge under the same provider name, with or without a key. The session keeps
  its selection, and each request gets the bridge's per-request checks. If the
  proxy cannot start, the provider and its models are withdrawn.
- Credential requests carry the snapshot's `credentialVersion`; the window
  refuses a version whose key has since been replaced, so a new key never
  reaches the endpoint of an older snapshot.
- Groups with a discovery `url`, and models with `modelOptions`, stay on the
  bridge, since the extension's requests for them differ from the runtime's.

Co-authored-by: Copilot <[email protected]>
Replace the private direct-routing path (a credential call on the local
BYOK channel plus agent/runtime model id translation) with the Agent Host
Protocol model source registry, so local and remote agent hosts share one
path.

- Sync the protocol types to the pre-release microsoft/agent-host-protocol#627
  (on #543), and narrow `authenticate` targets that are not MCP servers.
- Host: a model source registry validates `root/modelSourceRegistrationSet`
  and `Removed`, reports status with `root/modelSourceStateChanged`, holds
  credentials delivered with a `modelSource` target in memory, fences them
  with a nonce, and removes a departed client's `contributingClient` sources.
- Copilot agent: reads the `code.visualstudio.com/custom-endpoint@1` format,
  publishes each source's models with `modelSourceId`, and registers them on
  live sessions as host-owned providers that replace earlier ones on sync.
  Model ids are the runtime selection ids, bound to the registration,
  endpoint, and upstream model.
- Window: registers eligible Custom Endpoint groups with every connected
  host that reads the format, and answers key requests; the bridge stops
  listing those models.

Co-authored-by: Copilot <[email protected]>
…g back

Moves BYOK model sources to a VS Code-owned `byok-endpoints@1` definition
format that carries each model's resolved endpoint, with strict host-side
validation, and maps Custom Endpoint, Custom OpenAI Compatible, Azure (with
a key), xAI, OpenRouter and Ollama groups through a core vendor table. Models
whose requests the runtime would send differently stay on the bridge.

Adopts the registry from agent-host-protocol#627 at e06ed620: contributor
sets, model-source auth reasons, credential IDs and origins, leases, the
grace period, and resumable `modelSourceUnavailable` errors.

- Registers only the selected model's provider on a session, and never runs
  a turn on another model after its source is withdrawn or its key revoked.
- Marks a key rejected on the endpoint's 401 instead of asking for GitHub
  sign-in.
- Asks before using a remote agent host, sends it only public https
  endpoints, and never registers over relays.
- Namespaces registration IDs per installation and profile, and lets a
  window withdraw only its own contribution unless every window agrees.
- Honors `chat.byokUtilityModelDefault` for these models, and hides bridged
  copies only while the local host serves them.

Co-authored-by: Copilot <[email protected]>
@lramos15
Logan Ramos (lramos15) force-pushed the agents/vs-code-byok-custom-endpoint-integration branch from 9f9842f to 665267c Compare November 24, 2026 19:07
@lramos15 Logan Ramos (lramos15) changed the title agentHost: call Custom Endpoint BYOK models directly from the local runtime agentHost: serve BYOK provider groups to agent hosts as model sources Nov 24, 2026
…27 at a03a5a1b

Syncs the protocol to the registry as revised in review: model sources are
`RootState.modelSources`, their definitions travel only on
`root/modelSourceSet` with a client-chosen `nonce`, the host tracks
contributing clients privately from each action's origin, and a key's ID is
`authenticate`'s `accountId`.

- Host: keeps definitions and contributors privately, treats a `Set` with
  the same provider, format and nonce as a re-registration that keeps the
  key, rejects one that repeats the nonce with a different definition, and
  publishes `accountId`.
- Window: derives source IDs from the provider group and the nonce from a
  hash of the definition, so windows and devices share one source; registers
  it again on connect and reconnect; leaves another client's definition and
  key alone unless the user changed the group here; adds back a source
  another client removed only after reconnecting; and removes a source only
  when the user removes the group, or when policy turns the feature off on
  the local host.

Co-authored-by: Copilot <[email protected]>
…nt left

When the last contributing client of a contributingClient-retained model
source disconnects, the host now drains the source instead of removing it
immediately: its models leave the catalog and new work fails as
modelSourceUnavailable, but sessions with a running turn on it keep the
provider until the turn ends. The source is removed once idle, and a
re-registration cancels the drain.

Co-authored-by: Copilot <[email protected]>
…urces

Register the OpenAI, Anthropic and Gemini vendors' provider groups as model
sources, so the runtime calls their APIs directly with its own request
settings instead of matching the extension's per-vendor behavior:
- OpenAI models with a reasoning effort use Responses, the others Chat
  Completions, since the runtime always asks Responses for encrypted
  reasoning.
- Anthropic models use Messages at the Anthropic API.
- Gemini models use the runtime's experimental Google provider, the
  Interactions API with x-goog-api-key.

Sessions on a model source's Responses model ask for no reasoning summary,
as VS Code's BYOK providers never do, and restore the default when they
leave it. A session launched on a model source's model gets tool search
that defers tools past the 128 an OpenAI-compatible API accepts.

The integration test adds a Gemini turn, checks Responses requests carry no
reasoning summary, and checks the tool limit. A skipped test documents that
the bundled runtime doesn't redact provider keys from tool results.

Co-authored-by: Copilot <[email protected]>
…27 at a4a01c06

Sync the protocol from microsoft/agent-host-protocol#627 at a4a01c06, which
implements #622 after its second review round:
- The definition is part of the model source: root/modelSourceSet carries
  only the source, and the reducer keeps the definition in root state.
- Credential nonces, credentialOrigins, the capability's gracePeriod and
  principalPolicy are gone, and formats are { format } objects.

The host no longer issues nonces: a later delivery replaces the key it
holds, and a lease only lapses for the key it was delivered with. The window
checks the host's copy of the definition before sending a key: every
endpoint the key reaches must be one its own copy sends it to, whatever the
nonce. It checks again after reading the key, since the source may have
changed meanwhile.

Co-authored-by: Copilot <[email protected]>
A 401 on a model source's endpoint now carries the start time of the turn
that got it, and the host drops the credential only if it accepted that
credential before the turn started. A key delivered meanwhile is kept
instead of being reported as rejected.

The window no longer backs off and retries a failed key delivery on a
timer. It delivers again on the next state change, such as a reconnect, a
host report, or a replaced key.

Co-authored-by: Copilot <[email protected]>
Drop the skipped tool-output redaction test, which can't pass until the
runtime redacts provider keys from tool results and is tracked as a runtime
ask, and the mapping assertions the real-runtime integration test already
checks on the wire.

Co-authored-by: Copilot <[email protected]>

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.

Read at 6f67c7f. I traced these by reading; I did not run the code or read the tests in full, so a test may already cover some of them.

P1 is behavior a user can hit, worth settling before this leaves draft. P2 is a simplification or a maintainability point, and is your call.

P1

  1. A second window on a remote host can stop counting as a contributor after a group changes.
  2. A group with more than 256 direct-callable models is declined whole.
  3. Updating a group clears the key and can end turns running on its other models. Is that intended?

P2
4. The remote BYOK warning is hidden from the setting alone.
5. The Azure URL rule is a second copy of the extension's.
6. ConnectionModelSourceRegistrar could sync as one queued pass.
7. canSendKey could compare a recomputed nonce.
8. _reasoningSummaryOmitted may not need three states.
9. IModelSourceEntry repeats what is in root state.
10. Two 30-second disconnect timers.

Minor, no inline comment: the client-dispatchable action union is edited in 12 signatures across 6 files. A named type would make the next addition a one-line change.

- A window that contributed a source registers it again after another
  client updates it, so it keeps counting as a contributor.
- A definition holds up to 512 models, and the window leaves any more on
  the bridge instead of the host declining the whole group. OpenRouter
  lists more than 256 tool-capable models.
- The host declines a definition its agent can't read rather than storing
  it in root state for every client.
- Before sending a key, the window compares the host's definition with its
  own through its nonce, and checks again after reading the key that the
  host still needs it.
- Resuming a turn selects its model source's model again first, as sending
  does, and fails as unavailable while it can't.
- The session's reasoning summary state is a boolean, and one timer drops
  a disconnected client's managed settings and model sources.

Co-authored-by: Copilot <[email protected]>
…27 at 6a80f578

Sync the protocol from microsoft/agent-host-protocol#627 at 6a80f578, which
targets main now that #543 and #622 are merged:
- ModelSourceInfo and AgentInfo.modelSources are gone: root state lists
  every model source, so the host stops publishing a catalog per agent.
- format, definition and nonce are optional on ModelSource. The host
  rejects a client registration without any of them, and a model counts
  as the user's own when its root source has a definition.
- A request that selects a model whose registered source can't serve it
  fails with AhpErrorCodes.ModelSourceUnavailable (-32013).

Co-authored-by: Copilot <[email protected]>
The remote BYOK warning was hidden whenever the direct endpoints setting was on,
even when the session's host serves none of the window's models: a relayed
connection, a host the user didn't allow, one whose agent lacks the format, or
endpoints it can't reach. The registrar now publishes, per connection authority,
whether the host serves the window's sources or is still setting them up, and the
warning hides only for the session's own host.

Co-authored-by: Copilot <[email protected]>
Resolve conflicts in copilotAgent.ts and its tests: keep both sides' imports,
and in handleAuthenticationToken keep this branch's early return for non-MCP
authenticate targets ahead of main's hasGitHubToReturnTo Entra change.

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Base: b755f682 Current: aeaa648c

No screenshot changes.

…source registration

Registration now follows the automation pattern. The window dispatches
root/modelSourceRegisterRequested, and only the host publishes a source, with
root/modelSourceSet, for every change including its status. ModelSource moves
format, definition and retention into `registration`, has no nonce, and always
has a state. root/modelSourceRemoved takes modelSourceId, and
root/modelSourceStateChanged is gone.

- Host: the registry keeps each registered source and publishes it whole. It
  compares the format and definition itself, so an unchanged registration
  keeps its status and key, and publishes before confirming the request.
- Window: compares the host's registration with its own copy through a local
  definition key, and waits for a host that confirms a request before
  publishing the source.
- Turns on an unavailable source end with errorCode ModelSourceUnavailable.

The protocol is synced from #627's own changes applied to the AHP base this
branch already used (745899da), without AHP main's deferred turns (#620) and
search channel (#629), which VS Code main hasn't adopted.

Co-authored-by: Copilot <[email protected]>
…source retention

Retention is now only on root/modelSourceRegisterRequested, beside
`registration`, and no longer in state. The window sends it there. The host
keeps each source's retention privately from the latest request, uses it when
the last contributor leaves, and still declines a retention it won't honor.

Synced as before: #627's own change (git diff 2b520a36 cddbc7e7 -- types/) on
top of the previous local tree based on AHP 745899da.

Co-authored-by: Copilot <[email protected]>
…d AHP backport

The AHP model source registry has merged (microsoft/agent-host-protocol#627 as
5c4fd945, on top of #543). AHP main also has deferred turns (#620) and a search
channel (#629), which VS Code hasn't adopted, so the protocol is synced the
narrow way documented in common/state/AGENTS.md: `.ahp-version` stays on main's
pin 1928cd4e, with main's #631 backport plus #543's and #627's merged `types/`
diffs. AGENTS.md lists the backport and how to reproduce it. The generated copy
matches the previous branch copy except that #628's unrelated
`DirectoryEntry.isSymlink` drops out.

Conflicts: kept both sides' imports; in protocolServerHandler kept the model
source checks without UNSUPPORTED_CLIENT_ACTION_TYPES, which main removed; the
client test keeps `as const` for the MCP target alongside main's idToken.

Co-authored-by: Copilot <[email protected]>
…ders directly

- OpenRouter's Anthropic models use its Messages API with the key as a bearer token, through a new `auth: 'bearer'` endpoint option for anthropic and azure endpoints.
- An Azure group without a key signs in with the Microsoft account the user chose for the Copilot extension. The window delivers its token as an `expiresIn` lease and renews it before the lease ends.
- Custom Endpoint, Custom OpenAI Compatible, and Azure groups send extra request headers directly, unless a header may carry a credential or the providers drop it.

Co-authored-by: Copilot <[email protected]>
The agent host's direct path restated the extension's Azure URL rule. Both now call `resolveAzureModelUrl` in the import-free `customEndpointUrl.ts`, which the extension copies. It recognizes Azure hosts by domain instead of by text anywhere in the URL.

Co-authored-by: Copilot <[email protected]>
Models of a registered BYOK model source now carry `byokModelIdentifier`, the window language model identifier from the definition's first alias, as their bridged copies do. The window then treats them as BYOK models: the model picker lists them under their provider group's name, and hiding a model in the Language Models editor hides its direct copy.

Co-authored-by: Copilot <[email protected]>

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.

🟡 Changes recommended

Unresolved critical issues can misroute remote utility prompts, retry unsent turns without submitting their prompts, and prematurely finalize resumable turns, while direct-source models can also lose valid Copilot fallback.

4 open issues
5 resolved since last review

Review effort: Balanced

* session, so it can't serve utility requests itself yet.
*/
private _assertCopilotServesModelSourceChat(context: IAgentHostUtilityModelContext): void {
if (this._resolveMainAgentModel(context)?.model?.modelSourceId === undefined) {
duration: this._turnDuration(turnStopWatch),
part: createErrorResponsePart(error),
// The turn can run once its model source can serve it again.
part: createErrorResponsePart(error, error.errorCode === AhpErrorCodes.ModelSourceUnavailable),
Comment on lines +2473 to +2474
// The turn can run once its model source can serve it again.
part: createErrorResponsePart(error, error.errorCode === AhpErrorCodes.ModelSourceUnavailable),
}
const { agent, selection, model } = resolved;
if (model) {
return readAgentModelByokIdentifier(model) !== undefined ? model.id : undefined;

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.

Automated lightweight security-only screening: no conspicuous security vulnerabilities found in the reviewed changes. This is not a comprehensive security audit or a general correctness review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants