From a528f3f240ab6e381703b8499b34e115335b86b1 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Mon, 23 Nov 2026 17:50:36 -0500 Subject: [PATCH 01/11] docs: model source registry proposal Propose a docs-only design for #619: clients register bring-your-own-key model sources with an agent host. Registrations live in root state with a host-reported status, a sharing policy, and a retention policy. Clients add and remove them with client-dispatchable root actions, deliver keys through `authenticate` with a `modelSource` target, and select their models from #543's agent catalog by `id`. A host-wide registry lets automations and long-running headless sessions keep using a source after its client disconnects, and shows the models before any session exists. No `types/` changes, so no regeneration and no changelog fragment. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 594 ++++++++++++++++++++++++ 1 file changed, 594 insertions(+) create mode 100644 docs/proposals/model-source-registry.md diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md new file mode 100644 index 000000000..1af54a4be --- /dev/null +++ b/docs/proposals/model-source-registry.md @@ -0,0 +1,594 @@ +# Model Source Registry + +> A proposal to let clients register bring-your-own-key (BYOK) model sources with an agent host, so the host can serve those models to its sessions and automations. It tracks [#619](https://github.com/microsoft/agent-host-protocol/issues/619) and builds on the model sources in [#543](https://github.com/microsoft/agent-host-protocol/pull/543), which has not merged yet. Docs only: nothing here changes `types/`. + +## Status + +Proposal. The type sketches below show the intended shape. They are not part of the protocol until a follow-up change adds them to `types/`, regenerates the clients, and updates the guides and specification. + +An earlier revision proposed model sources as session-scoped plugin customizations. Review pointed out that BYOK configuration belongs to the user rather than to one session, and that automations and long-running headless sessions need model sources that outlive a client's session. This revision moves them to a host-wide registry. [§11](#_11-alternatives-considered) explains the trade-off. + +It assumes the direction #543 is taking after review: + +- Model IDs are unique within an agent's catalog. +- `SessionModelInfo.modelSourceId` groups a model under a `ModelSourceInfo` in `AgentInfo.modelSources`. +- A selection is just a model `id`. + +### Terminology + +- A **model source** is #543's term for an independently selectable source of model access, described by `ModelSourceInfo` in an agent's catalog. +- A **registration** is a model source a client or the host added to the host's registry, with its definition and status. +- A **model source definition** is the content of a registration that says how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. +- The **contributing client** is the client that registered a source. A registration's `clientId` names it. +- An **agent provider** is the existing `provider` field (`AgentInfo.provider`). Nothing new is called a "provider". + +--- + +## 1. Problem + +A client can own the user's BYOK model configuration: endpoints, wire formats, curated model lists, and API keys. The protocol has no way to hand that configuration to an agent host: + +- **No way to register a source.** Models are advertised by the host in `AgentInfo.models`, and #543's model sources are host-declared too. A client can't add one. +- **No credential path.** [`authenticate`](/specification/authentication#token-delivery) only accepts tokens for resources the host itself advertised: `AgentInfo.protectedResources`, or a live MCP authentication challenge. The client can't give the host a source's key. +- **No status.** Nothing reports whether a source loaded, needs a key, or failed. + +For example, a client such as VS Code lets users configure their own OpenAI, Anthropic, Azure, Gemini, OpenRouter, or custom OpenAI-compatible endpoints. When the agent host runs elsewhere (over SSH, in WSL, through a tunnel, or as a long-lived remote service), those models can't be offered: the configuration and the key stay with the client. + +The host may also run work no client is watching: sessions that span hours or days, and automations. Model sources have to be able to outlive one client's connection. + +--- + +## 2. Principle: keep AHP thin + +The agent behind the host does the heavy lifting. It owns: + +- the model source definition format and how to read it; +- endpoint validation and network policy; +- model discovery and capability derivation (context windows, vision support, and so on); +- the wire protocol for inference; +- the mapping from AHP model IDs to the endpoint's own model identifiers; +- how a credential is applied to a request. + +AHP carries only four things: + +1. **Registration.** A client adds, updates, or removes a model source definition. +2. **Status.** The host reports whether each source is starting, ready, needs a credential, or failed. +3. **Credential.** A client supplies a secret, scoped to one registered source. +4. **Selection.** The source's models appear in the agent's catalog and are selected like any other model. + +AHP names a definition's format but does not define it. + +--- + +## 3. Existing patterns this builds on + +- **Model sources ([#543](https://github.com/microsoft/agent-host-protocol/pull/543)).** `ModelSourceInfo { id, displayName }` and `AgentInfo.modelSources` describe an agent's sources, and `SessionModelInfo.modelSourceId` groups each model under one. A registered source joins that catalog, so selection, new-session pickers, and automations need nothing new. +- **Client-dispatched root actions.** `root/configChanged` already lets clients change host-wide state that the host validates and applies. +- **Keyed collections.** The registry follows the `Set` and `Removed` convention used for `activeClients`, `customizations`, and other keyed lists. +- **MCP server authentication.** An MCP server publishes `McpServerAuthRequiredState`, and the client answers with `authenticate` and a `target` naming that server. The [authentication spec](/specification/authentication#why-keyed-by-resource-and-optional-target) notes that `target.kind` is extensible for exactly this kind of addition. +- **Container provenance.** A client-published plugin carries the publisher's `clientId` and a host-reported `load` state that is absent until the host reports one. A registration works the same way. + +--- + +## 4. Proposed surface + +Everything here is additive and optional. It adds one root state field, two client-dispatchable root actions, one `authenticate` target, and one agent capability. There are no new commands, notifications, error codes, or channels. + +### 4.1 The registry + +```ts +// types/channels-root/state.ts + +export interface RootState { + // …existing… + /** Model sources registered on this host. Keyed by `id`. */ + modelSourceRegistrations?: ModelSourceRegistration[]; +} + +/** + * A model source registered on this host by a client, or by the host + * itself. Its definition is in a format the agent named by `provider` + * reads. It never contains a credential. + * + * @category Root State + * @stability 1.0 + * @preserveUnknownMembers + */ +export interface ModelSourceRegistration { + /** + * Host-unique ID, chosen by whoever registers the source. Also the + * source's `ModelSourceInfo.id` in the agent's catalog, and the + * `modelSourceId` of its models. + */ + id: string; + /** Agent provider whose agent reads the definition and serves the models. */ + provider: string; + /** Display name, published as `ModelSourceInfo.displayName`. */ + name: string; + /** Icons for UI display. */ + icons?: Icon[]; + /** Definition format, one of the agent's `ModelSourceRegistrationCapability.formats`. */ + format: string; + /** + * How to reach the source: endpoint, wire format, models, and so on, in + * `format`. MUST NOT contain a credential. + */ + definition: Record; + /** The contributing client. Absent for a source the host registered itself. */ + clientId?: string; + /** Who may select the source's models. Absent means `contributingClient`. */ + sharing?: ModelSourceSharingPolicy; + /** What happens when the contributing client leaves. Absent means `contributingClient`. */ + retention?: ModelSourceRetentionPolicy; + /** Host-reported status. Absent means the host hasn't reported one yet. */ + state?: ModelSourceState; + _meta?: Record; +} +``` + +`definition` is intentionally open data: its shape belongs to the agent that reads it. It lives in root state so a client can compare it with its own configuration and register again only when something changed. + +A host may register sources itself, for example from configuration on a remote machine. Those registrations have no `clientId`, and both policies behave as `host`. + +### 4.2 Status + +The status mirrors `McpServerState`: a lifecycle union discriminated by `kind`, with a `*Status` enum and `*State` variants. + +```ts +// types/channels-root/state.ts + +/** + * Discriminant for the ModelSourceState union. + * + * @category Root State + * @nonexhaustive + */ +export const enum ModelSourceStatus { + /** The agent is reading and validating the definition. */ + Starting = 'starting', + /** The source is usable, and its models are in the agent's catalog. */ + Ready = 'ready', + /** The source needs a credential before it can be used. */ + AuthRequired = 'authRequired', + /** The source failed, or the host declined it. */ + Error = 'error', +} + +/** @preserveUnknownMembers */ +export interface ModelSourceStartingState { + kind: ModelSourceStatus.Starting; +} + +/** @preserveUnknownMembers */ +export interface ModelSourceReadyState { + kind: ModelSourceStatus.Ready; +} + +/** + * What a model source needs in order to become ready. Deliberately + * carries no credential. + * + * @preserveUnknownMembers + */ +export interface ModelSourceAuthRequirement { + /** Why a credential is needed. */ + reason: AuthRequiredReason; + /** + * RFC 9728 metadata for the source's endpoint. `resource.resource` is + * the endpoint URL as the definition names it, in any scheme the agent + * supports (for example `http://localhost:11434/v1`). It's the value a + * client passes back as `authenticate({ resource })`, and nothing fetches + * it. `resource.resource_name` labels the prompt (for example + * "OpenRouter API key"). A source that accepts OAuth access tokens + * advertises `authorization_servers` and `scopes_supported`. A source + * that takes a user-supplied secret omits them. + */ + resource: ProtectedResourceMetadata; + /** Human-readable hint, for example the endpoint's error description. */ + description?: string; +} + +/** @preserveUnknownMembers */ +export interface ModelSourceAuthRequiredState extends ModelSourceAuthRequirement { + kind: ModelSourceStatus.AuthRequired; +} + +/** @preserveUnknownMembers */ +export interface ModelSourceErrorState { + kind: ModelSourceStatus.Error; + /** Error details. MUST NOT contain the credential. */ + error: ErrorInfo; +} + +/** @category Root State */ +export type ModelSourceState = + | ModelSourceStartingState + | ModelSourceReadyState + | ModelSourceAuthRequiredState + | ModelSourceErrorState; +``` + +```mermaid +stateDiagram-v2 + [*] --> starting : source registered + + starting --> authRequired : credential needed + starting --> ready : models listed + starting --> error : invalid definition, or declined by policy + + authRequired --> starting : authenticate accepted + + ready --> authRequired : credential expired, rejected, or revoked + ready --> starting : credential rotated, models re-listed + ready --> error : fatal failure + + error --> starting : definition changed +``` + +The host can remove a registration from any state (see [§6](#_6-lifecycle)). + +### 4.3 Registering and removing + +```ts +// types/channels-root/actions.ts + +/** + * Adds a model source registration, or replaces the one with the same `id`. + * + * @clientDispatchable + */ +export interface RootModelSourceRegistrationSetAction { + type: ActionType.RootModelSourceRegistrationSet; // 'root/modelSourceRegistrationSet' + registration: ModelSourceRegistration; +} + +/** + * Removes a model source registration. A no-op when none matches. + * + * @clientDispatchable + */ +export interface RootModelSourceRegistrationRemovedAction { + type: ActionType.RootModelSourceRegistrationRemoved; // 'root/modelSourceRegistrationRemoved' + id: string; +} +``` + +The reducers follow the keyed-collection convention: `Set` appends or replaces by `id`, and `Removed` deletes by `id` or returns the state unchanged. + +A client registers by dispatching `Set` with `clientId` set to its own ID and no `state`. The host then reports status by dispatching `Set` itself with the same registration and a `state`. A client SHOULD NOT dispatch `Set` for a registration that hasn't changed, because doing so clears its reported state. + +The host rejects a client-dispatched `Set` or `Removed`, through `ActionEnvelope.rejectionReason`, when: + +- the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; +- `clientId` isn't the dispatching client's ID, or `state` is present; +- `id` is already a declared `ModelSourceInfo.id` in that agent's catalog; +- the registration belongs to another client and has `contributingClient` sharing, or was registered by the host, unless host policy allows the change; +- the host won't honor the requested `sharing` or `retention`. The client can register again with a narrower policy. + +When a `Set` changes an existing registration's `provider`, `format`, `definition`, or `clientId`, the host drops its credential, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. + +### 4.4 Credential delivery through `authenticate` + +A client delivers a source's credential with the existing `authenticate` command and a new `target` variant. The command stays on the root channel, and no session is involved. + +```ts +// types/common/commands.ts + +/** @nonexhaustive */ +export const enum AuthenticateTargetKind { + McpServer = 'mcpServer', + ModelSource = 'modelSource', +} + +/** + * A registered model source. + * + * @category Commands + * @stability 1.0 + */ +export interface ModelSourceAuthenticateTarget { + kind: AuthenticateTargetKind.ModelSource; + /** The registration's `id`. */ + modelSourceId: string; +} + +export type AuthenticateTarget = + | McpServerAuthenticateTarget + | ModelSourceAuthenticateTarget; +``` + +```jsonc +// Client → Host +{ + "jsonrpc": "2.0", + "id": 7, + "method": "authenticate", + "params": { + "channel": "ahp-root://", + "resource": "https://api.example.com/v1", + "token": "", + "target": { "kind": "modelSource", "modelSourceId": "2f6c0e1a-model-source" } + } +} +``` + +The `token` is an opaque secret. The agent applies it as the definition specifies: an `Authorization: Bearer` header, an `x-api-key` or `api-key` header, and so on. + +Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. Untargeted tokens keep working for MCP servers and agent-level resources. + +Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMembers`: the client builds it for one request, so there are no unknown members to keep. + +`resource.resource` doesn't need to be an `https` URL, unlike other RFC 9728 resource identifiers. RFC 9728 requires `https` because an OAuth client fetches metadata from that URL. Here the client only echoes the value, so a local server such as `http://localhost:11434/v1` works. Whether the agent sends a credential over plain `http` is the host's network policy. + +When `target.kind` is `modelSource`, the host: + +- MUST apply the credential only to that registration. It never applies it to other registrations, MCP servers, or agent-level resources, even when they share `resource`. +- MUST require `resource` to equal the `resource.resource` it most recently advertised for that registration. +- MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). +- MUST reject a credential, including an empty `token` that would revoke one, from a client that may not supply one with `PermissionDenied` (`-32009`). The contributing client may always supply one. For a registration with `host` sharing, or one the host registered, any client the host allows may supply one, for example another device of the same user that has the same source configured. +- MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: required`. + +`expiresIn` keeps its current meaning and applies to short-lived tokens such as Microsoft Entra ID access tokens. API keys omit it. + +### 4.5 Models and selection + +When a registration is `ready`, the host adds it to the catalog of the agent named by `provider`, through `root/agentsChanged`: + +- a `ModelSourceInfo` in `AgentInfo.modelSources`, with the registration's `id` and its `name` as `displayName`; +- its models in `AgentInfo.models`, each with `modelSourceId` set to the registration's `id`. + +The host lists a registration's models only while it's `ready`. It MAY list the `ModelSourceInfo` in other states, since #543 allows a source with no models. + +Each model follows #543's catalog rules: + +- `id` MUST be unique within the agent's catalog. The host mints it and maps it to the endpoint's own model identifier, so two registrations can serve the same upstream model without colliding. +- `provider` stays the agent provider. +- `vendor` MAY name the service that serves the model, for example `OpenRouter`. + +**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A host can meet this by minting IDs it never reuses, for example with a random component, rather than deriving them from the endpoint's model name. + +**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed, that the chat is backed by the registration's agent provider, and that the registration's sharing policy allows the selection (see [§4.6](#_4-6-sharing-and-retention)). It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. + +**Sessions** need nothing new. Any session whose agent is the registration's `provider` can use its models, subject to sharing. There is no per-session list of registrations. + +**Automations** may name a registration's model when the registration has `host` sharing and `host` retention, or was registered by the host. The host SHOULD reject an automation create or update that names any other registration's model, because the automation would outlive or exceed what the contributing client allowed. If the source isn't `ready` when a run starts, the run fails through the existing automation run lifecycle, and the registration's `authRequired` state tells the next client to connect what's needed. + +### 4.6 Sharing and retention + +Two choices belong to the contributing client. The defaults are the narrowest, so a client that sets neither behaves like a client that only uses its own models while it's connected. + +```ts +// types/channels-root/state.ts + +/** + * Who may select a registered model source's models. + * + * @category Root State + * @nonexhaustive + */ +export const enum ModelSourceSharingPolicy { + /** Only turns and pending messages the contributing client dispatches. */ + ContributingClient = 'contributingClient', + /** Any client, and work the host starts itself, such as automations. */ + Host = 'host', +} + +/** + * How long a registered model source lasts once its contributing client leaves. + * + * @category Root State + * @nonexhaustive + */ +export const enum ModelSourceRetentionPolicy { + /** Removed when the contributing client leaves, once running turns finish. */ + ContributingClient = 'contributingClient', + /** Kept until a client removes it or host policy expires it. */ + Host = 'host', +} +``` + +- **Sharing** answers the concern that one client's key shouldn't be spent by another without consent. With `contributingClient`, the host rejects other clients' selections. With `host`, a user can continue on another device, and automations can use the source. +- **Retention** answers the headless case. With `host`, the registration and its in-memory key stay after the client disconnects, so long-running sessions and automations keep working while the host runs. + +The host never widens a policy. It rejects a registration whose policy it won't honor ([§4.3](#_4-3-registering-and-removing)), and it MAY expire `host`-retained registrations by its own policy. + +Every client sees every registration, because root state is shared. Clients SHOULD offer in their pickers only the models they may select, using `sharing` and `clientId`. + +### 4.7 Discovering support + +A client needs to know whether an agent accepts registrations, and in what format, before it registers. Unlike the per-agent markers #543 dropped, this capability carries information a client can't get any other way. + +```ts +// types/channels-root/state.ts + +export interface AgentCapabilities { + // …existing… + /** The agent serves models from registered model sources. */ + modelSourceRegistration?: ModelSourceRegistrationCapability; +} + +/** + * @category Root State + * @stability 1.0 + * @preserveUnknownMembers + */ +export interface ModelSourceRegistrationCapability { + /** + * Definition formats the agent reads, most preferred first. Format names + * are defined by agent implementations and SHOULD be namespaced, for + * example `example.com/model-source@1`, so different agents' formats + * don't collide. + */ + formats: string[]; +} +``` + +A client that knows none of an agent's formats doesn't register with it. A format that becomes a shared standard can get a well-known name, and every agent that reads it can list it. + +### 4.8 Change table + +What a follow-up implementation would touch: + +| Symbol | File | Kind | +| --- | --- | --- | +| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` | `channels-root/state.ts` | added | +| `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement` | `channels-root/state.ts` | added (lifecycle union) | +| `ModelSourceSharingPolicy`, `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | +| `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability` | `channels-root/state.ts` | added (capability) | +| `root/modelSourceRegistrationSet`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | +| Root reducer | `channels-root/reducer.ts` | upsert and remove, with fixtures for every branch | +| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the two root actions, so they pass the shared fixtures | +| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget`, `AuthenticateTarget` | `common/commands.ts` | added, widened | +| `AuthenticateParams.target` and `resource` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | +| `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources and reserved IDs | +| Generator registration | `scripts/generate-{csharp,go,kotlin,rust,swift}.ts` | new enums, structs, and union variants | +| Root channel and authentication specs, naming dictionary | `docs/`, `.github/instructions/` | updated | + +--- + +## 5. Flow + +```mermaid +sequenceDiagram + participant C as Contributing client + participant H as Agent host + participant A as Agent behind the host + participant E as Model endpoint + + C->>H: initialize + H-->>C: root snapshot (agent advertises modelSourceRegistration with formats) + + C->>H: root/modelSourceRegistrationSet (id, provider, format, definition) + H->>A: read and validate the definition + H-->>C: root/modelSourceRegistrationSet (state: authRequired) + + C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId } }) + H-->>C: {} + A->>E: list models (credential attached) + E-->>A: models + H-->>C: root/modelSourceRegistrationSet (state: ready) + H-->>C: root/agentsChanged (the source and its models join the agent catalog) + + C->>H: chat/turnStarted in any session on that agent (message.model: { id }) + A->>E: inference (credential attached) + + Note over C,H: Later, the client disconnects (host retention) + Note over H,E: running sessions and automations keep using the source +``` + +1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. +2. It dispatches `root/modelSourceRegistrationSet`. The host's agent reads and validates the definition, and the host reports `starting`. +3. If a credential is needed, the host reports `authRequired`. The client calls `authenticate` with a `modelSource` target. +4. The agent lists models. The host reports `ready` and adds the source and its models to the agent's catalog. +5. Any client the sharing policy allows can select those models in any session on that agent, and so can automations if the source is shared with the host. +6. When the contributing client disconnects, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). + +--- + +## 6. Lifecycle + +### When the contributing client leaves + +A client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period. A client that reconnects in time keeps its registrations. + +- **`contributingClient` retention (the default).** The host stops new work on the source as soon as the client leaves: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. +- **`host` retention.** The registration stays, with its credential in memory, until a client removes it, host policy expires it, or the host restarts (see below). While the contributing client is away, the source keeps serving the clients and automations its sharing policy allows. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client that may supply the credential answers. + +A client that comes back with the same `clientId` finds its registrations in root state and only dispatches `Set` for the ones it changed. A client that comes back with a new `clientId` registers again under the same `id`. For a `host`-shared registration, that takes it over: `clientId` changes, the credential is dropped, and the new contributing client supplies it. + +### Selections after removal + +A selection that names a removed source's model fails. The host MUST NOT run the work on a different model. The user picked a specific service with their own key, and quietly sending the prompt somewhere else would change where their data goes and who pays for it. + +- Drafts, history, and automation definitions keep the `id`. Because the `id` stays reserved, it can't later resolve to a different source. Clients show such a selection as unavailable. +- A pending message that names a removed model fails when the host would consume it, through the existing chat lifecycle. +- A turn that is using a source when a client explicitly removes it fails through the existing turn lifecycle the next time it needs the source. + +### Rotation, expiry, and revocation + +- **Rotation.** A new `authenticate` with the same target replaces the credential. The host MAY pass through `starting` while the agent re-lists models, keeping model IDs stable. +- **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired`. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. +- **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: required`. +- **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first, including the sharing policy. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. + +### Host restart + +Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained registrations are gone too, and their clients register again when they reconnect. A host that persists its own state SHOULD keep `host`-retained registrations, which come back in `authRequired` until a client supplies the credential. Model ID reservations are kept with the host's state either way. They identify a source and a model, not a secret. + +--- + +## 7. Credential rules + +1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. +2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. +3. **Scoped to one registration.** It is never shared with other registrations, MCP servers, or the agent's own protected resources. +4. **Attached only to that source's requests**, as its definition specifies. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. +5. **Dropped** when the registration is removed, when its definition or contributing client changes, and when the host restarts. +6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. +7. **Answered without the user when possible.** A client that has the source configured answers `authRequired` from its own secure storage. Clients SHOULD NOT prompt the user for a key they don't have. +8. **Checked by the client.** Before sending a secret, a client SHOULD check that `resource.resource` matches the endpoint in its own copy of the definition. + +--- + +## 8. Out of scope for AHP + +- The content of definition formats, endpoint validation and network policy, model discovery, capability derivation, and wire protocols. These belong to the agent. +- Client-side credential storage, and keys the host stores itself. That is host-owned authentication ([#404](https://github.com/microsoft/agent-host-protocol/pull/404)); see the open questions. +- Restricting a registration to particular sessions. +- Usage, billing, or per-call provenance. + +Hosts apply policy appropriate to the source, for example by declining registrations from clients they don't trust, or narrowing which formats they accept. + +--- + +## 9. Open questions + +- **Standard definition format.** Should a common format be standardized, for example in [Open Plugins](https://open-plugins.com/), so one registration works with any agent? The `format` names leave room for it. +- **Holding a turn for a credential.** A turn whose credential fails ends with a resumable error (see [§6](#rotation-expiry-and-revocation)). Should a host instead be able to hold the turn visibly, with a `modelSourceAuthentication` input request in `SessionState.inputNeeded`? It would carry a `ModelSourceAuthRequirement`, the way MCP's tool authentication request carries an `McpAuthRequirement`. +- **Keys that survive a restart.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. +- **Client identity.** Ownership uses `clientId`, which identifies a connection's client and can change, for example after a reinstall. Should ownership use a stable, verified client identity instead? +- **Visibility.** Every client on a host sees every registration, including its definition. That suits single-user hosts. Shared hosts might want the host to hide registrations from clients that may not use them, which would be a new pattern for root state. +- **Duplicates.** Two devices that sync the same configuration can register under the same `id` and share one registration. Devices that don't sync get two registrations for the same service. Should a host merge them? +- **Catalog across a re-auth.** Models are listed only while a source is `ready`, so a credential refresh briefly removes them. Should the host keep listing them during `authRequired`? +- **Re-registering unchanged sources.** A client-dispatched `Set` clears the reported state, so clients compare before they register again. Would a revision field be clearer? + +--- + +## 10. Compatibility + +- **Additive.** `RootState.modelSourceRegistrations` and the new capability are optional fields. `AuthenticateTargetKind` is `@nonexhaustive`, and generated clients preserve unknown `AuthenticateTarget` variants. +- **New actions follow the usual rules.** The two root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. +- **Ignorable.** A client that doesn't know the registry still sees registered sources' models in `AgentInfo.models` and can select them by `id`. It can't tell which ones its sharing policy excludes, so it may offer a model the host then rejects. +- **Capability-gated.** Clients register only with agents that advertise `modelSourceRegistration`. +- **Depends on #543.** Registered sources join #543's `AgentInfo.modelSources` catalog, so this lands after #543, or together with it. + +--- + +## 11. Alternatives considered + +- **Session-scoped plugin customizations.** The previous revision of this proposal: a client publishes a model source inside a plugin in its `SessionActiveClient` entry, and the host expands it into a child customization of that session, following the MCP server lifecycle. It was replaced for five reasons: + - Automations can't use a source that exists only inside one session. + - Long-running and headless sessions lose the source when the client's session membership ends, apart from in-memory retention. + - New-session pickers can't show the models until a session exists and the source has loaded. + - Every session repeats the same definition and the same key. + - Per-session enablement and per-session model sets, which the customization lifecycle provides, don't match how BYOK is configured. +- **A `SessionActiveClient.modelSources` field with host-published copies.** The first draft of #619. It makes the client the source of truth for model metadata it can't validate, and has the same session-scope problems. +- **Host configuration.** Model sources could be values in `RootConfigState`, changed with `root/configChanged`. Config has no per-entry ownership, status, or credential target, so each would need adding anyway. +- **Hiding registrations per connection.** Root state is one shared, replayable state, so the host enforces who may select a model rather than projecting different registries to different clients. +- **Host-to-client credential fetch per request.** The host would ask the contributing client for the key on each request, so it never rests on the host. AHP has no host-to-client request primitive yet ([#470](https://github.com/microsoft/agent-host-protocol/issues/470), with [#162](https://github.com/microsoft/agent-host-protocol/issues/162) proposing a similar request family). It also adds a round trip per request and can't serve headless work. + +--- + +## 12. Doctrine design tests + +Applying the [doctrine's design tests](/guide/doctrine#design-tests): + +- **Can a minimal client ignore this and still render a coherent session?** Yes. It sees ordinary models in the agent's catalog, and turns use whichever model it picks. +- **Is the durable, user-visible result represented in state?** Yes. Registrations, their status, and their models live in root state. The credential is deliberately not state, because it is a secret. +- **Does the host remain the authority?** Yes. The host validates registrations, decides status and policy, mints model IDs, and checks every selection. Clients send a definition and a secret, never a catalog. +- **Does this expose an agent implementation detail?** Only the format name. The definition's content, discovery, wire protocol, model ID mapping, and how a key is attached stay with the agent. +- **Does it fit an existing channel?** Yes. The registry is root state, and the credential uses root `authenticate`. No new channel. +- **Can clients discover support through capabilities or optional state?** Yes, through the agent's `modelSourceRegistration` capability and its formats. +- **Is provider-specific metadata an enhancement rather than a requirement?** Yes. `_meta` on registrations and models stays optional. + +It also respects the doctrine's anti-goal of "a required model provider, model router, or credential flow": the whole surface is optional, and a host may decline any registration. From 2c56b4db4f2d4f04a4dcce45a577bebda3786d27 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 07:43:53 -0500 Subject: [PATCH 02/11] docs: fix registry removal checks and stale credentials Validate a client-dispatched `Set` on its payload and authorize a `Removed` against the stored registration only, keeping removal of an unknown ID a no-op. The catalog collision check now ignores the entry the host publishes for the same registration, so a ready registration can still be updated or removed. Add a host-issued `credentialNonce` to each registration, echoed in the `modelSource` authenticate target. The host issues a new one whenever it drops the credential because the registration changed, and rejects a stale one with `Conflict`, so a delayed key for an old definition never reaches a new one. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 47 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 1af54a4be..90531c4cb 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -122,6 +122,13 @@ export interface ModelSourceRegistration { retention?: ModelSourceRetentionPolicy; /** Host-reported status. Absent means the host hasn't reported one yet. */ state?: ModelSourceState; + /** + * Host-issued token that a client echoes when it delivers the credential. + * The host changes it whenever it drops the credential because the + * registration changed, and never reuses one for the same `id`. Absent + * until the host reports a `state`. See §4.4. + */ + credentialNonce?: string; _meta?: Record; } ``` @@ -255,17 +262,21 @@ export interface RootModelSourceRegistrationRemovedAction { The reducers follow the keyed-collection convention: `Set` appends or replaces by `id`, and `Removed` deletes by `id` or returns the state unchanged. -A client registers by dispatching `Set` with `clientId` set to its own ID and no `state`. The host then reports status by dispatching `Set` itself with the same registration and a `state`. A client SHOULD NOT dispatch `Set` for a registration that hasn't changed, because doing so clears its reported state. +A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state` or `credentialNonce`. The host then reports status by dispatching `Set` itself with the same registration, a `state`, and a `credentialNonce`. A client SHOULD NOT dispatch `Set` for a registration that hasn't changed, because doing so clears its reported state. -The host rejects a client-dispatched `Set` or `Removed`, through `ActionEnvelope.rejectionReason`, when: +A client may change or remove a registration when it's the contributing client, or when the registration has `host` sharing, which lets another of the user's clients take it over (see [§6](#_6-lifecycle)). It may not change one that belongs to another client with `contributingClient` sharing, or one the host registered, unless host policy allows it. + +The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionReason`, when: - the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; -- `clientId` isn't the dispatching client's ID, or `state` is present; -- `id` is already a declared `ModelSourceInfo.id` in that agent's catalog; -- the registration belongs to another client and has `contributingClient` sharing, or was registered by the host, unless host policy allows the change; +- `clientId` isn't the dispatching client's ID, or `state` or `credentialNonce` is present; +- `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same registration doesn't count, so a ready registration can still be updated; +- a registration with this `id` already exists, and the dispatching client may not change it; - the host won't honor the requested `sharing` or `retention`. The client can register again with a narrower policy. -When a `Set` changes an existing registration's `provider`, `format`, `definition`, or `clientId`, the host drops its credential, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. +A client-dispatched `Removed` carries only an `id`, so the host checks it against the stored registration. When no registration has that `id`, the action is a no-op, as the keyed-collection convention requires. Otherwise the host rejects it only when the dispatching client may not change that registration. The registration's state, policies, and catalog entry don't affect removal. + +When a `Set` changes an existing registration's `provider`, `format`, `definition`, or `clientId`, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. ### 4.4 Credential delivery through `authenticate` @@ -290,6 +301,11 @@ export interface ModelSourceAuthenticateTarget { kind: AuthenticateTargetKind.ModelSource; /** The registration's `id`. */ modelSourceId: string; + /** + * The registration's current `credentialNonce`, as published in root + * state. The host rejects a stale one with `Conflict` (-32011). + */ + credentialNonce: string; } export type AuthenticateTarget = @@ -307,7 +323,11 @@ export type AuthenticateTarget = "channel": "ahp-root://", "resource": "https://api.example.com/v1", "token": "", - "target": { "kind": "modelSource", "modelSourceId": "2f6c0e1a-model-source" } + "target": { + "kind": "modelSource", + "modelSourceId": "2f6c0e1a-model-source", + "credentialNonce": "9b41d7" + } } } ``` @@ -316,6 +336,8 @@ The `token` is an opaque secret. The agent applies it as the definition specifie Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. Untargeted tokens keep working for MCP servers and agent-level resources. +`credentialNonce` keeps a delayed `authenticate` from reaching a definition it wasn't meant for. If a client replaces a registration's definition but keeps the endpoint, a key sent for the old definition would still match the `id` and `resource`. The host issues a new nonce whenever it drops the credential because the registration changed ([§4.3](#_4-3-registering-and-removing)), including when a removed registration is registered again under the same `id`. It keeps the nonce across rotation, expiry, and revocation, because the definition still matches. Random values meet the rule that a nonce is never reused for the same `id`. + Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMembers`: the client builds it for one request, so there are no unknown members to keep. `resource.resource` doesn't need to be an `https` URL, unlike other RFC 9728 resource identifiers. RFC 9728 requires `https` because an OAuth client fetches metadata from that URL. Here the client only echoes the value, so a local server such as `http://localhost:11434/v1` works. Whether the agent sends a credential over plain `http` is the host's network policy. @@ -325,6 +347,7 @@ When `target.kind` is `modelSource`, the host: - MUST apply the credential only to that registration. It never applies it to other registrations, MCP servers, or agent-level resources, even when they share `resource`. - MUST require `resource` to equal the `resource.resource` it most recently advertised for that registration. - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). +- MUST reject a `credentialNonce` other than the one it most recently issued for that registration with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. - MUST reject a credential, including an empty `token` that would revoke one, from a client that may not supply one with `PermissionDenied` (`-32009`). The contributing client may always supply one. For a registration with `host` sharing, or one the host registered, any client the host allows may supply one, for example another device of the same user that has the same source configured. - MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: required`. @@ -431,14 +454,14 @@ What a follow-up implementation would touch: | Symbol | File | Kind | | --- | --- | --- | -| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` | `channels-root/state.ts` | added | +| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including the host-issued `credentialNonce`) | `channels-root/state.ts` | added | | `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement` | `channels-root/state.ts` | added (lifecycle union) | | `ModelSourceSharingPolicy`, `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | | `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability` | `channels-root/state.ts` | added (capability) | | `root/modelSourceRegistrationSet`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | | Root reducer | `channels-root/reducer.ts` | upsert and remove, with fixtures for every branch | | Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the two root actions, so they pass the shared fixtures | -| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget`, `AuthenticateTarget` | `common/commands.ts` | added, widened | +| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId` and `credentialNonce`), `AuthenticateTarget` | `common/commands.ts` | added, widened | | `AuthenticateParams.target` and `resource` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | | `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources and reserved IDs | | Generator registration | `scripts/generate-{csharp,go,kotlin,rust,swift}.ts` | new enums, structs, and union variants | @@ -462,7 +485,7 @@ sequenceDiagram H->>A: read and validate the definition H-->>C: root/modelSourceRegistrationSet (state: authRequired) - C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId } }) + C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId, credentialNonce } }) H-->>C: {} A->>E: list models (credential attached) E-->>A: models @@ -478,7 +501,7 @@ sequenceDiagram 1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. 2. It dispatches `root/modelSourceRegistrationSet`. The host's agent reads and validates the definition, and the host reports `starting`. -3. If a credential is needed, the host reports `authRequired`. The client calls `authenticate` with a `modelSource` target. +3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`. The client calls `authenticate` with a `modelSource` target that echoes it. 4. The agent lists models. The host reports `ready` and adds the source and its models to the agent's catalog. 5. Any client the sharing policy allows can select those models in any session on that agent, and so can automations if the source is shared with the host. 6. When the contributing client disconnects, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). @@ -521,7 +544,7 @@ Credentials are gone after a restart, because they were never persisted. `contri 1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. -3. **Scoped to one registration.** It is never shared with other registrations, MCP servers, or the agent's own protected resources. +3. **Scoped to one registration and one `credentialNonce`.** It is never shared with other registrations, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. 4. **Attached only to that source's requests**, as its definition specifies. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. 5. **Dropped** when the registration is removed, when its definition or contributing client changes, and when the host restarts. 6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. From 840a211610c1a0d245fb4f866338fb0ea7da921c Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 08:37:14 -0500 Subject: [PATCH 03/11] docs: tighten registry status, revocation, and model ID rules - The host builds status updates from the current registration, so a late result can't undo a change or bring back a removed source. - Revocation reports `reason: expired`, so no client replays the revoked secret. - A model's upstream identity is its endpoint plus the endpoint's model identifier. Moving the endpoint mints new model IDs. - A client sends a stored secret only when the registration matches its own copy, and the host writes status descriptions and errors itself. - Restored registrations start in `starting`, untargeted model source credentials are rejected, and the credential drop list names every field that drops it. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 90531c4cb..e201e2450 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -191,7 +191,7 @@ export interface ModelSourceAuthRequirement { * that takes a user-supplied secret omits them. */ resource: ProtectedResourceMetadata; - /** Human-readable hint, for example the endpoint's error description. */ + /** Human-readable hint the host writes, for example "The endpoint rejected the API key." */ description?: string; } @@ -203,7 +203,7 @@ export interface ModelSourceAuthRequiredState extends ModelSourceAuthRequirement /** @preserveUnknownMembers */ export interface ModelSourceErrorState { kind: ModelSourceStatus.Error; - /** Error details. MUST NOT contain the credential. */ + /** Error details the host writes. MUST NOT contain the credential. */ error: ErrorInfo; } @@ -264,6 +264,8 @@ The reducers follow the keyed-collection convention: `Set` appends or replaces b A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state` or `credentialNonce`. The host then reports status by dispatching `Set` itself with the same registration, a `state`, and a `credentialNonce`. A client SHOULD NOT dispatch `Set` for a registration that hasn't changed, because doing so clears its reported state. +The host builds each status `Set` from the registration as it currently stands. It discards an agent result for a definition the registration no longer has, and never dispatches a status `Set` for a removed registration, so a late result can't undo a client's change or bring back a removed source. + A client may change or remove a registration when it's the contributing client, or when the registration has `host` sharing, which lets another of the user's clients take it over (see [§6](#_6-lifecycle)). It may not change one that belongs to another client with `contributingClient` sharing, or one the host registered, unless host policy allows it. The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionReason`, when: @@ -334,7 +336,7 @@ export type AuthenticateTarget = The `token` is an opaque secret. The agent applies it as the definition specifies: an `Authorization: Bearer` header, an `x-api-key` or `api-key` header, and so on. -Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. Untargeted tokens keep working for MCP servers and agent-level resources. +Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. The host rejects an untargeted `resource` that matches only model source challenges with `InvalidParams` (`-32602`). Untargeted tokens keep working for MCP servers and agent-level resources. `credentialNonce` keeps a delayed `authenticate` from reaching a definition it wasn't meant for. If a client replaces a registration's definition but keeps the endpoint, a key sent for the old definition would still match the `id` and `resource`. The host issues a new nonce whenever it drops the credential because the registration changed ([§4.3](#_4-3-registering-and-removing)), including when a removed registration is registered again under the same `id`. It keeps the nonce across rotation, expiry, and revocation, because the definition still matches. Random values meet the rule that a nonce is never reused for the same `id`. @@ -349,7 +351,7 @@ When `target.kind` is `modelSource`, the host: - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). - MUST reject a `credentialNonce` other than the one it most recently issued for that registration with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. - MUST reject a credential, including an empty `token` that would revoke one, from a client that may not supply one with `PermissionDenied` (`-32009`). The contributing client may always supply one. For a registration with `host` sharing, or one the host registered, any client the host allows may supply one, for example another device of the same user that has the same source configured. -- MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: required`. +- MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: expired`, so no client sends the revoked secret again. `expiresIn` keeps its current meaning and applies to short-lived tokens such as Microsoft Entra ID access tokens. API keys omit it. @@ -368,7 +370,7 @@ Each model follows #543's catalog rules: - `provider` stays the agent provider. - `vendor` MAY name the service that serves the model, for example `OpenRouter`. -**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A host can meet this by minting IDs it never reuses, for example with a random component, rather than deriving them from the endpoint's model name. +**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a `definition` change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when another client has taken the registration over. A host can meet this by minting IDs it never reuses, for example with a random component, rather than deriving them from the endpoint's model name. **Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed, that the chat is backed by the registration's agent provider, and that the registration's sharing policy allows the selection (see [§4.6](#_4-6-sharing-and-retention)). It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. @@ -514,7 +516,7 @@ sequenceDiagram A client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period. A client that reconnects in time keeps its registrations. -- **`contributingClient` retention (the default).** The host stops new work on the source as soon as the client leaves: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. +- **`contributingClient` retention (the default).** The host stops new work on the source as soon as the client leaves and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. - **`host` retention.** The registration stays, with its credential in memory, until a client removes it, host policy expires it, or the host restarts (see below). While the contributing client is away, the source keeps serving the clients and automations its sharing policy allows. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client that may supply the credential answers. A client that comes back with the same `clientId` finds its registrations in root state and only dispatches `Set` for the ones it changed. A client that comes back with a new `clientId` registers again under the same `id`. For a `host`-shared registration, that takes it over: `clientId` changes, the credential is dropped, and the new contributing client supplies it. @@ -531,25 +533,25 @@ A selection that names a removed source's model fails. The host MUST NOT run the - **Rotation.** A new `authenticate` with the same target replaces the credential. The host MAY pass through `starting` while the agent re-lists models, keeping model IDs stable. - **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired`. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. -- **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: required`. +- **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: expired`. Under the expiry rule, no client sends the revoked secret again, including other devices that have it stored. - **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first, including the sharing policy. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. ### Host restart -Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained registrations are gone too, and their clients register again when they reconnect. A host that persists its own state SHOULD keep `host`-retained registrations, which come back in `authRequired` until a client supplies the credential. Model ID reservations are kept with the host's state either way. They identify a source and a model, not a secret. +Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained registrations are gone too, and their clients register again when they reconnect. A host that persists its own state SHOULD keep `host`-retained registrations, which come back through `starting`, and reach `authRequired` only if they need a credential. Model ID reservations are kept with the host's state either way. They identify a source and a model, not a secret. --- ## 7. Credential rules -1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. +1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. 3. **Scoped to one registration and one `credentialNonce`.** It is never shared with other registrations, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. 4. **Attached only to that source's requests**, as its definition specifies. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. -5. **Dropped** when the registration is removed, when its definition or contributing client changes, and when the host restarts. +5. **Dropped** when the registration is removed, when its `provider`, `format`, `definition`, or contributing client changes, and when the host restarts. 6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. 7. **Answered without the user when possible.** A client that has the source configured answers `authRequired` from its own secure storage. Clients SHOULD NOT prompt the user for a key they don't have. -8. **Checked by the client.** Before sending a secret, a client SHOULD check that `resource.resource` matches the endpoint in its own copy of the definition. +8. **Checked by the client.** A client MUST NOT send a stored secret unless the registration's `provider`, `format`, and `definition` match its own copy. `credentialNonce` stops a delayed reply, but not a device whose copy of the definition is out of date or a registration another client has taken over. --- From 71af87d388221d808b8751280b6a8064909a4234 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 09:18:08 -0500 Subject: [PATCH 04/11] docs: follow MCP for registry ownership and status Like MCP servers, registrations have no per-client ownership: any client can use, change, or remove one and supply its credential. Remove the sharing policy, takeover, and permission checks, and keep retention as the one per-registration choice. A registration's `clientId` records who last wrote it. Report status with a host-only `root/modelSourceStateChanged` action, modeled on `session/mcpServerStateChanged`, instead of writing the whole registration back. Its reducer ignores unknown IDs, so a late status can't revive a removed registration or overwrite a newer definition. Issue a new `credentialNonce` on every credential change, including rotation, expiry, and revocation, and ignore failures from requests made with an older key. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 146 +++++++++++++----------- 1 file changed, 81 insertions(+), 65 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index e201e2450..a36535674 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -19,7 +19,7 @@ It assumes the direction #543 is taking after review: - A **model source** is #543's term for an independently selectable source of model access, described by `ModelSourceInfo` in an agent's catalog. - A **registration** is a model source a client or the host added to the host's registry, with its definition and status. - A **model source definition** is the content of a registration that says how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. -- The **contributing client** is the client that registered a source. A registration's `clientId` names it. +- The **contributing client** is the client that most recently registered or changed a source. A registration's `clientId` names it. - An **agent provider** is the existing `provider` field (`AgentInfo.provider`). Nothing new is called a "provider". --- @@ -66,13 +66,15 @@ AHP names a definition's format but does not define it. - **Client-dispatched root actions.** `root/configChanged` already lets clients change host-wide state that the host validates and applies. - **Keyed collections.** The registry follows the `Set` and `Removed` convention used for `activeClients`, `customizations`, and other keyed lists. - **MCP server authentication.** An MCP server publishes `McpServerAuthRequiredState`, and the client answers with `authenticate` and a `target` naming that server. The [authentication spec](/specification/authentication#why-keyed-by-resource-and-optional-target) notes that `target.kind` is extensible for exactly this kind of addition. +- **MCP server status.** The host reports a server's lifecycle with `session/mcpServerStateChanged`, a narrow action that updates only the server's state. A registration's status works the same way. +- **No per-client ownership.** Any client in a session can start, stop, or enable an MCP server and answer its authentication challenge. AHP checks a `clientId` only to route a client tool's result back from the client that runs it. Registrations follow the same model: every connected client can use and change them, and access control between clients is host policy. - **Container provenance.** A client-published plugin carries the publisher's `clientId` and a host-reported `load` state that is absent until the host reports one. A registration works the same way. --- ## 4. Proposed surface -Everything here is additive and optional. It adds one root state field, two client-dispatchable root actions, one `authenticate` target, and one agent capability. There are no new commands, notifications, error codes, or channels. +Everything here is additive and optional. It adds one root state field, three root actions (two of them client-dispatchable), one `authenticate` target, and one agent capability. There are no new commands, notifications, error codes, or channels. ### 4.1 The registry @@ -116,17 +118,19 @@ export interface ModelSourceRegistration { definition: Record; /** The contributing client. Absent for a source the host registered itself. */ clientId?: string; - /** Who may select the source's models. Absent means `contributingClient`. */ - sharing?: ModelSourceSharingPolicy; /** What happens when the contributing client leaves. Absent means `contributingClient`. */ retention?: ModelSourceRetentionPolicy; - /** Host-reported status. Absent means the host hasn't reported one yet. */ + /** + * Host-reported status, set with `root/modelSourceStateChanged`. Absent + * until the host reports one, and after a client replaces the + * registration until the host reports again. + */ state?: ModelSourceState; /** * Host-issued token that a client echoes when it delivers the credential. - * The host changes it whenever it drops the credential because the - * registration changed, and never reuses one for the same `id`. Absent - * until the host reports a `state`. See §4.4. + * The host issues a new one whenever the credential is installed or + * dropped, and never reuses one for the same `id`. Set with `state`. + * See §4.4. */ credentialNonce?: string; _meta?: Record; @@ -135,7 +139,7 @@ export interface ModelSourceRegistration { `definition` is intentionally open data: its shape belongs to the agent that reads it. It lives in root state so a client can compare it with its own configuration and register again only when something changed. -A host may register sources itself, for example from configuration on a remote machine. Those registrations have no `clientId`, and both policies behave as `host`. +A host may register sources itself, for example from configuration on a remote machine. Those registrations have no `clientId`, and their retention behaves as `host`. ### 4.2 Status @@ -234,6 +238,25 @@ stateDiagram-v2 The host can remove a registration from any state (see [§6](#_6-lifecycle)). +The host reports status with its own narrow action, as it does for MCP servers with `session/mcpServerStateChanged`. It never reports status by dispatching the client's whole registration back. + +```ts +// types/channels-root/actions.ts + +/** + * Updates a registration's status and credential nonce. A no-op when no + * registration has `id`. Only the host dispatches it. + */ +export interface RootModelSourceStateChangedAction { + type: ActionType.RootModelSourceStateChanged; // 'root/modelSourceStateChanged' + id: string; + state: ModelSourceState; + credentialNonce: string; +} +``` + +Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only `state` and `credentialNonce`, it can't overwrite a client's newer definition. The host also discards an agent result for a definition the registration no longer has, so a slow result for an old definition can't mark a new one `ready`. + ### 4.3 Registering and removing ```ts @@ -262,23 +285,20 @@ export interface RootModelSourceRegistrationRemovedAction { The reducers follow the keyed-collection convention: `Set` appends or replaces by `id`, and `Removed` deletes by `id` or returns the state unchanged. -A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state` or `credentialNonce`. The host then reports status by dispatching `Set` itself with the same registration, a `state`, and a `credentialNonce`. A client SHOULD NOT dispatch `Set` for a registration that hasn't changed, because doing so clears its reported state. +A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state` or `credentialNonce`. Replacing the registration clears its status until the host reports again with `root/modelSourceStateChanged`, so a client SHOULD NOT dispatch `Set` for a registration that hasn't changed. -The host builds each status `Set` from the registration as it currently stands. It discards an agent result for a definition the registration no longer has, and never dispatches a status `Set` for a removed registration, so a late result can't undo a client's change or bring back a removed source. - -A client may change or remove a registration when it's the contributing client, or when the registration has `host` sharing, which lets another of the user's clients take it over (see [§6](#_6-lifecycle)). It may not change one that belongs to another client with `contributingClient` sharing, or one the host registered, unless host policy allows it. +Like MCP servers, registrations have no per-client ownership. Any client can change or remove any registration, and the client that changes one becomes its contributing client. A host MAY reject client changes to a registration it created itself. The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionReason`, when: - the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; - `clientId` isn't the dispatching client's ID, or `state` or `credentialNonce` is present; - `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same registration doesn't count, so a ready registration can still be updated; -- a registration with this `id` already exists, and the dispatching client may not change it; -- the host won't honor the requested `sharing` or `retention`. The client can register again with a narrower policy. +- the host won't honor the requested `retention`. The client can register again with `contributingClient` retention. -A client-dispatched `Removed` carries only an `id`, so the host checks it against the stored registration. When no registration has that `id`, the action is a no-op, as the keyed-collection convention requires. Otherwise the host rejects it only when the dispatching client may not change that registration. The registration's state, policies, and catalog entry don't affect removal. +A client-dispatched `Removed` carries only an `id`. When no registration has that `id`, the action is a no-op, as the keyed-collection convention requires. -When a `Set` changes an existing registration's `provider`, `format`, `definition`, or `clientId`, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. +When a `Set` changes an existing registration's `provider`, `format`, or `definition`, the host drops its credential, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A change to `name`, `icons`, `clientId`, or `retention` keeps the credential. ### 4.4 Credential delivery through `authenticate` @@ -338,7 +358,13 @@ The `token` is an opaque secret. The agent applies it as the definition specifie Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. The host rejects an untargeted `resource` that matches only model source challenges with `InvalidParams` (`-32602`). Untargeted tokens keep working for MCP servers and agent-level resources. -`credentialNonce` keeps a delayed `authenticate` from reaching a definition it wasn't meant for. If a client replaces a registration's definition but keeps the endpoint, a key sent for the old definition would still match the `id` and `resource`. The host issues a new nonce whenever it drops the credential because the registration changed ([§4.3](#_4-3-registering-and-removing)), including when a removed registration is registered again under the same `id`. It keeps the nonce across rotation, expiry, and revocation, because the definition still matches. Random values meet the rule that a nonce is never reused for the same `id`. +`credentialNonce` fences every credential change. The host issues a new nonce whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation, and when a change to `provider`, `format`, or `definition` drops it ([§4.3](#_4-3-registering-and-removing)). That includes a removed registration that's registered again under the same `id`. An `authenticate` built before any of those changes is stale, so: + +- a key meant for an old definition never reaches a new one, even when the endpoint didn't change; +- a rotation that crosses a revocation can't undo the revocation; +- when two clients answer the same `authRequired`, the first wins, and the second gets `Conflict`, re-reads state, and finds the source ready. + +The host also tags each request with the nonce of the key it used, and ignores a failure from a request made with an older key, so a late failure can't drop a key that has since replaced it. Random values meet the rule that a nonce is never reused for the same `id`. Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMembers`: the client builds it for one request, so there are no unknown members to keep. @@ -350,9 +376,10 @@ When `target.kind` is `modelSource`, the host: - MUST require `resource` to equal the `resource.resource` it most recently advertised for that registration. - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). - MUST reject a `credentialNonce` other than the one it most recently issued for that registration with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. -- MUST reject a credential, including an empty `token` that would revoke one, from a client that may not supply one with `PermissionDenied` (`-32009`). The contributing client may always supply one. For a registration with `host` sharing, or one the host registered, any client the host allows may supply one, for example another device of the same user that has the same source configured. - MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: expired`, so no client sends the revoked secret again. +Any client may deliver or revoke a registration's credential, as any client may answer an MCP server's challenge. + `expiresIn` keeps its current meaning and applies to short-lived tokens such as Microsoft Entra ID access tokens. API keys omit it. ### 4.5 Models and selection @@ -370,34 +397,21 @@ Each model follows #543's catalog rules: - `provider` stays the agent provider. - `vendor` MAY name the service that serves the model, for example `OpenRouter`. -**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a `definition` change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when another client has taken the registration over. A host can meet this by minting IDs it never reuses, for example with a random component, rather than deriving them from the endpoint's model name. +**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a `definition` change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when a different client made the change. A host can meet this by minting IDs it never reuses, for example with a random component, rather than deriving them from the endpoint's model name. -**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed, that the chat is backed by the registration's agent provider, and that the registration's sharing policy allows the selection (see [§4.6](#_4-6-sharing-and-retention)). It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. +**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed and that the chat is backed by the registration's agent provider. It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. -**Sessions** need nothing new. Any session whose agent is the registration's `provider` can use its models, subject to sharing. There is no per-session list of registrations. +**Sessions** need nothing new. Any session whose agent is the registration's `provider` can use its models, whichever client started the turn. There is no per-session list of registrations. -**Automations** may name a registration's model when the registration has `host` sharing and `host` retention, or was registered by the host. The host SHOULD reject an automation create or update that names any other registration's model, because the automation would outlive or exceed what the contributing client allowed. If the source isn't `ready` when a run starts, the run fails through the existing automation run lifecycle, and the registration's `authRequired` state tells the next client to connect what's needed. +**Automations** may name a registration's model when the registration has `host` retention, or was registered by the host. The host SHOULD reject an automation create or update that names a model from a `contributingClient`-retained registration, because the automation would outlive the source. If the source isn't `ready` when a run starts, the run fails through the existing automation run lifecycle, and the registration's `authRequired` state tells the next client to connect what's needed. -### 4.6 Sharing and retention +### 4.6 Retention -Two choices belong to the contributing client. The defaults are the narrowest, so a client that sets neither behaves like a client that only uses its own models while it's connected. +The contributing client chooses what happens to a registration when it leaves. The default is the narrower choice, so a client that doesn't set it behaves like a client that only uses its models while it's connected. ```ts // types/channels-root/state.ts -/** - * Who may select a registered model source's models. - * - * @category Root State - * @nonexhaustive - */ -export const enum ModelSourceSharingPolicy { - /** Only turns and pending messages the contributing client dispatches. */ - ContributingClient = 'contributingClient', - /** Any client, and work the host starts itself, such as automations. */ - Host = 'host', -} - /** * How long a registered model source lasts once its contributing client leaves. * @@ -412,12 +426,11 @@ export const enum ModelSourceRetentionPolicy { } ``` -- **Sharing** answers the concern that one client's key shouldn't be spent by another without consent. With `contributingClient`, the host rejects other clients' selections. With `host`, a user can continue on another device, and automations can use the source. -- **Retention** answers the headless case. With `host`, the registration and its in-memory key stay after the client disconnects, so long-running sessions and automations keep working while the host runs. +The two values mirror how MCP servers already behave. A `contributingClient` registration goes away with its client, like a client-published plugin. A `host` registration stays, like a host-declared server, so long-running sessions and automations keep working, with the key in memory, while the host runs. -The host never widens a policy. It rejects a registration whose policy it won't honor ([§4.3](#_4-3-registering-and-removing)), and it MAY expire `host`-retained registrations by its own policy. +The host rejects `host` retention when it won't honor it ([§4.3](#_4-3-registering-and-removing)), and it MAY expire `host`-retained registrations by its own policy. -Every client sees every registration, because root state is shared. Clients SHOULD offer in their pickers only the models they may select, using `sharing` and `clientId`. +Every client sees every registration, including its definition, because root state is shared. That suits the hosts this is designed for, where every connected client belongs to the same user. A host shared by several users needs its own policy, for example by declining registrations (see [§9](#_9-open-questions)). ### 4.7 Discovering support @@ -458,11 +471,12 @@ What a follow-up implementation would touch: | --- | --- | --- | | `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including the host-issued `credentialNonce`) | `channels-root/state.ts` | added | | `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement` | `channels-root/state.ts` | added (lifecycle union) | -| `ModelSourceSharingPolicy`, `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | +| `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | | `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability` | `channels-root/state.ts` | added (capability) | | `root/modelSourceRegistrationSet`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | -| Root reducer | `channels-root/reducer.ts` | upsert and remove, with fixtures for every branch | -| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the two root actions, so they pass the shared fixtures | +| `root/modelSourceStateChanged` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (host-only, introduced in the development version) | +| Root reducer | `channels-root/reducer.ts` | upsert, remove, and status change, with fixtures for every branch, including a status change for an unknown `id` | +| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the three root actions, so they pass the shared fixtures | | `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId` and `credentialNonce`), `AuthenticateTarget` | `common/commands.ts` | added, widened | | `AuthenticateParams.target` and `resource` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | | `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources and reserved IDs | @@ -485,13 +499,13 @@ sequenceDiagram C->>H: root/modelSourceRegistrationSet (id, provider, format, definition) H->>A: read and validate the definition - H-->>C: root/modelSourceRegistrationSet (state: authRequired) + H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce) C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId, credentialNonce } }) H-->>C: {} A->>E: list models (credential attached) E-->>A: models - H-->>C: root/modelSourceRegistrationSet (state: ready) + H-->>C: root/modelSourceStateChanged (ready, new credentialNonce) H-->>C: root/agentsChanged (the source and its models join the agent catalog) C->>H: chat/turnStarted in any session on that agent (message.model: { id }) @@ -502,10 +516,10 @@ sequenceDiagram ``` 1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. -2. It dispatches `root/modelSourceRegistrationSet`. The host's agent reads and validates the definition, and the host reports `starting`. +2. It dispatches `root/modelSourceRegistrationSet`. The host's agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. 3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`. The client calls `authenticate` with a `modelSource` target that echoes it. -4. The agent lists models. The host reports `ready` and adds the source and its models to the agent's catalog. -5. Any client the sharing policy allows can select those models in any session on that agent, and so can automations if the source is shared with the host. +4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and adds the source and its models to the agent's catalog. +5. Any client can select those models in any session on that agent, and so can automations if the source has `host` retention. 6. When the contributing client disconnects, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). --- @@ -517,9 +531,9 @@ sequenceDiagram A client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period. A client that reconnects in time keeps its registrations. - **`contributingClient` retention (the default).** The host stops new work on the source as soon as the client leaves and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. -- **`host` retention.** The registration stays, with its credential in memory, until a client removes it, host policy expires it, or the host restarts (see below). While the contributing client is away, the source keeps serving the clients and automations its sharing policy allows. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client that may supply the credential answers. +- **`host` retention.** The registration stays, with its credential in memory, until a client removes it, host policy expires it, or the host restarts (see below). While the contributing client is away, the source keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. -A client that comes back with the same `clientId` finds its registrations in root state and only dispatches `Set` for the ones it changed. A client that comes back with a new `clientId` registers again under the same `id`. For a `host`-shared registration, that takes it over: `clientId` changes, the credential is dropped, and the new contributing client supplies it. +A client that comes back with the same `clientId` finds its registrations in root state and only dispatches `Set` for the ones it changed. A client that comes back with a new `clientId` and the same configuration registers again under the same `id`. That makes it the contributing client, and because the definition didn't change, the credential stays. ### Selections after removal @@ -531,10 +545,10 @@ A selection that names a removed source's model fails. The host MUST NOT run the ### Rotation, expiry, and revocation -- **Rotation.** A new `authenticate` with the same target replaces the credential. The host MAY pass through `starting` while the agent re-lists models, keeping model IDs stable. -- **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired`. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. -- **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: expired`. Under the expiry rule, no client sends the revoked secret again, including other devices that have it stored. -- **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first, including the sharing policy. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. +- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce. The host MAY pass through `starting` while the agent re-lists models, keeping model IDs stable. +- **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired` and a new nonce. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. +- **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: expired` and a new nonce. Under the expiry rule, no client sends the revoked secret again, including other devices that have it stored, and the new nonce rejects a delivery that was already in flight. +- **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. ### Host restart @@ -548,10 +562,10 @@ Credentials are gone after a restart, because they were never persisted. `contri 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. 3. **Scoped to one registration and one `credentialNonce`.** It is never shared with other registrations, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. 4. **Attached only to that source's requests**, as its definition specifies. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. -5. **Dropped** when the registration is removed, when its `provider`, `format`, `definition`, or contributing client changes, and when the host restarts. +5. **Dropped** when the registration is removed, when its `provider`, `format`, or `definition` changes, and when the host restarts. 6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. 7. **Answered without the user when possible.** A client that has the source configured answers `authRequired` from its own secure storage. Clients SHOULD NOT prompt the user for a key they don't have. -8. **Checked by the client.** A client MUST NOT send a stored secret unless the registration's `provider`, `format`, and `definition` match its own copy. `credentialNonce` stops a delayed reply, but not a device whose copy of the definition is out of date or a registration another client has taken over. +8. **Checked by the client.** A client MUST NOT send a stored secret unless the registration's `provider`, `format`, and `definition` match its own copy. `credentialNonce` stops a delayed reply, but not a device whose copy of the definition is out of date or a registration another client has changed. --- @@ -560,6 +574,7 @@ Credentials are gone after a restart, because they were never persisted. `contri - The content of definition formats, endpoint validation and network policy, model discovery, capability derivation, and wire protocols. These belong to the agent. - Client-side credential storage, and keys the host stores itself. That is host-owned authentication ([#404](https://github.com/microsoft/agent-host-protocol/pull/404)); see the open questions. - Restricting a registration to particular sessions. +- Per-client ownership and access control between clients. As with MCP servers, every connected client can use and change every registration. - Usage, billing, or per-call provenance. Hosts apply policy appropriate to the source, for example by declining registrations from clients they don't trust, or narrowing which formats they accept. @@ -571,19 +586,18 @@ Hosts apply policy appropriate to the source, for example by declining registrat - **Standard definition format.** Should a common format be standardized, for example in [Open Plugins](https://open-plugins.com/), so one registration works with any agent? The `format` names leave room for it. - **Holding a turn for a credential.** A turn whose credential fails ends with a resumable error (see [§6](#rotation-expiry-and-revocation)). Should a host instead be able to hold the turn visibly, with a `modelSourceAuthentication` input request in `SessionState.inputNeeded`? It would carry a `ModelSourceAuthRequirement`, the way MCP's tool authentication request carries an `McpAuthRequirement`. - **Keys that survive a restart.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. -- **Client identity.** Ownership uses `clientId`, which identifies a connection's client and can change, for example after a reinstall. Should ownership use a stable, verified client identity instead? -- **Visibility.** Every client on a host sees every registration, including its definition. That suits single-user hosts. Shared hosts might want the host to hide registrations from clients that may not use them, which would be a new pattern for root state. +- **Several users on one host.** AHP can't verify which client is which, so this proposal, like MCP, trusts every connected client equally, and every client sees every definition. A host shared by several users would need verified client identities, per-client access control, and a way to hide registrations from clients that may not use them. That last part would be a new pattern for root state. - **Duplicates.** Two devices that sync the same configuration can register under the same `id` and share one registration. Devices that don't sync get two registrations for the same service. Should a host merge them? - **Catalog across a re-auth.** Models are listed only while a source is `ready`, so a credential refresh briefly removes them. Should the host keep listing them during `authRequired`? -- **Re-registering unchanged sources.** A client-dispatched `Set` clears the reported state, so clients compare before they register again. Would a revision field be clearer? +- **Re-registering unchanged sources.** A client-dispatched `Set` clears the reported status until the host reports again, so clients compare before they register again. Would a revision field be clearer? --- ## 10. Compatibility - **Additive.** `RootState.modelSourceRegistrations` and the new capability are optional fields. `AuthenticateTargetKind` is `@nonexhaustive`, and generated clients preserve unknown `AuthenticateTarget` variants. -- **New actions follow the usual rules.** The two root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. -- **Ignorable.** A client that doesn't know the registry still sees registered sources' models in `AgentInfo.models` and can select them by `id`. It can't tell which ones its sharing policy excludes, so it may offer a model the host then rejects. +- **New actions follow the usual rules.** The three root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. +- **Ignorable.** A client that doesn't know the registry still sees registered sources' models in `AgentInfo.models` and can select them by `id`, like any other model. - **Capability-gated.** Clients register only with agents that advertise `modelSourceRegistration`. - **Depends on #543.** Registered sources join #543's `AgentInfo.modelSources` catalog, so this lands after #543, or together with it. @@ -598,8 +612,10 @@ Hosts apply policy appropriate to the source, for example by declining registrat - Every session repeats the same definition and the same key. - Per-session enablement and per-session model sets, which the customization lifecycle provides, don't match how BYOK is configured. - **A `SessionActiveClient.modelSources` field with host-published copies.** The first draft of #619. It makes the client the source of truth for model metadata it can't validate, and has the same session-scope problems. -- **Host configuration.** Model sources could be values in `RootConfigState`, changed with `root/configChanged`. Config has no per-entry ownership, status, or credential target, so each would need adding anyway. -- **Hiding registrations per connection.** Root state is one shared, replayable state, so the host enforces who may select a model rather than projecting different registries to different clients. +- **Host configuration.** Model sources could be values in `RootConfigState`, changed with `root/configChanged`. Config has no per-entry provenance, status, or credential target, so each would need adding anyway. +- **Per-client sharing and ownership.** An earlier draft let the contributing client limit who could use a source and who could change it, so one client couldn't spend another's key. AHP can't verify which client is which, any connected client can already run tools as the host's user, and MCP servers have no such limits. The rules added complexity without protection, so they were dropped, leaving retention as the only per-registration choice. +- **Hiding registrations per connection.** Root state is one shared, replayable state, and this proposal trusts every connected client, so it doesn't project different registries to different clients. +- **Reporting status by rewriting the registration.** An earlier draft had the host dispatch the whole registration back with `state` added. A late status write could then bring back a removed registration or overwrite a newer definition, which took several extra rules to prevent. A narrow status action, as MCP uses, prevents both by construction. - **Host-to-client credential fetch per request.** The host would ask the contributing client for the key on each request, so it never rests on the host. AHP has no host-to-client request primitive yet ([#470](https://github.com/microsoft/agent-host-protocol/issues/470), with [#162](https://github.com/microsoft/agent-host-protocol/issues/162) proposing a similar request family). It also adds a round trip per request and can't serve headless work. --- From fe2cc9da081e0a8528bcdabae34a7c07b92923e3 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 09:24:06 -0500 Subject: [PATCH 05/11] docs: remove a repeated sentence in the registry proposal Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index a36535674..0ed7ebffa 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -548,7 +548,7 @@ A selection that names a removed source's model fails. The host MUST NOT run the - **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce. The host MAY pass through `starting` while the agent re-lists models, keeping model IDs stable. - **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired` and a new nonce. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. - **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: expired` and a new nonce. Under the expiry rule, no client sends the revoked secret again, including other devices that have it stored, and the new nonce rejects a delivery that was already in flight. -- **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. +- **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. ### Host restart From c600f0cbccd6711d4be83f15c65bada3cfb1631f Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 09:35:07 -0500 Subject: [PATCH 06/11] docs: keep registered models listed across re-auth Once a registration has been ready, the host keeps its models listed through `starting` and `authRequired`, so a key rotation or expiry doesn't change the catalog or break a selection. It withdraws them on removal, when the contributing client leaves under `contributingClient` retention, on `error`, or when a change mints new model IDs. A turn that starts without a usable credential ends with a resumable error, like a mid-turn credential failure. This settles the open question about the catalog across a re-auth. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 0ed7ebffa..7be3ce42b 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -389,7 +389,7 @@ When a registration is `ready`, the host adds it to the catalog of the agent nam - a `ModelSourceInfo` in `AgentInfo.modelSources`, with the registration's `id` and its `name` as `displayName`; - its models in `AgentInfo.models`, each with `modelSourceId` set to the registration's `id`. -The host lists a registration's models only while it's `ready`. It MAY list the `ModelSourceInfo` in other states, since #543 allows a source with no models. +The host adds a registration's models when it first becomes `ready`, and keeps them listed through later `starting` and `authRequired` states, so a key rotation or expiry doesn't change the catalog or break a selection. It withdraws them when the registration is removed, when its contributing client leaves under `contributingClient` retention, when it enters `error`, or when a change to `provider`, `format`, or `definition` mints new model IDs (see Reserved model IDs below). A turn that uses a listed model while the source has no usable credential fails like a mid-turn credential failure ([§6](#rotation-expiry-and-revocation)). The host MAY list the `ModelSourceInfo` in any state, since #543 allows a source with no models. Each model follows #543's catalog rules: @@ -545,10 +545,10 @@ A selection that names a removed source's model fails. The host MUST NOT run the ### Rotation, expiry, and revocation -- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce. The host MAY pass through `starting` while the agent re-lists models, keeping model IDs stable. +- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. - **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired` and a new nonce. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. - **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: expired` and a new nonce. Under the expiry rule, no client sends the revoked secret again, including other devices that have it stored, and the new nonce rejects a delivery that was already in flight. -- **Mid-turn.** If the credential fails during a turn that uses the source, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. +- **Mid-turn.** If the credential fails during a turn that uses the source, or a turn starts while the source has no usable credential, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. ### Host restart @@ -588,7 +588,6 @@ Hosts apply policy appropriate to the source, for example by declining registrat - **Keys that survive a restart.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. - **Several users on one host.** AHP can't verify which client is which, so this proposal, like MCP, trusts every connected client equally, and every client sees every definition. A host shared by several users would need verified client identities, per-client access control, and a way to hide registrations from clients that may not use them. That last part would be a new pattern for root state. - **Duplicates.** Two devices that sync the same configuration can register under the same `id` and share one registration. Devices that don't sync get two registrations for the same service. Should a host merge them? -- **Catalog across a re-auth.** Models are listed only while a source is `ready`, so a credential refresh briefly removes them. Should the host keep listing them during `authRequired`? - **Re-registering unchanged sources.** A client-dispatched `Set` clears the reported status until the host reports again, so clients compare before they register again. Would a revision field be clearer? --- From 5b85a8b76953e53d8bd53eba966a46e39b141ec7 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 10:33:57 -0500 Subject: [PATCH 07/11] docs: fence stale agent results and keep the credential resource Treat `credentialNonce` as the registration's generation. The host issues a new one when a registration is added or its provider, format, or definition changes, even with no credential held, as well as on every credential change. It tags every agent operation with the current nonce and discards any result with an older one, so a late result can't mark a re-registered or reverted registration ready. Move the credential's RFC 9728 metadata from the `authRequired` state to a host-reported `credentialResource` on the registration, kept in every state. A client that connects while a source is ready can then rotate or revoke its credential. `ModelSourceAuthRequirement` keeps `reason` and `description`. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 75 +++++++++++++++---------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 7be3ce42b..46ce9e984 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -127,12 +127,30 @@ export interface ModelSourceRegistration { */ state?: ModelSourceState; /** - * Host-issued token that a client echoes when it delivers the credential. - * The host issues a new one whenever the credential is installed or - * dropped, and never reuses one for the same `id`. Set with `state`. + * Host-issued token that a client echoes when it delivers the credential, + * and that tags every agent operation on the registration. The host issues + * a new one when the registration is added, when its `provider`, `format`, + * or `definition` changes, and whenever the credential is installed or + * dropped. It never reuses one for the same `id`. Set with `state`. * See §4.4. */ credentialNonce?: string; + /** + * RFC 9728 metadata for the endpoint the credential is for. Present + * whenever the source takes a credential, in every state, so any client + * can deliver, rotate, or revoke one. Absent for a source that needs no + * credential. Set with `state`. + * + * `credentialResource.resource` is the endpoint URL as the definition + * names it, in any scheme the agent supports (for example + * `http://localhost:11434/v1`). It's the value a client passes back as + * `authenticate({ resource })`, and nothing fetches it. + * `credentialResource.resource_name` labels the prompt (for example + * "OpenRouter API key"). A source that accepts OAuth access tokens + * advertises `authorization_servers` and `scopes_supported`. A source + * that takes a user-supplied secret omits them. + */ + credentialResource?: ProtectedResourceMetadata; _meta?: Record; } ``` @@ -176,25 +194,15 @@ export interface ModelSourceReadyState { } /** - * What a model source needs in order to become ready. Deliberately - * carries no credential. + * Why a model source needs a credential before it can be ready. Deliberately + * carries no credential. The endpoint the credential is for is the + * registration's `credentialResource`. * * @preserveUnknownMembers */ export interface ModelSourceAuthRequirement { /** Why a credential is needed. */ reason: AuthRequiredReason; - /** - * RFC 9728 metadata for the source's endpoint. `resource.resource` is - * the endpoint URL as the definition names it, in any scheme the agent - * supports (for example `http://localhost:11434/v1`). It's the value a - * client passes back as `authenticate({ resource })`, and nothing fetches - * it. `resource.resource_name` labels the prompt (for example - * "OpenRouter API key"). A source that accepts OAuth access tokens - * advertises `authorization_servers` and `scopes_supported`. A source - * that takes a user-supplied secret omits them. - */ - resource: ProtectedResourceMetadata; /** Human-readable hint the host writes, for example "The endpoint rejected the API key." */ description?: string; } @@ -244,18 +252,21 @@ The host reports status with its own narrow action, as it does for MCP servers w // types/channels-root/actions.ts /** - * Updates a registration's status and credential nonce. A no-op when no - * registration has `id`. Only the host dispatches it. + * Updates a registration's status, credential nonce, and credential + * resource together. A no-op when no registration has `id`. Only the host + * dispatches it. */ export interface RootModelSourceStateChangedAction { type: ActionType.RootModelSourceStateChanged; // 'root/modelSourceStateChanged' id: string; state: ModelSourceState; credentialNonce: string; + /** Replaces the registration's `credentialResource`. Absent clears it. */ + credentialResource?: ProtectedResourceMetadata; } ``` -Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only `state` and `credentialNonce`, it can't overwrite a client's newer definition. The host also discards an agent result for a definition the registration no longer has, so a slow result for an old definition can't mark a new one `ready`. +Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the three host-reported fields, it can't overwrite a client's newer definition. The host also tags every agent operation on the registration, such as validation, model discovery, and inference, with its current `credentialNonce`, and discards any result whose nonce is no longer current ([§4.4](#_4-4-credential-delivery-through-authenticate)). A slow result from before a definition change, a re-registration, or a key change therefore can't mark the current registration `ready`, even when the definition has changed back to the same value. ### 4.3 Registering and removing @@ -285,20 +296,20 @@ export interface RootModelSourceRegistrationRemovedAction { The reducers follow the keyed-collection convention: `Set` appends or replaces by `id`, and `Removed` deletes by `id` or returns the state unchanged. -A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state` or `credentialNonce`. Replacing the registration clears its status until the host reports again with `root/modelSourceStateChanged`, so a client SHOULD NOT dispatch `Set` for a registration that hasn't changed. +A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state`, `credentialNonce`, or `credentialResource`. Replacing the registration clears those host-reported fields until the host reports again with `root/modelSourceStateChanged`, so a client SHOULD NOT dispatch `Set` for a registration that hasn't changed. Like MCP servers, registrations have no per-client ownership. Any client can change or remove any registration, and the client that changes one becomes its contributing client. A host MAY reject client changes to a registration it created itself. The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionReason`, when: - the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; -- `clientId` isn't the dispatching client's ID, or `state` or `credentialNonce` is present; +- `clientId` isn't the dispatching client's ID, or `state`, `credentialNonce`, or `credentialResource` is present; - `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same registration doesn't count, so a ready registration can still be updated; - the host won't honor the requested `retention`. The client can register again with `contributingClient` retention. A client-dispatched `Removed` carries only an `id`. When no registration has that `id`, the action is a no-op, as the keyed-collection convention requires. -When a `Set` changes an existing registration's `provider`, `format`, or `definition`, the host drops its credential, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A change to `name`, `icons`, `clientId`, or `retention` keeps the credential. +When a `Set` changes an existing registration's `provider`, `format`, or `definition`, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A change to `name`, `icons`, `clientId`, or `retention` keeps the credential and the nonce. ### 4.4 Credential delivery through `authenticate` @@ -358,22 +369,24 @@ The `token` is an opaque secret. The agent applies it as the definition specifie Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. The host rejects an untargeted `resource` that matches only model source challenges with `InvalidParams` (`-32602`). Untargeted tokens keep working for MCP servers and agent-level resources. -`credentialNonce` fences every credential change. The host issues a new nonce whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation, and when a change to `provider`, `format`, or `definition` drops it ([§4.3](#_4-3-registering-and-removing)). That includes a removed registration that's registered again under the same `id`. An `authenticate` built before any of those changes is stale, so: +`credentialNonce` fences every credential change, and works as the registration's generation. The host issues a new nonce whenever a registration is added, including one registered again under a removed `id`, and whenever its `provider`, `format`, or `definition` changes, whether or not it held a credential. It also issues one whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation. An `authenticate` built before any of those changes is stale, so: - a key meant for an old definition never reaches a new one, even when the endpoint didn't change; - a rotation that crosses a revocation can't undo the revocation; - when two clients answer the same `authRequired`, the first wins, and the second gets `Conflict`, re-reads state, and finds the source ready. -The host also tags each request with the nonce of the key it used, and ignores a failure from a request made with an older key, so a late failure can't drop a key that has since replaced it. Random values meet the rule that a nonce is never reused for the same `id`. +The host tags every agent operation on the registration with the current nonce and discards any result, success or failure, that carries an older one. A late failure can't drop a key that has since replaced it, and a late success can't mark a changed or re-registered source `ready`, even after an edit that changes the definition back. Random values meet the rule that a nonce is never reused for the same `id`. + +`credentialResource` and `credentialNonce` stay in root state for as long as the source takes a credential, not only while it's `authRequired`. Any client, including one that connected after the source became ready, can build an `authenticate` request at any time: to rotate a short-lived token before it expires, or to revoke a key with an empty token. Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMembers`: the client builds it for one request, so there are no unknown members to keep. -`resource.resource` doesn't need to be an `https` URL, unlike other RFC 9728 resource identifiers. RFC 9728 requires `https` because an OAuth client fetches metadata from that URL. Here the client only echoes the value, so a local server such as `http://localhost:11434/v1` works. Whether the agent sends a credential over plain `http` is the host's network policy. +`credentialResource.resource` doesn't need to be an `https` URL, unlike other RFC 9728 resource identifiers. RFC 9728 requires `https` because an OAuth client fetches metadata from that URL. Here the client only echoes the value, so a local server such as `http://localhost:11434/v1` works. Whether the agent sends a credential over plain `http` is the host's network policy. When `target.kind` is `modelSource`, the host: - MUST apply the credential only to that registration. It never applies it to other registrations, MCP servers, or agent-level resources, even when they share `resource`. -- MUST require `resource` to equal the `resource.resource` it most recently advertised for that registration. +- MUST require `resource` to equal the registration's current `credentialResource.resource`. - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). - MUST reject a `credentialNonce` other than the one it most recently issued for that registration with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. - MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: expired`, so no client sends the revoked secret again. @@ -469,8 +482,8 @@ What a follow-up implementation would touch: | Symbol | File | Kind | | --- | --- | --- | -| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including the host-issued `credentialNonce`) | `channels-root/state.ts` | added | -| `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement` | `channels-root/state.ts` | added (lifecycle union) | +| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including the host-reported `credentialNonce` and `credentialResource`) | `channels-root/state.ts` | added | +| `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement` (`reason` and `description`) | `channels-root/state.ts` | added (lifecycle union) | | `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | | `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability` | `channels-root/state.ts` | added (capability) | | `root/modelSourceRegistrationSet`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | @@ -499,7 +512,7 @@ sequenceDiagram C->>H: root/modelSourceRegistrationSet (id, provider, format, definition) H->>A: read and validate the definition - H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce) + H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce, credentialResource) C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId, credentialNonce } }) H-->>C: {} @@ -517,7 +530,7 @@ sequenceDiagram 1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. 2. It dispatches `root/modelSourceRegistrationSet`. The host's agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. -3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`. The client calls `authenticate` with a `modelSource` target that echoes it. +3. If a credential is needed, the host reports `authRequired` with a `credentialNonce` and the `credentialResource` the key is for. The client calls `authenticate` with that `resource` and a `modelSource` target that echoes the nonce. 4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and adds the source and its models to the agent's catalog. 5. Any client can select those models in any session on that agent, and so can automations if the source has `host` retention. 6. When the contributing client disconnects, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). @@ -558,7 +571,7 @@ Credentials are gone after a restart, because they were never persisted. `contri ## 7. Credential rules -1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. +1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, `credentialResource`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. 3. **Scoped to one registration and one `credentialNonce`.** It is never shared with other registrations, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. 4. **Attached only to that source's requests**, as its definition specifies. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. From 913d86487dcc0aa24fcab71812b86c7770e671f9 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 12:56:02 -0500 Subject: [PATCH 08/11] docs: contributors, credential identity, and turn rules for the registry Address the cross-model review of the registry design: - A registration lists its contributing clients. `Set` adds, joins an unchanged definition without disturbing host-reported fields, or replaces a changed one. A new `root/modelSourceContributorRemoved` withdraws one client's contribution. A `contributingClient` source goes away when its last contributor leaves, and the last explicit withdrawal removes a source whatever its retention. - `credentialId` names the key the host holds, and `credentialOrigins` lists every origin it's sent to. Model sources get their own auth reasons: required, expired, rejected, and revoked. - Clients never cache or replay a credential, and deliver one only in answer to the registration's state. Endpoints resolve on the host, and hosts SHOULD apply an egress policy. - Withdrawal, removal, and revocation stop work at once, and turns on an unavailable source end with a resumable `modelSourceUnavailable` error. `expiresIn` on a static key is a lease. - The capability advertises the contributor grace period and whether the registry is shared across principals. - Model IDs SHOULD be derived deterministically. `modelSourceId` alone doesn't mark a registered source. Rename `name` to `displayName`. - AHP doesn't define, standardize, or name any definition format, and AHP does have host-to-client requests. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 358 ++++++++++++++++-------- 1 file changed, 240 insertions(+), 118 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 46ce9e984..830dc1e99 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -19,7 +19,8 @@ It assumes the direction #543 is taking after review: - A **model source** is #543's term for an independently selectable source of model access, described by `ModelSourceInfo` in an agent's catalog. - A **registration** is a model source a client or the host added to the host's registry, with its definition and status. - A **model source definition** is the content of a registration that says how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. -- The **contributing client** is the client that most recently registered or changed a source. A registration's `clientId` names it. +- A **contributing client** is a client that registered a source and still wants it. Several clients, such as two windows or two devices, can contribute the same source. A registration's `contributingClientIds` lists them. +- A **principal** is the user or account a host has verified a client acts for. AHP doesn't define how a host verifies one. - An **agent provider** is the existing `provider` field (`AgentInfo.provider`). Nothing new is called a "provider". --- @@ -51,12 +52,12 @@ The agent behind the host does the heavy lifting. It owns: AHP carries only four things: -1. **Registration.** A client adds, updates, or removes a model source definition. +1. **Registration.** A client contributes a model source definition, or withdraws its contribution. 2. **Status.** The host reports whether each source is starting, ready, needs a credential, or failed. 3. **Credential.** A client supplies a secret, scoped to one registered source. 4. **Selection.** The source's models appear in the agent's catalog and are selected like any other model. -AHP names a definition's format but does not define it. +AHP names a definition's format but never defines, standardizes, or names one: `format` and `definition` are opaque to AHP and belong to the agent. --- @@ -67,14 +68,14 @@ AHP names a definition's format but does not define it. - **Keyed collections.** The registry follows the `Set` and `Removed` convention used for `activeClients`, `customizations`, and other keyed lists. - **MCP server authentication.** An MCP server publishes `McpServerAuthRequiredState`, and the client answers with `authenticate` and a `target` naming that server. The [authentication spec](/specification/authentication#why-keyed-by-resource-and-optional-target) notes that `target.kind` is extensible for exactly this kind of addition. - **MCP server status.** The host reports a server's lifecycle with `session/mcpServerStateChanged`, a narrow action that updates only the server's state. A registration's status works the same way. -- **No per-client ownership.** Any client in a session can start, stop, or enable an MCP server and answer its authentication challenge. AHP checks a `clientId` only to route a client tool's result back from the client that runs it. Registrations follow the same model: every connected client can use and change them, and access control between clients is host policy. -- **Container provenance.** A client-published plugin carries the publisher's `clientId` and a host-reported `load` state that is absent until the host reports one. A registration works the same way. +- **No per-client ownership.** Any client in a session can start, stop, or enable an MCP server and answer its authentication challenge. AHP checks a `clientId` only to route a client tool's result back from the client that runs it. Registrations follow the same model by default: every connected client can use and change them. A host that can verify principals MAY restrict them ([§4.7](#_4-7-discovering-support)). +- **Container provenance.** A client-published plugin carries the publisher's `clientId` and a host-reported `load` state that is absent until the host reports one. A registration lists its contributing clients the same way, and its host-reported fields are absent until the host reports them. --- ## 4. Proposed surface -Everything here is additive and optional. It adds one root state field, three root actions (two of them client-dispatchable), one `authenticate` target, and one agent capability. There are no new commands, notifications, error codes, or channels. +Everything here is additive and optional. It adds one root state field, four root actions (three of them client-dispatchable), one `authenticate` target, one agent capability, and one well-known `ErrorInfo.errorType`. There are no new commands, notifications, error codes, or channels. ### 4.1 The registry @@ -88,8 +89,8 @@ export interface RootState { } /** - * A model source registered on this host by a client, or by the host - * itself. Its definition is in a format the agent named by `provider` + * A model source registered on this host by one or more clients, or by the + * host itself. Its definition is in a format the agent named by `provider` * reads. It never contains a credential. * * @category Root State @@ -105,8 +106,8 @@ export interface ModelSourceRegistration { id: string; /** Agent provider whose agent reads the definition and serves the models. */ provider: string; - /** Display name, published as `ModelSourceInfo.displayName`. */ - name: string; + /** Human-readable name, published as `ModelSourceInfo.displayName`. */ + displayName: string; /** Icons for UI display. */ icons?: Icon[]; /** Definition format, one of the agent's `ModelSourceRegistrationCapability.formats`. */ @@ -116,48 +117,55 @@ export interface ModelSourceRegistration { * `format`. MUST NOT contain a credential. */ definition: Record; - /** The contributing client. Absent for a source the host registered itself. */ - clientId?: string; - /** What happens when the contributing client leaves. Absent means `contributingClient`. */ - retention?: ModelSourceRetentionPolicy; /** - * Host-reported status, set with `root/modelSourceStateChanged`. Absent - * until the host reports one, and after a client replaces the - * registration until the host reports again. + * The clients that contribute this registration, in the order they + * joined. The reducer maintains it. Absent when no client contributes it: + * a source the host registered itself, or a `host`-retained one whose + * contributors have all left. */ + contributingClientIds?: string[]; + /** What happens when the last contributing client leaves. Absent means `contributingClient`. */ + retention?: ModelSourceRetentionPolicy; + + // Host-reported fields, set together with `root/modelSourceStateChanged`. + // Absent until the host reports, and after a `Set` replaces the + // registration until the host reports again. + + /** Host-reported status. */ state?: ModelSourceState; /** * Host-issued token that a client echoes when it delivers the credential, - * and that tags every agent operation on the registration. The host issues - * a new one when the registration is added, when its `provider`, `format`, - * or `definition` changes, and whenever the credential is installed or - * dropped. It never reuses one for the same `id`. Set with `state`. - * See §4.4. + * and that tags every agent operation on the registration. See §4.4. */ credentialNonce?: string; /** * RFC 9728 metadata for the endpoint the credential is for. Present * whenever the source takes a credential, in every state, so any client * can deliver, rotate, or revoke one. Absent for a source that needs no - * credential. Set with `state`. - * - * `credentialResource.resource` is the endpoint URL as the definition - * names it, in any scheme the agent supports (for example - * `http://localhost:11434/v1`). It's the value a client passes back as - * `authenticate({ resource })`, and nothing fetches it. - * `credentialResource.resource_name` labels the prompt (for example - * "OpenRouter API key"). A source that accepts OAuth access tokens - * advertises `authorization_servers` and `scopes_supported`. A source - * that takes a user-supplied secret omits them. + * credential. */ credentialResource?: ProtectedResourceMetadata; + /** + * Every origin the host sends the credential to, such as + * `https://api.example.com`. Present whenever `credentialResource` is. + */ + credentialOrigins?: URI[]; + /** + * The client-supplied ID of the credential the host most recently + * accepted. While the state is `starting` or `ready`, the host holds it. + * While it's `authRequired`, `reason` says what happened to it. Absent + * until the host accepts a credential. + */ + credentialId?: string; _meta?: Record; } ``` -`definition` is intentionally open data: its shape belongs to the agent that reads it. It lives in root state so a client can compare it with its own configuration and register again only when something changed. +`definition` is intentionally open data. AHP doesn't define, standardize, or name any definition format: `format` and `definition` are opaque to AHP and belong to the agent that reads them. The definition lives in root state so a client can compare it with its own configuration. + +`credentialResource.resource` is the endpoint URL as the definition names it, and the value a client passes back as `authenticate({ resource })`. `credentialResource.resource_name` labels the prompt, for example "OpenRouter API key". A source that accepts OAuth access tokens advertises `authorization_servers` and `scopes_supported`. A source that takes a user-supplied secret omits them. A source whose models use several endpoints lists every origin in `credentialOrigins`, so a client can check them all before it sends a key ([§7](#_7-credential-rules)). -A host may register sources itself, for example from configuration on a remote machine. Those registrations have no `clientId`, and their retention behaves as `host`. +A host may register sources itself, for example from configuration on a remote machine. Those registrations have no contributing clients, and their retention behaves as `host`. ### 4.2 Status @@ -183,6 +191,23 @@ export const enum ModelSourceStatus { Error = 'error', } +/** + * Why a model source needs a credential. + * + * @category Root State + * @nonexhaustive + */ +export const enum ModelSourceAuthRequiredReason { + /** The host holds no credential yet. */ + Required = 'required', + /** The credential's lifetime or lease lapsed. Renewing it is fine. */ + Expired = 'expired', + /** The endpoint refused the credential. Clients don't send one with the same `credentialId` again. */ + Rejected = 'rejected', + /** A client revoked the credential. Clients don't send one again without a user's action. */ + Revoked = 'revoked', +} + /** @preserveUnknownMembers */ export interface ModelSourceStartingState { kind: ModelSourceStatus.Starting; @@ -202,7 +227,7 @@ export interface ModelSourceReadyState { */ export interface ModelSourceAuthRequirement { /** Why a credential is needed. */ - reason: AuthRequiredReason; + reason: ModelSourceAuthRequiredReason; /** Human-readable hint the host writes, for example "The endpoint rejected the API key." */ description?: string; } @@ -227,6 +252,8 @@ export type ModelSourceState = | ModelSourceErrorState; ``` +The reasons are specific to model sources. The shared `AuthRequiredReason` folds rejection and revocation into `expired`, so a client that renews automatically could undo a user's revocation, or keep resending a key the endpoint refused. + ```mermaid stateDiagram-v2 [*] --> starting : source registered @@ -246,15 +273,14 @@ stateDiagram-v2 The host can remove a registration from any state (see [§6](#_6-lifecycle)). -The host reports status with its own narrow action, as it does for MCP servers with `session/mcpServerStateChanged`. It never reports status by dispatching the client's whole registration back. +The host reports status with its own narrow action, as it does for MCP servers with `session/mcpServerStateChanged`. It never reports status by dispatching the registration back. ```ts // types/channels-root/actions.ts /** - * Updates a registration's status, credential nonce, and credential - * resource together. A no-op when no registration has `id`. Only the host - * dispatches it. + * Updates a registration's host-reported fields together. A no-op when no + * registration has `id`. Only the host dispatches it. */ export interface RootModelSourceStateChangedAction { type: ActionType.RootModelSourceStateChanged; // 'root/modelSourceStateChanged' @@ -263,28 +289,51 @@ export interface RootModelSourceStateChangedAction { credentialNonce: string; /** Replaces the registration's `credentialResource`. Absent clears it. */ credentialResource?: ProtectedResourceMetadata; + /** Replaces the registration's `credentialOrigins`. Absent clears it. */ + credentialOrigins?: URI[]; + /** Replaces the registration's `credentialId`. Absent clears it. */ + credentialId?: string; } ``` -Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the three host-reported fields, it can't overwrite a client's newer definition. The host also tags every agent operation on the registration, such as validation, model discovery, and inference, with its current `credentialNonce`, and discards any result whose nonce is no longer current ([§4.4](#_4-4-credential-delivery-through-authenticate)). A slow result from before a definition change, a re-registration, or a key change therefore can't mark the current registration `ready`, even when the definition has changed back to the same value. +Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the host-reported fields, it can't overwrite a client's newer definition. The host also tags every agent operation on the registration, such as validation, model discovery, and inference, with its current `credentialNonce`, and discards any result whose nonce is no longer current ([§4.4](#_4-4-credential-delivery-through-authenticate)). A slow result from before a definition change, a re-registration, or a key change therefore can't mark the current registration `ready`, even when the definition has changed back to the same value. + +### 4.3 Contributing, withdrawing, and removing -### 4.3 Registering and removing +Several clients, such as two windows or two devices, can want the same source. Each one contributes it, and each one withdraws only its own contribution. ```ts // types/channels-root/actions.ts /** - * Adds a model source registration, or replaces the one with the same `id`. + * Contributes a model source registration for `clientId`: adds it, joins + * an existing one with the same routing, or replaces one whose routing + * changed. * * @clientDispatchable */ export interface RootModelSourceRegistrationSetAction { type: ActionType.RootModelSourceRegistrationSet; // 'root/modelSourceRegistrationSet' registration: ModelSourceRegistration; + /** The contributing client. Absent when the host registers the source itself. */ + clientId?: string; +} + +/** + * Withdraws `clientId`'s contribution. A no-op when no registration has + * `id`, or `clientId` doesn't contribute it. + * + * @clientDispatchable + */ +export interface RootModelSourceContributorRemovedAction { + type: ActionType.RootModelSourceContributorRemoved; // 'root/modelSourceContributorRemoved' + id: string; + clientId: string; } /** - * Removes a model source registration. A no-op when none matches. + * Removes a model source registration for every contributor. A no-op when + * none matches. * * @clientDispatchable */ @@ -294,22 +343,35 @@ export interface RootModelSourceRegistrationRemovedAction { } ``` -The reducers follow the keyed-collection convention: `Set` appends or replaces by `id`, and `Removed` deletes by `id` or returns the state unchanged. +A registration's routing is its `provider`, `format`, and `definition`, with definitions compared as JSON values, ignoring object key order. The reducers apply the actions as follows: -A client registers by dispatching `Set` with `clientId` set to its own ID, and with no `state`, `credentialNonce`, or `credentialResource`. Replacing the registration clears those host-reported fields until the host reports again with `root/modelSourceStateChanged`, so a client SHOULD NOT dispatch `Set` for a registration that hasn't changed. +- **Add.** When no registration has the `id`, `Set` appends the registration, with `contributingClientIds` set to `[clientId]`, or absent when there's no `clientId`. +- **Join.** When one has, and its routing is unchanged, `Set` keeps the existing host-reported fields (`state`, `credentialNonce`, `credentialResource`, `credentialOrigins`, and `credentialId`), adds `clientId` to `contributingClientIds` if it isn't there, and takes `displayName`, `icons`, `retention`, and `_meta` from the action. Joining doesn't disturb the status, nonce, or credential. +- **Replace.** When the routing changed, `Set` replaces the registration, with `contributingClientIds` set to `[clientId]`. The other contributors wanted a different definition, so they're no longer contributors. The host-reported fields are absent until the host reports again. +- **Withdraw.** `root/modelSourceContributorRemoved` removes `clientId` from `contributingClientIds`, leaving the field absent when no contributor remains. It never removes the registration. The host does that with `Removed`. +- **Remove.** `Removed` deletes the registration by `id`, or returns the state unchanged. -Like MCP servers, registrations have no per-client ownership. Any client can change or remove any registration, and the client that changes one becomes its contributing client. A host MAY reject client changes to a registration it created itself. +A client contributes by dispatching `Set` with its own `clientId`, and without `contributingClientIds` or any host-reported field. It dispatches `Set` when it starts with the source configured and isn't already a contributor, for example a second window, or a window that reloaded with a new `clientId`. When contributors disagree on `displayName`, `icons`, `retention`, or `_meta`, the last `Set` wins. + +A client SHOULD derive `id` from a stable key in its own configuration, so every device and window that has the same source configured shares one registration. A client SHOULD NOT replace a registration whose routing differs from its own copy unless the user changed the source in its configuration. Otherwise, two clients with different configurations would replace each other's registration indefinitely. + +When the user removes the source from a client's configuration, the client withdraws its own contribution. It dispatches `Removed` only to remove the source for every contributor, for example from a host-wide management view. The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionReason`, when: - the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; -- `clientId` isn't the dispatching client's ID, or `state`, `credentialNonce`, or `credentialResource` is present; -- `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same registration doesn't count, so a ready registration can still be updated; -- the host won't honor the requested `retention`. The client can register again with `contributingClient` retention. +- `clientId` is absent or isn't the dispatching client's ID; +- the registration includes `contributingClientIds` or any host-reported field; +- `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same registration doesn't count, so a ready registration can still be joined or changed; +- the host won't honor the requested `retention`. The client can register again with `contributingClient` retention; +- the registration is one the host registered itself; +- the host restricts registrations by principal, and the existing registration belongs to another principal ([§4.7](#_4-7-discovering-support)). -A client-dispatched `Removed` carries only an `id`. When no registration has that `id`, the action is a no-op, as the keyed-collection convention requires. +The host rejects a client-dispatched `root/modelSourceContributorRemoved` whose `clientId` isn't the dispatching client's ID. A host MAY reject a client's `Removed` for a registration it registered itself, or one that belongs to another principal. -When a `Set` changes an existing registration's `provider`, `format`, or `definition`, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A change to `name`, `icons`, `clientId`, or `retention` keeps the credential and the nonce. +When a client's own withdrawal leaves a registration with no contributors, the host removes it with `Removed`, whatever its retention: the last client that wanted it has withdrawn. When a contributor leaves instead, retention decides ([§6](#_6-lifecycle)). + +When a `Set` replaces a registration's routing, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A join, or a change to `displayName`, `icons`, `retention`, or `_meta`, keeps the credential and the nonce. ### 4.4 Credential delivery through `authenticate` @@ -339,6 +401,12 @@ export interface ModelSourceAuthenticateTarget { * state. The host rejects a stale one with `Conflict` (-32011). */ credentialNonce: string; + /** + * A client-chosen, non-secret ID for the credential, such as a hash of + * where the client stores the key. The host publishes it as the + * registration's `credentialId`. MUST NOT be derived from the secret. + */ + credentialId?: string; } export type AuthenticateTarget = @@ -359,7 +427,8 @@ export type AuthenticateTarget = "target": { "kind": "modelSource", "modelSourceId": "2f6c0e1a-model-source", - "credentialNonce": "9b41d7" + "credentialNonce": "9b41d7", + "credentialId": "keychain-5c2a" } } } @@ -369,7 +438,9 @@ The `token` is an opaque secret. The agent applies it as the definition specifie Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. The host rejects an untargeted `resource` that matches only model source challenges with `InvalidParams` (`-32602`). Untargeted tokens keep working for MCP servers and agent-level resources. -`credentialNonce` fences every credential change, and works as the registration's generation. The host issues a new nonce whenever a registration is added, including one registered again under a removed `id`, and whenever its `provider`, `format`, or `definition` changes, whether or not it held a credential. It also issues one whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation. An `authenticate` built before any of those changes is stale, so: +Clients SHOULD include `credentialId` when they deliver a credential, and omit it when they revoke one. It lets a client that reloads, or one on another device, tell whether the host holds its current key. + +`credentialNonce` fences every credential change, and works as the registration's generation. The host issues a new nonce whenever a registration is added, including one registered again under a removed `id`, and whenever its routing changes, whether or not it held a credential. It also issues one whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation. An `authenticate` built before any of those changes is stale, so: - a key meant for an old definition never reaches a new one, even when the endpoint didn't change; - a rotation that crosses a revocation can't undo the revocation; @@ -377,11 +448,21 @@ Clients MUST include a `modelSource` target when they deliver a registered sourc The host tags every agent operation on the registration with the current nonce and discards any result, success or failure, that carries an older one. A late failure can't drop a key that has since replaced it, and a late success can't mark a changed or re-registered source `ready`, even after an edit that changes the definition back. Random values meet the rule that a nonce is never reused for the same `id`. -`credentialResource` and `credentialNonce` stay in root state for as long as the source takes a credential, not only while it's `authRequired`. Any client, including one that connected after the source became ready, can build an `authenticate` request at any time: to rotate a short-lived token before it expires, or to revoke a key with an empty token. +The credential fields stay in root state for as long as the source takes a credential, not only while it's `authRequired`. Any client, including one that connected after the source became ready, can build an `authenticate` request at any time: to rotate a short-lived token before it expires, or to revoke a key with an empty token. + +**When a client delivers.** A client delivers a credential only in answer to the registration's current state, reading it from its own secure storage or token provider each time. It MUST NOT cache a credential it delivered, or replay one, for example after a reconnect. It delivers one when: + +- the state is `authRequired` with reason `required`; +- the reason is `expired`, with a renewed credential: a fresh token, or the same static key with a new lease; +- the reason is `rejected`, only a credential whose `credentialId` differs from the registration's; +- the state is `starting` or `ready`, and the registration's `credentialId` names a key this client has since replaced, for example one it delivered before the user changed it. A client whose key simply differs leaves the host's credential alone, so two devices with different working keys don't replace each other's in turn; +- a lease it set is about to expire. + +After `revoked`, a client delivers a credential only when a user asks it to. Before it sends any secret, a client checks the registration against its own copy ([§7](#_7-credential-rules)). Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMembers`: the client builds it for one request, so there are no unknown members to keep. -`credentialResource.resource` doesn't need to be an `https` URL, unlike other RFC 9728 resource identifiers. RFC 9728 requires `https` because an OAuth client fetches metadata from that URL. Here the client only echoes the value, so a local server such as `http://localhost:11434/v1` works. Whether the agent sends a credential over plain `http` is the host's network policy. +`credentialResource.resource` doesn't need to be an `https` URL, unlike other RFC 9728 resource identifiers. RFC 9728 requires `https` because an OAuth client fetches metadata from that URL. Here the client only echoes the value, so a local server such as `http://localhost:11434/v1` works. Where the host actually sends the credential is governed by its egress policy ([§7](#_7-credential-rules)). When `target.kind` is `modelSource`, the host: @@ -389,20 +470,23 @@ When `target.kind` is `modelSource`, the host: - MUST require `resource` to equal the registration's current `credentialResource.resource`. - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). - MUST reject a `credentialNonce` other than the one it most recently issued for that registration with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. -- MUST treat an empty `token` as revocation: it drops the credential, and the source returns to `authRequired` with `reason: expired`, so no client sends the revoked secret again. +- MUST publish the target's `credentialId` as the registration's `credentialId` when it accepts a credential. +- MUST treat an empty `token` as revocation: it stops using the credential at once, drops it, and reports `authRequired` with `reason: revoked`. -Any client may deliver or revoke a registration's credential, as any client may answer an MCP server's challenge. +Any client may deliver or revoke a registration's credential, as any client may answer an MCP server's challenge, unless the host restricts credentials by principal ([§4.7](#_4-7-discovering-support)). It then rejects a credential from another principal's client with `PermissionDenied` (`-32009`). -`expiresIn` keeps its current meaning and applies to short-lived tokens such as Microsoft Entra ID access tokens. API keys omit it. +`expiresIn` keeps its meaning for short-lived tokens such as Microsoft Entra ID access tokens. With a static key, it's a lease: the host drops the key when the lease elapses and reports `expired`, and a client renews the lease by sending the key again. An API key without a lease omits it. ### 4.5 Models and selection When a registration is `ready`, the host adds it to the catalog of the agent named by `provider`, through `root/agentsChanged`: -- a `ModelSourceInfo` in `AgentInfo.modelSources`, with the registration's `id` and its `name` as `displayName`; +- a `ModelSourceInfo` in `AgentInfo.modelSources`, with the registration's `id` and `displayName`; - its models in `AgentInfo.models`, each with `modelSourceId` set to the registration's `id`. -The host adds a registration's models when it first becomes `ready`, and keeps them listed through later `starting` and `authRequired` states, so a key rotation or expiry doesn't change the catalog or break a selection. It withdraws them when the registration is removed, when its contributing client leaves under `contributingClient` retention, when it enters `error`, or when a change to `provider`, `format`, or `definition` mints new model IDs (see Reserved model IDs below). A turn that uses a listed model while the source has no usable credential fails like a mid-turn credential failure ([§6](#rotation-expiry-and-revocation)). The host MAY list the `ModelSourceInfo` in any state, since #543 allows a source with no models. +`modelSourceId` alone doesn't mark a registered source: #543 also uses it to group an agent's own models. Registration provenance is the signal: a source is registered when `modelSourceRegistrations` has an entry with that `id` whose `provider` is the agent. + +The host adds a registration's models when it first becomes `ready`, and keeps them listed through later `starting` and `authRequired` states, so a key rotation or expiry doesn't change the catalog or break a selection. It withdraws them when the registration is removed, when its last contributing client leaves under `contributingClient` retention, when it enters `error`, or when a routing change mints new model IDs (see Reserved model IDs below). A turn that uses a listed model while the source has no usable credential ends with the `modelSourceUnavailable` error ([§6](#turns-on-an-unavailable-source)). The host MAY list the `ModelSourceInfo` in any state, since #543 allows a source with no models. Each model follows #543's catalog rules: @@ -410,9 +494,11 @@ Each model follows #543's catalog rules: - `provider` stays the agent provider. - `vendor` MAY name the service that serves the model, for example `OpenRouter`. -**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a `definition` change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when a different client made the change. A host can meet this by minting IDs it never reuses, for example with a random component, rather than deriving them from the endpoint's model name. +**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a `definition` change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when a different client made the change. + +A host SHOULD derive each model's `id` deterministically from the registration (its `id`, `provider`, and `format`), the endpoint, and the endpoint's model identifier, for example with a hash. The same model then gets the same `id` when its source is registered again or the host restarts, without a stored table, and a moved endpoint gets a new one. Random IDs would break saved selections whenever a source is registered again, unless the host persists a table of them. -**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed and that the chat is backed by the registration's agent provider. It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. +**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed, that the chat is backed by the registration's agent provider, and, when it restricts registrations by principal, that the turn's client acts for the registration's principal. It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. **Sessions** need nothing new. Any session whose agent is the registration's `provider` can use its models, whichever client started the turn. There is no per-session list of registrations. @@ -420,34 +506,33 @@ Each model follows #543's catalog rules: ### 4.6 Retention -The contributing client chooses what happens to a registration when it leaves. The default is the narrower choice, so a client that doesn't set it behaves like a client that only uses its models while it's connected. +The contributing clients choose what happens to a registration when the last of them leaves. The default is the narrower choice, so clients that don't set it behave like clients that only use their models while one of them is connected. ```ts // types/channels-root/state.ts /** - * How long a registered model source lasts once its contributing client leaves. + * How long a registered model source lasts once its last contributing + * client leaves. * * @category Root State * @nonexhaustive */ export const enum ModelSourceRetentionPolicy { - /** Removed when the contributing client leaves, once running turns finish. */ + /** Removed when the last contributing client leaves, once running turns finish. */ ContributingClient = 'contributingClient', - /** Kept until a client removes it or host policy expires it. */ + /** Kept until it's removed, its last contributor withdraws, or host policy expires it. */ Host = 'host', } ``` -The two values mirror how MCP servers already behave. A `contributingClient` registration goes away with its client, like a client-published plugin. A `host` registration stays, like a host-declared server, so long-running sessions and automations keep working, with the key in memory, while the host runs. +The two values mirror how MCP servers already behave. A `contributingClient` registration goes away with its clients, like a client-published plugin. A `host` registration stays, like a host-declared server, so long-running sessions and automations keep working, with the key in memory, while the host runs. Explicit withdrawal is different from leaving: when the last contributor withdraws, the source goes away whatever its retention, so `host` retention doesn't leave sources nobody wants. -The host rejects `host` retention when it won't honor it ([§4.3](#_4-3-registering-and-removing)), and it MAY expire `host`-retained registrations by its own policy. - -Every client sees every registration, including its definition, because root state is shared. That suits the hosts this is designed for, where every connected client belongs to the same user. A host shared by several users needs its own policy, for example by declining registrations (see [§9](#_9-open-questions)). +The host rejects `host` retention when it won't honor it ([§4.3](#_4-3-contributing-withdrawing-and-removing)), and it MAY expire `host`-retained registrations by its own policy. ### 4.7 Discovering support -A client needs to know whether an agent accepts registrations, and in what format, before it registers. Unlike the per-agent markers #543 dropped, this capability carries information a client can't get any other way. +A client needs to know whether an agent accepts registrations, in what format, how long the host tolerates a disconnect, and whether the registry is shared across principals. Unlike the per-agent markers #543 dropped, this capability carries information a client can't get any other way. ```ts // types/channels-root/state.ts @@ -471,10 +556,37 @@ export interface ModelSourceRegistrationCapability { * don't collide. */ formats: string[]; + /** + * How long, in milliseconds, the host keeps a disconnected client's + * contributions before it treats the client as having left. + * + * @integer + * @minimum 0 + */ + gracePeriod?: number; + /** Whether clients acting for different principals share the registry. Absent means `shared`. */ + principalPolicy?: ModelSourcePrincipalPolicy; +} + +/** + * @category Root State + * @nonexhaustive + */ +export const enum ModelSourcePrincipalPolicy { + /** Every connected client may change, supply credentials for, and select every registration. */ + Shared = 'shared', + /** + * The host verifies principals, and limits changes, credentials, and + * selection of each registration to clients of the principal that + * registered it. + */ + Isolated = 'isolated', } ``` -A client that knows none of an agent's formats doesn't register with it. A format that becomes a shared standard can get a well-known name, and every agent that reads it can list it. +A client that knows none of an agent's formats doesn't register with it. AHP doesn't define, standardize, or name any format. + +**Principals.** AHP doesn't verify which client is which, so by default every connected client is trusted equally, as with MCP servers. Where a host can verify principals, it MAY restrict changes, credentials, and use of a registration to clients of the principal that registered it, and advertises `isolated`. Root state still lists every registration to every client, so a definition is never private. A host whose connections carry credentials scoped to one client, such as a relay that forwards each client's own sign-in, SHOULD NOT let one client's registration be used by another: it uses `isolated`, or doesn't advertise `modelSourceRegistration`. ### 4.8 Change table @@ -482,17 +594,18 @@ What a follow-up implementation would touch: | Symbol | File | Kind | | --- | --- | --- | -| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including the host-reported `credentialNonce` and `credentialResource`) | `channels-root/state.ts` | added | -| `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement` (`reason` and `description`) | `channels-root/state.ts` | added (lifecycle union) | +| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including `contributingClientIds` and the host-reported `credentialNonce`, `credentialResource`, `credentialOrigins`, and `credentialId`) | `channels-root/state.ts` | added | +| `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement`, `ModelSourceAuthRequiredReason` | `channels-root/state.ts` | added (lifecycle union) | | `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | -| `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability` | `channels-root/state.ts` | added (capability) | -| `root/modelSourceRegistrationSet`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | +| `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability`, `ModelSourcePrincipalPolicy` | `channels-root/state.ts` | added (capability) | +| `root/modelSourceRegistrationSet`, `root/modelSourceContributorRemoved`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | | `root/modelSourceStateChanged` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (host-only, introduced in the development version) | -| Root reducer | `channels-root/reducer.ts` | upsert, remove, and status change, with fixtures for every branch, including a status change for an unknown `id` | -| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the three root actions, so they pass the shared fixtures | -| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId` and `credentialNonce`), `AuthenticateTarget` | `common/commands.ts` | added, widened | +| Root reducer | `channels-root/reducer.ts` | add, join, replace, withdraw, remove, and status change, with fixtures for every branch | +| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the four root actions, so they pass the shared fixtures | +| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId`, `credentialNonce`, and `credentialId`), `AuthenticateTarget` | `common/commands.ts` | added, widened | | `AuthenticateParams.target` and `resource` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | -| `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources and reserved IDs | +| `ErrorInfo.errorType` docs | `common/state.ts` | the well-known `modelSourceUnavailable` value | +| `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources, provenance, and reserved IDs | | Generator registration | `scripts/generate-{csharp,go,kotlin,rust,swift}.ts` | new enums, structs, and union variants | | Root channel and authentication specs, naming dictionary | `docs/`, `.github/instructions/` | updated | @@ -508,45 +621,50 @@ sequenceDiagram participant E as Model endpoint C->>H: initialize - H-->>C: root snapshot (agent advertises modelSourceRegistration with formats) + H-->>C: root snapshot (agent advertises modelSourceRegistration with formats and gracePeriod) - C->>H: root/modelSourceRegistrationSet (id, provider, format, definition) + C->>H: root/modelSourceRegistrationSet (registration, clientId) H->>A: read and validate the definition - H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce, credentialResource) + H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce, credentialResource, credentialOrigins) - C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId, credentialNonce } }) + C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId, credentialNonce, credentialId } }) H-->>C: {} A->>E: list models (credential attached) E-->>A: models - H-->>C: root/modelSourceStateChanged (ready, new credentialNonce) + H-->>C: root/modelSourceStateChanged (ready, new credentialNonce, credentialId) H-->>C: root/agentsChanged (the source and its models join the agent catalog) C->>H: chat/turnStarted in any session on that agent (message.model: { id }) A->>E: inference (credential attached) - Note over C,H: Later, the client disconnects (host retention) + Note over C,H: Later, the last contributing client disconnects (host retention) Note over H,E: running sessions and automations keep using the source ``` 1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. -2. It dispatches `root/modelSourceRegistrationSet`. The host's agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. -3. If a credential is needed, the host reports `authRequired` with a `credentialNonce` and the `credentialResource` the key is for. The client calls `authenticate` with that `resource` and a `modelSource` target that echoes the nonce. -4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and adds the source and its models to the agent's catalog. -5. Any client can select those models in any session on that agent, and so can automations if the source has `host` retention. -6. When the contributing client disconnects, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). +2. It dispatches `root/modelSourceRegistrationSet` with its own `clientId`. The host's agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. +3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`, the `credentialResource` the key is for, and every origin it would send the key to. The client checks those against its own copy and calls `authenticate` with that `resource` and a `modelSource` target that echoes the nonce and names its key with `credentialId`. +4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and the `credentialId` it now holds. It adds the source and its models to the agent's catalog. +5. Another window or device that has the same source configured dispatches the same `Set` and joins as a contributor, without disturbing the status, nonce, or credential. It sees the `credentialId` and doesn't send its key again. +6. Any client can select those models in any session on that agent, and so can automations if the source has `host` retention. +7. When the last contributing client leaves, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). --- ## 6. Lifecycle -### When the contributing client leaves +### When a contributing client leaves + +A contributing client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period, which the host advertises as `gracePeriod`. The host then dispatches `root/modelSourceContributorRemoved` for it. While other contributors remain, nothing else changes. When the last contributor leaves: -A client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period. A client that reconnects in time keeps its registrations. +- **`contributingClient` retention (the default).** The host stops new work on the source and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. +- **`host` retention.** The registration stays, with its credential in memory and no contributors, until a client removes it, a client that joins later withdraws, host policy expires it, or the host restarts (see below). It keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. -- **`contributingClient` retention (the default).** The host stops new work on the source as soon as the client leaves and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. -- **`host` retention.** The registration stays, with its credential in memory, until a client removes it, host policy expires it, or the host restarts (see below). While the contributing client is away, the source keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. +A client that comes back with the same `clientId` within the grace period is still listed, and dispatches `Set` only for the sources it changed. A client that comes back with a new `clientId` and the same configuration joins with `Set`, which keeps the status, nonce, and credential. -A client that comes back with the same `clientId` finds its registrations in root state and only dispatches `Set` for the ones it changed. A client that comes back with a new `clientId` and the same configuration registers again under the same `id`. That makes it the contributing client, and because the definition didn't change, the credential stays. +### Withdrawal, removal, and revocation stop work at once + +When a client's withdrawal leaves a registration with no contributors, when any client dispatches `Removed`, or when a client revokes the credential, the host stops using the credential immediately. It ends every running turn that uses the source with the `modelSourceUnavailable` error (see below), rather than letting it finish. Withdrawal and removal then remove the registration. Revocation keeps it, in `authRequired` with `reason: revoked`. ### Selections after removal @@ -554,40 +672,45 @@ A selection that names a removed source's model fails. The host MUST NOT run the - Drafts, history, and automation definitions keep the `id`. Because the `id` stays reserved, it can't later resolve to a different source. Clients show such a selection as unavailable. - A pending message that names a removed model fails when the host would consume it, through the existing chat lifecycle. -- A turn that is using a source when a client explicitly removes it fails through the existing turn lifecycle the next time it needs the source. -### Rotation, expiry, and revocation +### Rotation, expiry, rejection, and revocation + +- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce and publishes the new `credentialId`. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. +- **Expiry.** When a credential's lifetime or lease lapses, the host drops it, and the source goes to `authRequired` with `reason: expired` and a new nonce. A client may renew it: a fresh token, or the same static key with a new lease. Clients holding short-lived tokens or leases SHOULD renew before `expiresIn` elapses. +- **Rejection.** When the endpoint refuses a credential, the source goes to `authRequired` with `reason: rejected` and a new nonce, and `credentialId` still names the refused key. No client sends a credential with that `credentialId` again. A client whose key differs may send it, or ask the user for a new one. +- **Revocation.** An empty `token` drops the credential at once, and the source goes to `authRequired` with `reason: revoked` and a new nonce. No client delivers a credential again without a user's action, including other devices that have the key stored, and the new nonce rejects a delivery that was already in flight. + +### Turns on an unavailable source -- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. -- **Expiry and rejection.** When a credential expires or the endpoint rejects it, the source goes to `authRequired` with `reason: expired` and a new nonce. A client MUST NOT replay the same secret: it renews the token or asks the user for a new key. Clients holding short-lived tokens SHOULD deliver a fresh one before `expiresIn` elapses. -- **Revocation.** An empty `token` drops the credential, and the source returns to `authRequired` with `reason: expired` and a new nonce. Under the expiry rule, no client sends the revoked secret again, including other devices that have it stored, and the new nonce rejects a delivery that was already in flight. -- **Mid-turn.** If the credential fails during a turn that uses the source, or a turn starts while the source has no usable credential, the host SHOULD end the turn with a resumable error (`chat/error` with `part.resumable: true`). Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. +When a turn can't use its source, because the credential is missing, expired, rejected, or revoked, or because the source was withdrawn or removed, the host ends the turn with `chat/error`. The error part's `error.errorType` is `modelSourceUnavailable`, and `resumable` is `true`. A client tells why from the registration of the turn's model: its `state`, or its absence. Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. ### Host restart -Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained registrations are gone too, and their clients register again when they reconnect. A host that persists its own state SHOULD keep `host`-retained registrations, which come back through `starting`, and reach `authRequired` only if they need a credential. Model ID reservations are kept with the host's state either way. They identify a source and a model, not a secret. +Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained registrations are gone too, and their clients register again when they reconnect. A host that persists its own state SHOULD keep `host`-retained registrations, which come back through `starting`, and reach `authRequired` with `reason: required` only if they need a credential. Model IDs derived deterministically ([§4.5](#_4-5-models-and-selection)) come back unchanged without a stored table. --- ## 7. Credential rules -1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, `credentialResource`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. +1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, `credentialResource`, `credentialOrigins`, `credentialId`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`, and `credentialId` is never derived from it. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. 3. **Scoped to one registration and one `credentialNonce`.** It is never shared with other registrations, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. -4. **Attached only to that source's requests**, as its definition specifies. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. -5. **Dropped** when the registration is removed, when its `provider`, `format`, or `definition` changes, and when the host restarts. +4. **Sent only where the host says.** The host attaches it only to that source's requests, as its definition specifies, and only to origins in `credentialOrigins`. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. +5. **Dropped** when the registration is removed, when its routing changes, when it's revoked, when its lease lapses, and when the host restarts. 6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. -7. **Answered without the user when possible.** A client that has the source configured answers `authRequired` from its own secure storage. Clients SHOULD NOT prompt the user for a key they don't have. -8. **Checked by the client.** A client MUST NOT send a stored secret unless the registration's `provider`, `format`, and `definition` match its own copy. `credentialNonce` stops a delayed reply, but not a device whose copy of the definition is out of date or a registration another client has changed. +7. **Delivered only in answer to state.** Clients MUST NOT cache a model source credential they delivered, or replay one, for example on reconnect. They deliver one only in answer to the registration's current state ([§4.4](#_4-4-credential-delivery-through-authenticate)), reading it from their own secure storage or token provider. Clients SHOULD NOT prompt the user for a key they don't have. +8. **Checked by the client.** A client MUST NOT send a stored secret unless the registration's `provider`, `format`, and `definition` match its own copy, and every origin in `credentialOrigins` is one its own copy of the definition sends the key to. `credentialNonce` stops a delayed reply, but not a device whose copy of the definition is out of date or a registration another client has changed. +9. **Reached from the host.** Endpoints in a definition, including loopback and private addresses, are resolved and reached from the host machine: `localhost` in a source registered with a remote host is that host, not the client's machine. Hosts SHOULD apply an egress policy to registered endpoints: deny link-local and cloud metadata addresses, and require `https` for any credentialed endpoint that isn't a loopback address, unless the host has opted in to plain `http`. --- ## 8. Out of scope for AHP -- The content of definition formats, endpoint validation and network policy, model discovery, capability derivation, and wire protocols. These belong to the agent. +- Defining, standardizing, or naming any definition format. `format` and `definition` stay opaque and belong to the agent. +- Endpoint validation beyond rule 9's egress policy, model discovery, capability derivation, and wire protocols. These belong to the agent. - Client-side credential storage, and keys the host stores itself. That is host-owned authentication ([#404](https://github.com/microsoft/agent-host-protocol/pull/404)); see the open questions. +- How a host verifies principals. - Restricting a registration to particular sessions. -- Per-client ownership and access control between clients. As with MCP servers, every connected client can use and change every registration. - Usage, billing, or per-call provenance. Hosts apply policy appropriate to the source, for example by declining registrations from clients they don't trust, or narrowing which formats they accept. @@ -596,19 +719,17 @@ Hosts apply policy appropriate to the source, for example by declining registrat ## 9. Open questions -- **Standard definition format.** Should a common format be standardized, for example in [Open Plugins](https://open-plugins.com/), so one registration works with any agent? The `format` names leave room for it. -- **Holding a turn for a credential.** A turn whose credential fails ends with a resumable error (see [§6](#rotation-expiry-and-revocation)). Should a host instead be able to hold the turn visibly, with a `modelSourceAuthentication` input request in `SessionState.inputNeeded`? It would carry a `ModelSourceAuthRequirement`, the way MCP's tool authentication request carries an `McpAuthRequirement`. +- **Holding a turn for a credential.** A turn whose credential fails ends with the resumable `modelSourceUnavailable` error (see [§6](#turns-on-an-unavailable-source)). Should a host instead be able to hold the turn visibly, with a `modelSourceAuthentication` input request in `SessionState.inputNeeded`? It would carry a `ModelSourceAuthRequirement`, the way MCP's tool authentication request carries an `McpAuthRequirement`. - **Keys that survive a restart.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. -- **Several users on one host.** AHP can't verify which client is which, so this proposal, like MCP, trusts every connected client equally, and every client sees every definition. A host shared by several users would need verified client identities, per-client access control, and a way to hide registrations from clients that may not use them. That last part would be a new pattern for root state. -- **Duplicates.** Two devices that sync the same configuration can register under the same `id` and share one registration. Devices that don't sync get two registrations for the same service. Should a host merge them? -- **Re-registering unchanged sources.** A client-dispatched `Set` clears the reported status until the host reports again, so clients compare before they register again. Would a revision field be clearer? +- **Hiding registrations from other principals.** `isolated` lets a host restrict who changes, supplies credentials for, and uses a registration, but root state still shows every definition to every client. Should a host be able to hide registrations from clients of other principals? That would be a new pattern for root state. +- **Duplicates.** Clients that derive different `id`s for the same service get two registrations. Should a host merge them? --- ## 10. Compatibility - **Additive.** `RootState.modelSourceRegistrations` and the new capability are optional fields. `AuthenticateTargetKind` is `@nonexhaustive`, and generated clients preserve unknown `AuthenticateTarget` variants. -- **New actions follow the usual rules.** The three root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. +- **New actions follow the usual rules.** The four root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. - **Ignorable.** A client that doesn't know the registry still sees registered sources' models in `AgentInfo.models` and can select them by `id`, like any other model. - **Capability-gated.** Clients register only with agents that advertise `modelSourceRegistration`. - **Depends on #543.** Registered sources join #543's `AgentInfo.modelSources` catalog, so this lands after #543, or together with it. @@ -625,10 +746,11 @@ Hosts apply policy appropriate to the source, for example by declining registrat - Per-session enablement and per-session model sets, which the customization lifecycle provides, don't match how BYOK is configured. - **A `SessionActiveClient.modelSources` field with host-published copies.** The first draft of #619. It makes the client the source of truth for model metadata it can't validate, and has the same session-scope problems. - **Host configuration.** Model sources could be values in `RootConfigState`, changed with `root/configChanged`. Config has no per-entry provenance, status, or credential target, so each would need adding anyway. -- **Per-client sharing and ownership.** An earlier draft let the contributing client limit who could use a source and who could change it, so one client couldn't spend another's key. AHP can't verify which client is which, any connected client can already run tools as the host's user, and MCP servers have no such limits. The rules added complexity without protection, so they were dropped, leaving retention as the only per-registration choice. +- **Per-client sharing and ownership.** An earlier draft let the contributing client limit who could use a source and who could change it, so one client couldn't spend another's key. AHP can't verify which client is which, any connected client can already run tools as the host's user, and MCP servers have no such limits. The rules added complexity without protection, so they were dropped. A host that can verify principals advertises `isolated` instead ([§4.7](#_4-7-discovering-support)). +- **One `clientId`, last writer wins.** An earlier draft recorded only the client that last wrote a registration. A second window's identical `Set` took the source over, and the source went away when that window left, even though the first window still wanted it. `host` retention instead left sources behind that nobody cleaned up. A list of contributing clients lets each client add and withdraw only its own contribution. - **Hiding registrations per connection.** Root state is one shared, replayable state, and this proposal trusts every connected client, so it doesn't project different registries to different clients. - **Reporting status by rewriting the registration.** An earlier draft had the host dispatch the whole registration back with `state` added. A late status write could then bring back a removed registration or overwrite a newer definition, which took several extra rules to prevent. A narrow status action, as MCP uses, prevents both by construction. -- **Host-to-client credential fetch per request.** The host would ask the contributing client for the key on each request, so it never rests on the host. AHP has no host-to-client request primitive yet ([#470](https://github.com/microsoft/agent-host-protocol/issues/470), with [#162](https://github.com/microsoft/agent-host-protocol/issues/162) proposing a similar request family). It also adds a round trip per request and can't serve headless work. +- **Host-to-client credential fetch per request.** The host would ask the contributing client for the key on each request, so it never rests on the host. AHP has host-to-client requests, such as the `resource*` family, but a fetch per model request adds a client round trip to every request and can't serve headless work once the client leaves. --- From 43836efec1c87e5bbbd9e51aef2405444dd7e573 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 13:14:09 -0500 Subject: [PATCH 09/11] docs: compare registry definition numbers by value Definitions are compared with numbers by numeric value, so every client's reducer agrees on whether a `Set` joins or replaces. A restart drops a host-retained source's credential rather than the source. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 830dc1e99..48b48dd49 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -343,7 +343,7 @@ export interface RootModelSourceRegistrationRemovedAction { } ``` -A registration's routing is its `provider`, `format`, and `definition`, with definitions compared as JSON values, ignoring object key order. The reducers apply the actions as follows: +A registration's routing is its `provider`, `format`, and `definition`, with definitions compared as JSON values: object key order is ignored, and numbers compare by numeric value, so `1` equals `1.0`. Every client's reducer has to reach the same answer, or one client would clear host-reported fields the host kept. The reducers apply the actions as follows: - **Add.** When no registration has the `id`, `Set` appends the registration, with `contributingClientIds` set to `[clientId]`, or absent when there's no `clientId`. - **Join.** When one has, and its routing is unchanged, `Set` keeps the existing host-reported fields (`state`, `credentialNonce`, `credentialResource`, `credentialOrigins`, and `credentialId`), adds `clientId` to `contributingClientIds` if it isn't there, and takes `displayName`, `icons`, `retention`, and `_meta` from the action. Joining doesn't disturb the status, nonce, or credential. @@ -658,7 +658,7 @@ sequenceDiagram A contributing client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period, which the host advertises as `gracePeriod`. The host then dispatches `root/modelSourceContributorRemoved` for it. While other contributors remain, nothing else changes. When the last contributor leaves: - **`contributingClient` retention (the default).** The host stops new work on the source and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. -- **`host` retention.** The registration stays, with its credential in memory and no contributors, until a client removes it, a client that joins later withdraws, host policy expires it, or the host restarts (see below). It keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. +- **`host` retention.** The registration stays, with its credential in memory and no contributors, until a client removes it, a client that joins later withdraws, or host policy expires it. A restart drops its credential (see below). It keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. A client that comes back with the same `clientId` within the grace period is still listed, and dispatches `Set` only for the sources it changed. A client that comes back with a new `clientId` and the same configuration joins with `Set`, which keeps the status, nonce, and credential. From 3b9b1318b6c1ce09a3dd74705863098b38a4ae86 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 13:44:06 -0500 Subject: [PATCH 10/11] docs: address registry review on naming, client IDs, and definitions Rename `RootState.modelSourceRegistrations` to `modelSources`, the `ModelSourceRegistration` type to `ModelSource`, and the actions to `root/modelSourceSet` and `root/modelSourceRemoved`. Drop client IDs from the registry. The host learns who registered a source from `ActionEnvelope.origin` and tracks contributing clients itself, so `contributingClientIds`, the `clientId` on `Set`, and `root/modelSourceContributorRemoved` go away. Removal applies to every client. Keep the definition out of state. It travels on `root/modelSourceSet`, and the source carries a `nonce` instead, like `ClientPluginCustomization.nonce`. Reducers compare provider, format, and nonce to tell a re-registration from an update, which replaces the JSON comparison of definitions. Clients check where a key goes with the host-reported `credentialOrigins`. Reuse `authenticate`'s existing `accountId` instead of a new `credentialId` target field, and note that host-owned authentication may later supersede it. Suggest recognized `format` values such as `openaiCompatible`, and explain that built-in sources stay agent-declared. Refs #619 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 338 ++++++++++++------------ 1 file changed, 170 insertions(+), 168 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 48b48dd49..4db8f9894 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -17,9 +17,9 @@ It assumes the direction #543 is taking after review: ### Terminology - A **model source** is #543's term for an independently selectable source of model access, described by `ModelSourceInfo` in an agent's catalog. -- A **registration** is a model source a client or the host added to the host's registry, with its definition and status. -- A **model source definition** is the content of a registration that says how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. -- A **contributing client** is a client that registered a source and still wants it. Several clients, such as two windows or two devices, can contribute the same source. A registration's `contributingClientIds` lists them. +- A **registered model source**, or **registration**, is an entry in the host's registry, `RootState.modelSources`: a model source a client or the host added, with its status. +- A **model source definition** is what tells the agent how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. It travels on the action that registers the source, and isn't kept in state. +- A **contributing client** is a client that registered a source and hasn't left. The host tracks contributing clients itself, from the origin of each registering action. They aren't in state. - A **principal** is the user or account a host has verified a client acts for. AHP doesn't define how a host verifies one. - An **agent provider** is the existing `provider` field (`AgentInfo.provider`). Nothing new is called a "provider". @@ -52,12 +52,12 @@ The agent behind the host does the heavy lifting. It owns: AHP carries only four things: -1. **Registration.** A client contributes a model source definition, or withdraws its contribution. +1. **Registration.** A client adds, updates, or removes a model source. 2. **Status.** The host reports whether each source is starting, ready, needs a credential, or failed. 3. **Credential.** A client supplies a secret, scoped to one registered source. 4. **Selection.** The source's models appear in the agent's catalog and are selected like any other model. -AHP names a definition's format but never defines, standardizes, or names one: `format` and `definition` are opaque to AHP and belong to the agent. +AHP suggests a few recognized format names ([§4.1](#_4-1-the-registry)), but doesn't define what a definition contains, even for those. `definition` is opaque to AHP and belongs to the agent. --- @@ -69,13 +69,14 @@ AHP names a definition's format but never defines, standardizes, or names one: ` - **MCP server authentication.** An MCP server publishes `McpServerAuthRequiredState`, and the client answers with `authenticate` and a `target` naming that server. The [authentication spec](/specification/authentication#why-keyed-by-resource-and-optional-target) notes that `target.kind` is extensible for exactly this kind of addition. - **MCP server status.** The host reports a server's lifecycle with `session/mcpServerStateChanged`, a narrow action that updates only the server's state. A registration's status works the same way. - **No per-client ownership.** Any client in a session can start, stop, or enable an MCP server and answer its authentication challenge. AHP checks a `clientId` only to route a client tool's result back from the client that runs it. Registrations follow the same model by default: every connected client can use and change them. A host that can verify principals MAY restrict them ([§4.7](#_4-7-discovering-support)). -- **Container provenance.** A client-published plugin carries the publisher's `clientId` and a host-reported `load` state that is absent until the host reports one. A registration lists its contributing clients the same way, and its host-reported fields are absent until the host reports them. +- **Container provenance and `nonce`.** A client-published plugin carries a `nonce`, an opaque version token the host compares to detect changes without re-reading the plugin, and a host-reported `load` state that is absent until the host reports one. A registered source carries a `nonce` for its definition the same way, and its host-reported fields are absent until the host reports them. +- **Action origin.** Every client-dispatched action's envelope carries the dispatcher's `clientId` in `ActionEnvelope.origin`. The host learns who registered a source from it, so the registry itself doesn't need client IDs. --- ## 4. Proposed surface -Everything here is additive and optional. It adds one root state field, four root actions (three of them client-dispatchable), one `authenticate` target, one agent capability, and one well-known `ErrorInfo.errorType`. There are no new commands, notifications, error codes, or channels. +Everything here is additive and optional. It adds one root state field, three root actions (two of them client-dispatchable), one `authenticate` target, one agent capability, and one well-known `ErrorInfo.errorType`. There are no new commands, notifications, error codes, or channels. ### 4.1 The registry @@ -84,20 +85,24 @@ Everything here is additive and optional. It adds one root state field, four roo export interface RootState { // …existing… - /** Model sources registered on this host. Keyed by `id`. */ - modelSourceRegistrations?: ModelSourceRegistration[]; + /** + * Model sources registered on this host, keyed by `id`. When one is + * ready, it also appears in its agent's `AgentInfo.modelSources` catalog. + */ + modelSources?: ModelSource[]; } /** - * A model source registered on this host by one or more clients, or by the - * host itself. Its definition is in a format the agent named by `provider` - * reads. It never contains a credential. + * A model source registered on this host by a client, or by the host + * itself. The definition that tells the agent named by `provider` how to + * reach it travels on `root/modelSourceSet` and isn't kept here. Nothing + * here is a credential. * * @category Root State * @stability 1.0 * @preserveUnknownMembers */ -export interface ModelSourceRegistration { +export interface ModelSource { /** * Host-unique ID, chosen by whoever registers the source. Also the * source's `ModelSourceInfo.id` in the agent's catalog, and the @@ -110,32 +115,39 @@ export interface ModelSourceRegistration { displayName: string; /** Icons for UI display. */ icons?: Icon[]; - /** Definition format, one of the agent's `ModelSourceRegistrationCapability.formats`. */ - format: string; /** - * How to reach the source: endpoint, wire format, models, and so on, in - * `format`. MUST NOT contain a credential. + * The definition's format, one of the agent's + * `ModelSourceRegistrationCapability.formats`. Recognized values include: + * + * - `'openaiCompatible'`: an endpoint that implements OpenAI's API, such + * as OpenAI, OpenRouter, xAI, or a local server like Ollama or LM Studio. + * - `'anthropic'`: an endpoint that implements Anthropic's Messages API. + * - `'azureOpenai'`: an Azure OpenAI deployment. + * - `'gemini'`: Google's Gemini API. + * + * Agents MAY read other formats, named with a namespace such as + * `example.com/model-source@1` so they don't collide. */ - definition: Record; + format: string; /** - * The clients that contribute this registration, in the order they - * joined. The reducer maintains it. Absent when no client contributes it: - * a source the host registered itself, or a `host`-retained one whose - * contributors have all left. + * Opaque version token for the definition, such as a hash of it, chosen + * by whoever registers the source. A client compares it with its own copy + * instead of the definition, and the reducer compares it to tell an update + * from a re-registration of the same definition. */ - contributingClientIds?: string[]; + nonce: string; /** What happens when the last contributing client leaves. Absent means `contributingClient`. */ retention?: ModelSourceRetentionPolicy; // Host-reported fields, set together with `root/modelSourceStateChanged`. - // Absent until the host reports, and after a `Set` replaces the - // registration until the host reports again. + // Absent until the host reports, and after an update replaces the + // definition until the host reports again. /** Host-reported status. */ state?: ModelSourceState; /** * Host-issued token that a client echoes when it delivers the credential, - * and that tags every agent operation on the registration. See §4.4. + * and that tags every agent operation on the source. See §4.4. */ credentialNonce?: string; /** @@ -151,21 +163,24 @@ export interface ModelSourceRegistration { */ credentialOrigins?: URI[]; /** - * The client-supplied ID of the credential the host most recently - * accepted. While the state is `starting` or `ready`, the host holds it. - * While it's `authRequired`, `reason` says what happened to it. Absent - * until the host accepts a credential. + * The `accountId` the client sent with the credential the host most + * recently accepted. While the state is `starting` or `ready`, the host + * holds that credential. While it's `authRequired`, `reason` says what + * happened to it. Absent until the host accepts a credential sent with an + * `accountId`. */ - credentialId?: string; + accountId?: string; _meta?: Record; } ``` -`definition` is intentionally open data. AHP doesn't define, standardize, or name any definition format: `format` and `definition` are opaque to AHP and belong to the agent that reads them. The definition lives in root state so a client can compare it with its own configuration. +The `format` values follow the pattern of `Changeset.changeKind`: AHP recognizes a few names so clients and agents can agree on common cases, but it doesn't define what a definition contains, even for those ([§9](#_9-open-questions)). `definition` is opaque to AHP and belongs to the agent. + +The definition travels only on `root/modelSourceSet` ([§4.3](#_4-3-registering-updating-and-removing)). The host hands it to the agent and keeps it privately, and the reducer stores the source without it. Clients don't need the definition after it's submitted: they compare `nonce` with their own copy, and check where a key would go with the host-reported `credentialOrigins`. Actions are broadcast and replayed, so the definition is still never secret, and it MUST NOT contain a credential. `credentialResource.resource` is the endpoint URL as the definition names it, and the value a client passes back as `authenticate({ resource })`. `credentialResource.resource_name` labels the prompt, for example "OpenRouter API key". A source that accepts OAuth access tokens advertises `authorization_servers` and `scopes_supported`. A source that takes a user-supplied secret omits them. A source whose models use several endpoints lists every origin in `credentialOrigins`, so a client can check them all before it sends a key ([§7](#_7-credential-rules)). -A host may register sources itself, for example from configuration on a remote machine. Those registrations have no contributing clients, and their retention behaves as `host`. +A host may register sources itself, for example from configuration on a remote machine. Those sources have no contributing clients, and their retention behaves as `host`. ### 4.2 Status @@ -202,7 +217,7 @@ export const enum ModelSourceAuthRequiredReason { Required = 'required', /** The credential's lifetime or lease lapsed. Renewing it is fine. */ Expired = 'expired', - /** The endpoint refused the credential. Clients don't send one with the same `credentialId` again. */ + /** The endpoint refused the credential. Clients don't send one with the same `accountId` again. */ Rejected = 'rejected', /** A client revoked the credential. Clients don't send one again without a user's action. */ Revoked = 'revoked', @@ -221,7 +236,7 @@ export interface ModelSourceReadyState { /** * Why a model source needs a credential before it can be ready. Deliberately * carries no credential. The endpoint the credential is for is the - * registration's `credentialResource`. + * model source's `credentialResource`. * * @preserveUnknownMembers */ @@ -279,99 +294,88 @@ The host reports status with its own narrow action, as it does for MCP servers w // types/channels-root/actions.ts /** - * Updates a registration's host-reported fields together. A no-op when no - * registration has `id`. Only the host dispatches it. + * Updates a model source's host-reported fields together. A no-op when no + * model source has `id`. Only the host dispatches it. */ export interface RootModelSourceStateChangedAction { type: ActionType.RootModelSourceStateChanged; // 'root/modelSourceStateChanged' id: string; state: ModelSourceState; credentialNonce: string; - /** Replaces the registration's `credentialResource`. Absent clears it. */ + /** Replaces the source's `credentialResource`. Absent clears it. */ credentialResource?: ProtectedResourceMetadata; - /** Replaces the registration's `credentialOrigins`. Absent clears it. */ + /** Replaces the source's `credentialOrigins`. Absent clears it. */ credentialOrigins?: URI[]; - /** Replaces the registration's `credentialId`. Absent clears it. */ - credentialId?: string; + /** Replaces the source's `accountId`. Absent clears it. */ + accountId?: string; } ``` -Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the host-reported fields, it can't overwrite a client's newer definition. The host also tags every agent operation on the registration, such as validation, model discovery, and inference, with its current `credentialNonce`, and discards any result whose nonce is no longer current ([§4.4](#_4-4-credential-delivery-through-authenticate)). A slow result from before a definition change, a re-registration, or a key change therefore can't mark the current registration `ready`, even when the definition has changed back to the same value. - -### 4.3 Contributing, withdrawing, and removing +Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the host-reported fields, it can't overwrite a client's newer definition. The host also tags every agent operation on the registration, such as validation, model discovery, and inference, with its current `credentialNonce`, and discards any result whose nonce is no longer current ([§4.4](#_4-4-credential-delivery-through-authenticate)). A slow result from before an update, a removal and re-add under the same `id`, or a key change therefore can't mark the current source `ready`, even when the definition has changed back to the same value. -Several clients, such as two windows or two devices, can want the same source. Each one contributes it, and each one withdraws only its own contribution. +### 4.3 Registering, updating, and removing ```ts // types/channels-root/actions.ts /** - * Contributes a model source registration for `clientId`: adds it, joins - * an existing one with the same routing, or replaces one whose routing - * changed. + * Adds a model source, or updates the one with the same `id`. * * @clientDispatchable */ -export interface RootModelSourceRegistrationSetAction { - type: ActionType.RootModelSourceRegistrationSet; // 'root/modelSourceRegistrationSet' - registration: ModelSourceRegistration; - /** The contributing client. Absent when the host registers the source itself. */ - clientId?: string; -} - -/** - * Withdraws `clientId`'s contribution. A no-op when no registration has - * `id`, or `clientId` doesn't contribute it. - * - * @clientDispatchable - */ -export interface RootModelSourceContributorRemovedAction { - type: ActionType.RootModelSourceContributorRemoved; // 'root/modelSourceContributorRemoved' - id: string; - clientId: string; +export interface RootModelSourceSetAction { + type: ActionType.RootModelSourceSet; // 'root/modelSourceSet' + /** The model source, without host-reported fields. */ + modelSource: ModelSource; + /** + * How to reach the source, in `modelSource.format`: endpoint, wire + * format, models, and so on. The host hands it to the agent. The reducer + * doesn't store it. MUST NOT contain a credential. + */ + definition: Record; } /** - * Removes a model source registration for every contributor. A no-op when - * none matches. + * Removes a model source. A no-op when none matches. * * @clientDispatchable */ -export interface RootModelSourceRegistrationRemovedAction { - type: ActionType.RootModelSourceRegistrationRemoved; // 'root/modelSourceRegistrationRemoved' +export interface RootModelSourceRemovedAction { + type: ActionType.RootModelSourceRemoved; // 'root/modelSourceRemoved' id: string; } ``` -A registration's routing is its `provider`, `format`, and `definition`, with definitions compared as JSON values: object key order is ignored, and numbers compare by numeric value, so `1` equals `1.0`. Every client's reducer has to reach the same answer, or one client would clear host-reported fields the host kept. The reducers apply the actions as follows: +The reducers follow the keyed-collection convention, with one twist so that re-registering the same definition doesn't disturb a working source: + +- **Add.** When no model source has the `id`, `Set` appends `modelSource`. +- **Re-register.** When one has, with the same `provider`, `format`, and `nonce`, `Set` keeps its host-reported fields (`state`, `credentialNonce`, `credentialResource`, `credentialOrigins`, and `accountId`) and takes `displayName`, `icons`, `retention`, and `_meta` from the action. The status, nonce, and credential are undisturbed. +- **Update.** When any of the three differs, `Set` replaces the source. Its host-reported fields are absent until the host reports again. +- **Remove.** `Removed` deletes the source by `id`, or returns the state unchanged. -- **Add.** When no registration has the `id`, `Set` appends the registration, with `contributingClientIds` set to `[clientId]`, or absent when there's no `clientId`. -- **Join.** When one has, and its routing is unchanged, `Set` keeps the existing host-reported fields (`state`, `credentialNonce`, `credentialResource`, `credentialOrigins`, and `credentialId`), adds `clientId` to `contributingClientIds` if it isn't there, and takes `displayName`, `icons`, `retention`, and `_meta` from the action. Joining doesn't disturb the status, nonce, or credential. -- **Replace.** When the routing changed, `Set` replaces the registration, with `contributingClientIds` set to `[clientId]`. The other contributors wanted a different definition, so they're no longer contributors. The host-reported fields are absent until the host reports again. -- **Withdraw.** `root/modelSourceContributorRemoved` removes `clientId` from `contributingClientIds`, leaving the field absent when no contributor remains. It never removes the registration. The host does that with `Removed`. -- **Remove.** `Removed` deletes the registration by `id`, or returns the state unchanged. +Comparing three strings keeps every client's reducer in agreement without comparing definitions. -A client contributes by dispatching `Set` with its own `clientId`, and without `contributingClientIds` or any host-reported field. It dispatches `Set` when it starts with the source configured and isn't already a contributor, for example a second window, or a window that reloaded with a new `clientId`. When contributors disagree on `displayName`, `icons`, `retention`, or `_meta`, the last `Set` wins. +A client registers a source by dispatching `Set` with no host-reported fields. It dispatches `Set` when it starts or reconnects with the source configured, and when the user changes the source. Re-registering an unchanged source is how a second window, a reloaded window, or another device that has the same source configured becomes a contributing client. When clients disagree on `displayName`, `icons`, `retention`, or `_meta`, the last `Set` wins. -A client SHOULD derive `id` from a stable key in its own configuration, so every device and window that has the same source configured shares one registration. A client SHOULD NOT replace a registration whose routing differs from its own copy unless the user changed the source in its configuration. Otherwise, two clients with different configurations would replace each other's registration indefinitely. +A client SHOULD derive `id` from a stable key in its own configuration, so every device and window that has the same source configured shares one model source. It SHOULD derive `nonce` from the definition, for example as a hash of it. A client SHOULD NOT update a source whose `nonce` differs from its own copy unless the user changed the source in its configuration, and SHOULD NOT add back a source another client removed except when it starts or reconnects. Otherwise, two clients with different configurations would replace each other's source indefinitely. -When the user removes the source from a client's configuration, the client withdraws its own contribution. It dispatches `Removed` only to remove the source for every contributor, for example from a host-wide management view. +When the user removes the source from a client's configuration, the client dispatches `Removed`. Removal applies to every client. Clients that share a configuration lose the source from theirs too, and a client that still has it configured registers it again the next time it starts or reconnects. The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionReason`, when: - the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; -- `clientId` is absent or isn't the dispatching client's ID; -- the registration includes `contributingClientIds` or any host-reported field; -- `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same registration doesn't count, so a ready registration can still be joined or changed; +- `modelSource` includes any host-reported field; +- its `provider`, `format`, and `nonce` match the existing source's, but `definition` differs from the definition the host holds. A re-registration must not carry a different definition, because reducers keep the credential for it; +- `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same source doesn't count, so a ready source can still be re-registered or updated; - the host won't honor the requested `retention`. The client can register again with `contributingClient` retention; -- the registration is one the host registered itself; -- the host restricts registrations by principal, and the existing registration belongs to another principal ([§4.7](#_4-7-discovering-support)). +- the source is one the host registered itself; +- the host restricts sources by principal, and the existing source belongs to another principal ([§4.7](#_4-7-discovering-support)). -The host rejects a client-dispatched `root/modelSourceContributorRemoved` whose `clientId` isn't the dispatching client's ID. A host MAY reject a client's `Removed` for a registration it registered itself, or one that belongs to another principal. +A host MAY reject a client's `Removed` for a source it registered itself, or one that belongs to another principal. -When a client's own withdrawal leaves a registration with no contributors, the host removes it with `Removed`, whatever its retention: the last client that wanted it has withdrawn. When a contributor leaves instead, retention decides ([§6](#_6-lifecycle)). +The host tracks contributing clients itself, from `ActionEnvelope.origin`. An add or a re-registration adds the dispatching client. An update makes the dispatching client the only one, because the others registered a different definition. When the last contributing client leaves, retention decides what happens ([§6](#_6-lifecycle)). -When a `Set` replaces a registration's routing, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A join, or a change to `displayName`, `icons`, `retention`, or `_meta`, keeps the credential and the nonce. +When `Set` updates a source, because its `provider`, `format`, or `nonce` changed, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A re-registration, or a change to `displayName`, `icons`, `retention`, or `_meta`, keeps the credential and the nonce. ### 4.4 Credential delivery through `authenticate` @@ -394,19 +398,13 @@ export const enum AuthenticateTargetKind { */ export interface ModelSourceAuthenticateTarget { kind: AuthenticateTargetKind.ModelSource; - /** The registration's `id`. */ + /** The model source's `id`. */ modelSourceId: string; /** - * The registration's current `credentialNonce`, as published in root + * The model source's current `credentialNonce`, as published in root * state. The host rejects a stale one with `Conflict` (-32011). */ credentialNonce: string; - /** - * A client-chosen, non-secret ID for the credential, such as a hash of - * where the client stores the key. The host publishes it as the - * registration's `credentialId`. MUST NOT be derived from the secret. - */ - credentialId?: string; } export type AuthenticateTarget = @@ -424,11 +422,11 @@ export type AuthenticateTarget = "channel": "ahp-root://", "resource": "https://api.example.com/v1", "token": "", + "accountId": "keychain-5c2a", "target": { "kind": "modelSource", "modelSourceId": "2f6c0e1a-model-source", - "credentialNonce": "9b41d7", - "credentialId": "keychain-5c2a" + "credentialNonce": "9b41d7" } } } @@ -438,27 +436,27 @@ The `token` is an opaque secret. The agent applies it as the definition specifie Clients MUST include a `modelSource` target when they deliver a registered source's credential. A token without a target can't be scoped to one registration (see [§7](#_7-credential-rules)), so it never satisfies a model source's challenge. The host rejects an untargeted `resource` that matches only model source challenges with `InvalidParams` (`-32602`). Untargeted tokens keep working for MCP servers and agent-level resources. -Clients SHOULD include `credentialId` when they deliver a credential, and omit it when they revoke one. It lets a client that reloads, or one on another device, tell whether the host holds its current key. +Clients SHOULD include the existing `accountId` parameter when they deliver a credential, and omit it when they revoke one. The host publishes it as the source's `accountId`, which lets a client that reloads, or one on another device, tell whether the host holds its current key. `accountId` is opaque and MUST NOT be derived from the secret. For an API key that has no account of its own, a client uses an ID that changes whenever the user replaces the key, such as one derived from where it stores the key and when the key last changed. -`credentialNonce` fences every credential change, and works as the registration's generation. The host issues a new nonce whenever a registration is added, including one registered again under a removed `id`, and whenever its routing changes, whether or not it held a credential. It also issues one whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation. An `authenticate` built before any of those changes is stale, so: +`credentialNonce` fences every credential change, and works as the source's generation. The host issues a new nonce whenever a source is added, including one registered again under a removed `id`, and whenever `Set` updates it, whether or not it held a credential. It also issues one whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation. An `authenticate` built before any of those changes is stale, so: - a key meant for an old definition never reaches a new one, even when the endpoint didn't change; - a rotation that crosses a revocation can't undo the revocation; - when two clients answer the same `authRequired`, the first wins, and the second gets `Conflict`, re-reads state, and finds the source ready. -The host tags every agent operation on the registration with the current nonce and discards any result, success or failure, that carries an older one. A late failure can't drop a key that has since replaced it, and a late success can't mark a changed or re-registered source `ready`, even after an edit that changes the definition back. Random values meet the rule that a nonce is never reused for the same `id`. +The host tags every agent operation on the source with the current nonce and discards any result, success or failure, that carries an older one. A late failure can't drop a key that has since replaced it, and a late success can't mark an updated or re-added source `ready`, even after an edit that changes the definition back. Random values meet the rule that a nonce is never reused for the same `id`. The credential fields stay in root state for as long as the source takes a credential, not only while it's `authRequired`. Any client, including one that connected after the source became ready, can build an `authenticate` request at any time: to rotate a short-lived token before it expires, or to revoke a key with an empty token. -**When a client delivers.** A client delivers a credential only in answer to the registration's current state, reading it from its own secure storage or token provider each time. It MUST NOT cache a credential it delivered, or replay one, for example after a reconnect. It delivers one when: +**When a client delivers.** A client delivers a credential only in answer to the source's current state, reading it from its own secure storage or token provider each time. It MUST NOT cache a credential it delivered, or replay one, for example after a reconnect. It delivers one when: - the state is `authRequired` with reason `required`; - the reason is `expired`, with a renewed credential: a fresh token, or the same static key with a new lease; -- the reason is `rejected`, only a credential whose `credentialId` differs from the registration's; -- the state is `starting` or `ready`, and the registration's `credentialId` names a key this client has since replaced, for example one it delivered before the user changed it. A client whose key simply differs leaves the host's credential alone, so two devices with different working keys don't replace each other's in turn; +- the reason is `rejected`, only a credential whose `accountId` differs from the source's; +- the state is `starting` or `ready`, and the source's `accountId` names a key this client has since replaced, for example one it delivered before the user changed it. A client whose key simply differs leaves the host's credential alone, so two devices with different working keys don't replace each other's in turn; - a lease it set is about to expire. -After `revoked`, a client delivers a credential only when a user asks it to. Before it sends any secret, a client checks the registration against its own copy ([§7](#_7-credential-rules)). +After `revoked`, a client delivers a credential only when a user asks it to. Before it sends any secret, a client checks the source against its own copy ([§7](#_7-credential-rules)). Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMembers`: the client builds it for one request, so there are no unknown members to keep. @@ -466,47 +464,49 @@ Like `McpServerAuthenticateTarget`, the target doesn't carry `@preserveUnknownMe When `target.kind` is `modelSource`, the host: -- MUST apply the credential only to that registration. It never applies it to other registrations, MCP servers, or agent-level resources, even when they share `resource`. -- MUST require `resource` to equal the registration's current `credentialResource.resource`. +- MUST apply the credential only to that model source. It never applies it to other model sources, MCP servers, or agent-level resources, even when they share `resource`. +- MUST require `resource` to equal the source's current `credentialResource.resource`. - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). -- MUST reject a `credentialNonce` other than the one it most recently issued for that registration with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. -- MUST publish the target's `credentialId` as the registration's `credentialId` when it accepts a credential. +- MUST reject a `credentialNonce` other than the one it most recently issued for that source with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. +- MUST publish the request's `accountId` as the source's `accountId` when it accepts a credential, and clear it when the request has none. - MUST treat an empty `token` as revocation: it stops using the credential at once, drops it, and reports `authRequired` with `reason: revoked`. -Any client may deliver or revoke a registration's credential, as any client may answer an MCP server's challenge, unless the host restricts credentials by principal ([§4.7](#_4-7-discovering-support)). It then rejects a credential from another principal's client with `PermissionDenied` (`-32009`). +Any client may deliver or revoke a model source's credential, as any client may answer an MCP server's challenge, unless the host restricts credentials by principal ([§4.7](#_4-7-discovering-support)). It then rejects a credential from another principal's client with `PermissionDenied` (`-32009`). `expiresIn` keeps its meaning for short-lived tokens such as Microsoft Entra ID access tokens. With a static key, it's a lease: the host drops the key when the lease elapses and reports `expired`, and a client renews the lease by sending the key again. An API key without a lease omits it. ### 4.5 Models and selection -When a registration is `ready`, the host adds it to the catalog of the agent named by `provider`, through `root/agentsChanged`: +When a registered source is `ready`, the host adds it to the catalog of the agent named by `provider`, through `root/agentsChanged`: + +- a `ModelSourceInfo` in `AgentInfo.modelSources`, with the source's `id` and `displayName`; +- its models in `AgentInfo.models`, each with `modelSourceId` set to the source's `id`. -- a `ModelSourceInfo` in `AgentInfo.modelSources`, with the registration's `id` and `displayName`; -- its models in `AgentInfo.models`, each with `modelSourceId` set to the registration's `id`. +`modelSourceId` alone doesn't mark a registered source: #543 also uses it to group an agent's own models. Registration is the signal: a source is registered when `RootState.modelSources` has an entry with that `id` whose `provider` is the agent. -`modelSourceId` alone doesn't mark a registered source: #543 also uses it to group an agent's own models. Registration provenance is the signal: a source is registered when `modelSourceRegistrations` has an entry with that `id` whose `provider` is the agent. +**Built-in sources.** A source the agent provides itself, such as a first-party service that ships with the agent, stays an agent-declared `ModelSourceInfo` (#543). The host lists it and its models in `AgentInfo` directly, and its sign-in uses `AgentInfo.protectedResources` and an untargeted `authenticate`, as today. It isn't a registered source and needs nothing from this proposal. Clients register sources only for configuration the agent doesn't have. If a client ever had to supply a built-in service's configuration, for example because the agent can't reach the service on its own, it would register it like any other source: a source that takes OAuth tokens advertises `authorization_servers` in `credentialResource`, and its `id` can't collide with the agent's own sources ([§4.3](#_4-3-registering-updating-and-removing)). -The host adds a registration's models when it first becomes `ready`, and keeps them listed through later `starting` and `authRequired` states, so a key rotation or expiry doesn't change the catalog or break a selection. It withdraws them when the registration is removed, when its last contributing client leaves under `contributingClient` retention, when it enters `error`, or when a routing change mints new model IDs (see Reserved model IDs below). A turn that uses a listed model while the source has no usable credential ends with the `modelSourceUnavailable` error ([§6](#turns-on-an-unavailable-source)). The host MAY list the `ModelSourceInfo` in any state, since #543 allows a source with no models. +The host adds a registered source's models when it first becomes `ready`, and keeps them listed through later `starting` and `authRequired` states, so a key rotation or expiry doesn't change the catalog or break a selection. It withdraws them when the source is removed, when its last contributing client leaves under `contributingClient` retention, when it enters `error`, or when an update mints new model IDs (see Reserved model IDs below). A turn that uses a listed model while the source has no usable credential ends with the `modelSourceUnavailable` error ([§6](#turns-on-an-unavailable-source)). The host MAY list the `ModelSourceInfo` in any state, since #543 allows a source with no models. Each model follows #543's catalog rules: -- `id` MUST be unique within the agent's catalog. The host mints it and maps it to the endpoint's own model identifier, so two registrations can serve the same upstream model without colliding. +- `id` MUST be unique within the agent's catalog. The host mints it and maps it to the endpoint's own model identifier, so two sources can serve the same upstream model without colliding. - `provider` stays the agent provider. - `vendor` MAY name the service that serves the model, for example `OpenRouter`. -**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registration, that `id` is bound to that registration and its upstream model for as long as the host keeps state. That includes after the registration is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same registration (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a `definition` change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when a different client made the change. +**Reserved model IDs.** Drafts, pending messages, history, and automation definitions keep a selection after its source goes away, and a chat keeps them when it moves to another session. Once the host publishes a model `id` for a registered source, that `id` is bound to that source and its upstream model for as long as the host keeps state. That includes after the source is removed and across a host restart. The host MUST NOT resolve the `id` to anything else. It MAY publish the `id` again only when the same source (the same `id`) comes back offering the same upstream model. A model's upstream identity is the endpoint the agent sends its requests to plus that endpoint's model identifier. A change to `provider` or `format`, or a definition change that moves the endpoint, makes it a different upstream model, so the host mints new IDs, even when a different client made the change. -A host SHOULD derive each model's `id` deterministically from the registration (its `id`, `provider`, and `format`), the endpoint, and the endpoint's model identifier, for example with a hash. The same model then gets the same `id` when its source is registered again or the host restarts, without a stored table, and a moved endpoint gets a new one. Random IDs would break saved selections whenever a source is registered again, unless the host persists a table of them. +A host SHOULD derive each model's `id` deterministically from the source (its `id`, `provider`, and `format`), the endpoint, and the endpoint's model identifier, for example with a hash. The same model then gets the same `id` when its source is registered again or the host restarts, without a stored table, and a moved endpoint gets a new one. Random IDs would break saved selections whenever a source is registered again, unless the host persists a table of them. -**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed, that the chat is backed by the registration's agent provider, and, when it restricts registrations by principal, that the turn's client acts for the registration's principal. It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. +**Selection** doesn't change: a client picks a model by `id`, with optional `config`, on every path a selection already uses. The host checks that the model is listed, that the chat is backed by the source's agent provider, and, when it restricts sources by principal, that the turn's client acts for the source's principal. It checks whenever it uses a selection, including when a client continues a turn with `chat/turnResume`. Otherwise it rejects the selection through the existing failure paths: `InvalidParams` for requests, and `rejectionReason` for dispatched actions. -**Sessions** need nothing new. Any session whose agent is the registration's `provider` can use its models, whichever client started the turn. There is no per-session list of registrations. +**Sessions** need nothing new. Any session whose agent is the source's `provider` can use its models, whichever client started the turn. There is no per-session list of sources. -**Automations** may name a registration's model when the registration has `host` retention, or was registered by the host. The host SHOULD reject an automation create or update that names a model from a `contributingClient`-retained registration, because the automation would outlive the source. If the source isn't `ready` when a run starts, the run fails through the existing automation run lifecycle, and the registration's `authRequired` state tells the next client to connect what's needed. +**Automations** may name a registered source's model when the source has `host` retention, or was registered by the host. The host SHOULD reject an automation create or update that names a model from a `contributingClient`-retained source, because the automation would outlive the source. If the source isn't `ready` when a run starts, the run fails through the existing automation run lifecycle, and the source's `authRequired` state tells the next client to connect what's needed. ### 4.6 Retention -The contributing clients choose what happens to a registration when the last of them leaves. The default is the narrower choice, so clients that don't set it behave like clients that only use their models while one of them is connected. +The client that registers a source chooses what happens to it when the last contributing client leaves. The default is the narrower choice, so clients that don't set it behave like clients that only use their models while one of them is connected. ```ts // types/channels-root/state.ts @@ -521,14 +521,14 @@ The contributing clients choose what happens to a registration when the last of export const enum ModelSourceRetentionPolicy { /** Removed when the last contributing client leaves, once running turns finish. */ ContributingClient = 'contributingClient', - /** Kept until it's removed, its last contributor withdraws, or host policy expires it. */ + /** Kept until a client removes it, or host policy expires it. */ Host = 'host', } ``` -The two values mirror how MCP servers already behave. A `contributingClient` registration goes away with its clients, like a client-published plugin. A `host` registration stays, like a host-declared server, so long-running sessions and automations keep working, with the key in memory, while the host runs. Explicit withdrawal is different from leaving: when the last contributor withdraws, the source goes away whatever its retention, so `host` retention doesn't leave sources nobody wants. +The two values mirror how MCP servers already behave. A `contributingClient` source goes away with its clients, like a client-published plugin. A `host` source stays, like a host-declared server, so long-running sessions and automations keep working, with the key in memory, while the host runs. When the user removes the source from their configuration, their client removes it, whatever its retention, so `host` retention doesn't leave sources nobody wants. -The host rejects `host` retention when it won't honor it ([§4.3](#_4-3-contributing-withdrawing-and-removing)), and it MAY expire `host`-retained registrations by its own policy. +The host rejects `host` retention when it won't honor it ([§4.3](#_4-3-registering-updating-and-removing)), and it MAY expire `host`-retained sources by its own policy. ### 4.7 Discovering support @@ -550,15 +550,15 @@ export interface AgentCapabilities { */ export interface ModelSourceRegistrationCapability { /** - * Definition formats the agent reads, most preferred first. Format names - * are defined by agent implementations and SHOULD be namespaced, for - * example `example.com/model-source@1`, so different agents' formats - * don't collide. + * Definition formats the agent reads, most preferred first: recognized + * values of `ModelSource.format`, or namespaced names for formats the + * agent defines itself. */ formats: string[]; /** - * How long, in milliseconds, the host keeps a disconnected client's - * contributions before it treats the client as having left. + * How long, in milliseconds, the host keeps counting a disconnected + * client as a contributing client before it treats the client as having + * left. * * @integer * @minimum 0 @@ -573,20 +573,20 @@ export interface ModelSourceRegistrationCapability { * @nonexhaustive */ export const enum ModelSourcePrincipalPolicy { - /** Every connected client may change, supply credentials for, and select every registration. */ + /** Every connected client may change, supply credentials for, and select every model source. */ Shared = 'shared', /** * The host verifies principals, and limits changes, credentials, and - * selection of each registration to clients of the principal that + * selection of each model source to clients of the principal that * registered it. */ Isolated = 'isolated', } ``` -A client that knows none of an agent's formats doesn't register with it. AHP doesn't define, standardize, or name any format. +A client that knows none of an agent's formats doesn't register with it. AHP recognizes a few format names ([§4.1](#_4-1-the-registry)) but doesn't define what a definition contains. -**Principals.** AHP doesn't verify which client is which, so by default every connected client is trusted equally, as with MCP servers. Where a host can verify principals, it MAY restrict changes, credentials, and use of a registration to clients of the principal that registered it, and advertises `isolated`. Root state still lists every registration to every client, so a definition is never private. A host whose connections carry credentials scoped to one client, such as a relay that forwards each client's own sign-in, SHOULD NOT let one client's registration be used by another: it uses `isolated`, or doesn't advertise `modelSourceRegistration`. +**Principals.** AHP doesn't verify which client is which, so by default every connected client is trusted equally, as with MCP servers. Where a host can verify principals, it MAY restrict changes, credentials, and use of a model source to clients of the principal that registered it, and advertises `isolated`. Root state still lists every model source to every client, and the action stream carries every definition, so neither is private. A host whose connections carry credentials scoped to one client, such as a relay that forwards each client's own sign-in, SHOULD NOT let one client's model source be used by another: it uses `isolated`, or doesn't advertise `modelSourceRegistration`. ### 4.8 Change table @@ -594,16 +594,16 @@ What a follow-up implementation would touch: | Symbol | File | Kind | | --- | --- | --- | -| `RootState.modelSourceRegistrations`, `ModelSourceRegistration` (including `contributingClientIds` and the host-reported `credentialNonce`, `credentialResource`, `credentialOrigins`, and `credentialId`) | `channels-root/state.ts` | added | +| `RootState.modelSources`, `ModelSource` (including `nonce`, the recognized `format` values, and the host-reported `credentialNonce`, `credentialResource`, `credentialOrigins`, and `accountId`) | `channels-root/state.ts` | added | | `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement`, `ModelSourceAuthRequiredReason` | `channels-root/state.ts` | added (lifecycle union) | | `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | | `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability`, `ModelSourcePrincipalPolicy` | `channels-root/state.ts` | added (capability) | -| `root/modelSourceRegistrationSet`, `root/modelSourceContributorRemoved`, `root/modelSourceRegistrationRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | +| `root/modelSourceSet` (with `definition`, which the reducer doesn't store), `root/modelSourceRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | | `root/modelSourceStateChanged` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (host-only, introduced in the development version) | -| Root reducer | `channels-root/reducer.ts` | add, join, replace, withdraw, remove, and status change, with fixtures for every branch | -| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the four root actions, so they pass the shared fixtures | -| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId`, `credentialNonce`, and `credentialId`), `AuthenticateTarget` | `common/commands.ts` | added, widened | -| `AuthenticateParams.target` and `resource` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | +| Root reducer | `channels-root/reducer.ts` | add, re-register, update, remove, and status change, with fixtures for every branch | +| Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the three root actions, so they pass the shared fixtures | +| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId` and `credentialNonce`), `AuthenticateTarget` | `common/commands.ts` | added, widened | +| `AuthenticateParams.target`, `resource`, and `accountId` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | | `ErrorInfo.errorType` docs | `common/state.ts` | the well-known `modelSourceUnavailable` value | | `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources, provenance, and reserved IDs | | Generator registration | `scripts/generate-{csharp,go,kotlin,rust,swift}.ts` | new enums, structs, and union variants | @@ -623,15 +623,15 @@ sequenceDiagram C->>H: initialize H-->>C: root snapshot (agent advertises modelSourceRegistration with formats and gracePeriod) - C->>H: root/modelSourceRegistrationSet (registration, clientId) + C->>H: root/modelSourceSet (modelSource with nonce, definition) H->>A: read and validate the definition H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce, credentialResource, credentialOrigins) - C->>H: authenticate({ resource, token, target: { kind: 'modelSource', modelSourceId, credentialNonce, credentialId } }) + C->>H: authenticate({ resource, token, accountId, target: { kind: 'modelSource', modelSourceId, credentialNonce } }) H-->>C: {} A->>E: list models (credential attached) E-->>A: models - H-->>C: root/modelSourceStateChanged (ready, new credentialNonce, credentialId) + H-->>C: root/modelSourceStateChanged (ready, new credentialNonce, accountId) H-->>C: root/agentsChanged (the source and its models join the agent catalog) C->>H: chat/turnStarted in any session on that agent (message.model: { id }) @@ -642,10 +642,10 @@ sequenceDiagram ``` 1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. -2. It dispatches `root/modelSourceRegistrationSet` with its own `clientId`. The host's agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. -3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`, the `credentialResource` the key is for, and every origin it would send the key to. The client checks those against its own copy and calls `authenticate` with that `resource` and a `modelSource` target that echoes the nonce and names its key with `credentialId`. -4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and the `credentialId` it now holds. It adds the source and its models to the agent's catalog. -5. Another window or device that has the same source configured dispatches the same `Set` and joins as a contributor, without disturbing the status, nonce, or credential. It sees the `credentialId` and doesn't send its key again. +2. It dispatches `root/modelSourceSet` with the source, its `nonce`, and the definition. The host counts the client as a contributing client, the agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. +3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`, the `credentialResource` the key is for, and every origin it would send the key to. The client checks those against its own copy and calls `authenticate` with that `resource`, an `accountId` naming its key, and a `modelSource` target that echoes the nonce. +4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and the `accountId` of the key it now holds. It adds the source and its models to the agent's catalog. +5. Another window or device that has the same source configured dispatches the same `Set`. Its `nonce` matches, so it becomes a contributing client without disturbing the status, nonce, or credential. It sees the `accountId` and doesn't send its key again. 6. Any client can select those models in any session on that agent, and so can automations if the source has `host` retention. 7. When the last contributing client leaves, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). @@ -655,16 +655,16 @@ sequenceDiagram ### When a contributing client leaves -A contributing client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period, which the host advertises as `gracePeriod`. The host then dispatches `root/modelSourceContributorRemoved` for it. While other contributors remain, nothing else changes. When the last contributor leaves: +A contributing client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period, which the host advertises as `gracePeriod`. The host stops counting it. While other contributing clients remain, nothing else changes. When the last one leaves: -- **`contributingClient` retention (the default).** The host stops new work on the source and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the registration and drops its credential. -- **`host` retention.** The registration stays, with its credential in memory and no contributors, until a client removes it, a client that joins later withdraws, or host policy expires it. A restart drops its credential (see below). It keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. +- **`contributingClient` retention (the default).** The host stops new work on the source and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the source with `root/modelSourceRemoved` and drops its credential. +- **`host` retention.** The source stays, with its credential in memory and no contributing clients, until a client removes it or host policy expires it. A restart drops its credential (see below). It keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. -A client that comes back with the same `clientId` within the grace period is still listed, and dispatches `Set` only for the sources it changed. A client that comes back with a new `clientId` and the same configuration joins with `Set`, which keeps the status, nonce, and credential. +A client that comes back with the same `clientId` within the grace period is still counted, and dispatches `Set` only for the sources it changed. A client that comes back with a new `clientId` and the same configuration re-registers with `Set`, which keeps the status, nonce, and credential. -### Withdrawal, removal, and revocation stop work at once +### Removal and revocation stop work at once -When a client's withdrawal leaves a registration with no contributors, when any client dispatches `Removed`, or when a client revokes the credential, the host stops using the credential immediately. It ends every running turn that uses the source with the `modelSourceUnavailable` error (see below), rather than letting it finish. Withdrawal and removal then remove the registration. Revocation keeps it, in `authRequired` with `reason: revoked`. +When a client dispatches `Removed`, or revokes the credential, the host stops using the credential immediately. It ends every running turn that uses the source with the `modelSourceUnavailable` error (see below), rather than letting it finish. Removal removes the source. Revocation keeps it, in `authRequired` with `reason: revoked`. ### Selections after removal @@ -675,38 +675,38 @@ A selection that names a removed source's model fails. The host MUST NOT run the ### Rotation, expiry, rejection, and revocation -- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce and publishes the new `credentialId`. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. +- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce and publishes the new `accountId`. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. - **Expiry.** When a credential's lifetime or lease lapses, the host drops it, and the source goes to `authRequired` with `reason: expired` and a new nonce. A client may renew it: a fresh token, or the same static key with a new lease. Clients holding short-lived tokens or leases SHOULD renew before `expiresIn` elapses. -- **Rejection.** When the endpoint refuses a credential, the source goes to `authRequired` with `reason: rejected` and a new nonce, and `credentialId` still names the refused key. No client sends a credential with that `credentialId` again. A client whose key differs may send it, or ask the user for a new one. +- **Rejection.** When the endpoint refuses a credential, the source goes to `authRequired` with `reason: rejected` and a new nonce, and `accountId` still names the refused key. No client sends a credential with that `accountId` again. A client whose key differs may send it, or ask the user for a new one. - **Revocation.** An empty `token` drops the credential at once, and the source goes to `authRequired` with `reason: revoked` and a new nonce. No client delivers a credential again without a user's action, including other devices that have the key stored, and the new nonce rejects a delivery that was already in flight. ### Turns on an unavailable source -When a turn can't use its source, because the credential is missing, expired, rejected, or revoked, or because the source was withdrawn or removed, the host ends the turn with `chat/error`. The error part's `error.errorType` is `modelSourceUnavailable`, and `resumable` is `true`. A client tells why from the registration of the turn's model: its `state`, or its absence. Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. +When a turn can't use its source, because the credential is missing, expired, rejected, or revoked, or because the source was removed, the host ends the turn with `chat/error`. The error part's `error.errorType` is `modelSourceUnavailable`, and `resumable` is `true`. A client tells why from the registered source of the turn's model: its `state`, or its absence. Once the source is ready again, a client can continue the same turn with `chat/turnResume`, and the host checks the turn's selection again first. The host never switches models. It doesn't hold the turn open: `SessionStatus.InputNeeded` comes from `inputNeeded` entries and blocked tool calls, and none of them covers a model source, so a held turn would look like it's still running. ### Host restart -Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained registrations are gone too, and their clients register again when they reconnect. A host that persists its own state SHOULD keep `host`-retained registrations, which come back through `starting`, and reach `authRequired` with `reason: required` only if they need a credential. Model IDs derived deterministically ([§4.5](#_4-5-models-and-selection)) come back unchanged without a stored table. +Credentials are gone after a restart, because they were never persisted. `contributingClient`-retained sources are gone too, and their clients register them again when they reconnect. A host that persists its own state SHOULD keep `host`-retained sources and their definitions, which come back through `starting`, and reach `authRequired` with `reason: required` only if they need a credential. Model IDs derived deterministically ([§4.5](#_4-5-models-and-selection)) come back unchanged without a stored table. --- ## 7. Credential rules -1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes `definition`, `_meta`, `ErrorInfo`, `credentialResource`, `credentialOrigins`, `credentialId`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`, and `credentialId` is never derived from it. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. +1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes the definition on `root/modelSourceSet`, `nonce`, `_meta`, `ErrorInfo`, `credentialResource`, `credentialOrigins`, `accountId`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`, and neither `nonce` nor `accountId` is derived from it. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. -3. **Scoped to one registration and one `credentialNonce`.** It is never shared with other registrations, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. +3. **Scoped to one model source and one `credentialNonce`.** It is never shared with other model sources, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. 4. **Sent only where the host says.** The host attaches it only to that source's requests, as its definition specifies, and only to origins in `credentialOrigins`. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. -5. **Dropped** when the registration is removed, when its routing changes, when it's revoked, when its lease lapses, and when the host restarts. +5. **Dropped** when the source is removed, when `Set` updates it, when it's revoked, when its lease lapses, and when the host restarts. 6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. -7. **Delivered only in answer to state.** Clients MUST NOT cache a model source credential they delivered, or replay one, for example on reconnect. They deliver one only in answer to the registration's current state ([§4.4](#_4-4-credential-delivery-through-authenticate)), reading it from their own secure storage or token provider. Clients SHOULD NOT prompt the user for a key they don't have. -8. **Checked by the client.** A client MUST NOT send a stored secret unless the registration's `provider`, `format`, and `definition` match its own copy, and every origin in `credentialOrigins` is one its own copy of the definition sends the key to. `credentialNonce` stops a delayed reply, but not a device whose copy of the definition is out of date or a registration another client has changed. +7. **Delivered only in answer to state.** Clients MUST NOT cache a model source credential they delivered, or replay one, for example on reconnect. They deliver one only in answer to the source's current state ([§4.4](#_4-4-credential-delivery-through-authenticate)), reading it from their own secure storage or token provider. Clients SHOULD NOT prompt the user for a key they don't have. +8. **Checked by the client.** A client MUST NOT send a stored secret unless the source's `provider`, `format`, and `nonce` match its own copy, and every origin in `credentialOrigins` is one its own copy of the definition sends the key to. The host derives `credentialOrigins` from the definition it actually holds, so the origin check doesn't depend on another client choosing `nonce` honestly. `credentialNonce` stops a delayed reply, but not a device whose copy is out of date or a source another client has changed. 9. **Reached from the host.** Endpoints in a definition, including loopback and private addresses, are resolved and reached from the host machine: `localhost` in a source registered with a remote host is that host, not the client's machine. Hosts SHOULD apply an egress policy to registered endpoints: deny link-local and cloud metadata addresses, and require `https` for any credentialed endpoint that isn't a loopback address, unless the host has opted in to plain `http`. --- ## 8. Out of scope for AHP -- Defining, standardizing, or naming any definition format. `format` and `definition` stay opaque and belong to the agent. +- Defining what a definition contains, even for the recognized `format` values. `definition` stays opaque and belongs to the agent. - Endpoint validation beyond rule 9's egress policy, model discovery, capability derivation, and wire protocols. These belong to the agent. - Client-side credential storage, and keys the host stores itself. That is host-owned authentication ([#404](https://github.com/microsoft/agent-host-protocol/pull/404)); see the open questions. - How a host verifies principals. @@ -720,16 +720,17 @@ Hosts apply policy appropriate to the source, for example by declining registrat ## 9. Open questions - **Holding a turn for a credential.** A turn whose credential fails ends with the resumable `modelSourceUnavailable` error (see [§6](#turns-on-an-unavailable-source)). Should a host instead be able to hold the turn visibly, with a `modelSourceAuthentication` input request in `SessionState.inputNeeded`? It would carry a `ModelSourceAuthRequirement`, the way MCP's tool authentication request carries an `McpAuthRequirement`. -- **Keys that survive a restart.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. -- **Hiding registrations from other principals.** `isolated` lets a host restrict who changes, supplies credentials for, and uses a registration, but root state still shows every definition to every client. Should a host be able to hide registrations from clients of other principals? That would be a new pattern for root state. -- **Duplicates.** Clients that derive different `id`s for the same service get two registrations. Should a host merge them? +- **Definitions for the recognized formats.** AHP recognizes a few `format` names but doesn't define what their definitions contain, so two agents that both read `openaiCompatible` may still expect different definitions. Should AHP define a small shared definition for each recognized format, for example in [Open Plugins](https://open-plugins.com/), so one definition works with any agent? +- **Keys that survive a restart, and host-owned authentication.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. Once host-owned authentication lands, it's likely to become the canonical place for model source credentials, and the `modelSource` target and the `accountId` published here would follow it. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. +- **Hiding sources from other principals.** `isolated` lets a host restrict who changes, supplies credentials for, and uses a model source, but root state still lists every source, and the action stream carries every definition, to every client. Should a host be able to hide sources from clients of other principals? That would be a new pattern for root state. +- **Duplicates.** Clients that derive different `id`s for the same service get two sources. Should a host merge them? --- ## 10. Compatibility -- **Additive.** `RootState.modelSourceRegistrations` and the new capability are optional fields. `AuthenticateTargetKind` is `@nonexhaustive`, and generated clients preserve unknown `AuthenticateTarget` variants. -- **New actions follow the usual rules.** The four root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. +- **Additive.** `RootState.modelSources` and the new capability are optional fields. `AuthenticateTargetKind` is `@nonexhaustive`, and generated clients preserve unknown `AuthenticateTarget` variants. +- **New actions follow the usual rules.** The three root actions are introduced in the development protocol version, like any new action, so hosts don't send them to clients that negotiated an older version. No extra version bump is needed. - **Ignorable.** A client that doesn't know the registry still sees registered sources' models in `AgentInfo.models` and can select them by `id`, like any other model. - **Capability-gated.** Clients register only with agents that advertise `modelSourceRegistration`. - **Depends on #543.** Registered sources join #543's `AgentInfo.modelSources` catalog, so this lands after #543, or together with it. @@ -747,7 +748,8 @@ Hosts apply policy appropriate to the source, for example by declining registrat - **A `SessionActiveClient.modelSources` field with host-published copies.** The first draft of #619. It makes the client the source of truth for model metadata it can't validate, and has the same session-scope problems. - **Host configuration.** Model sources could be values in `RootConfigState`, changed with `root/configChanged`. Config has no per-entry provenance, status, or credential target, so each would need adding anyway. - **Per-client sharing and ownership.** An earlier draft let the contributing client limit who could use a source and who could change it, so one client couldn't spend another's key. AHP can't verify which client is which, any connected client can already run tools as the host's user, and MCP servers have no such limits. The rules added complexity without protection, so they were dropped. A host that can verify principals advertises `isolated` instead ([§4.7](#_4-7-discovering-support)). -- **One `clientId`, last writer wins.** An earlier draft recorded only the client that last wrote a registration. A second window's identical `Set` took the source over, and the source went away when that window left, even though the first window still wanted it. `host` retention instead left sources behind that nobody cleaned up. A list of contributing clients lets each client add and withdraw only its own contribution. +- **Client IDs in state.** Earlier drafts recorded the client that last wrote a source, and then a list of contributing clients with a per-client withdrawal action. A source can outlive the connections that registered it, so those IDs mean little to other clients. The host learns who registered a source from `ActionEnvelope.origin` and tracks contributing clients itself, which is all `contributingClient` retention needs. +- **Definitions in state.** An earlier draft kept each definition in root state so clients could compare it with their own, which forced every client's reducer to compare JSON values the same way. Only the host and its agent need the definition after it's submitted. A `nonce` lets clients compare versions, as `ClientPluginCustomization.nonce` does, and the host-reported `credentialOrigins` lets them check where a key would go. - **Hiding registrations per connection.** Root state is one shared, replayable state, and this proposal trusts every connected client, so it doesn't project different registries to different clients. - **Reporting status by rewriting the registration.** An earlier draft had the host dispatch the whole registration back with `state` added. A late status write could then bring back a removed registration or overwrite a newer definition, which took several extra rules to prevent. A narrow status action, as MCP uses, prevents both by construction. - **Host-to-client credential fetch per request.** The host would ask the contributing client for the key on each request, so it never rests on the host. AHP has host-to-client requests, such as the `resource*` family, but a fetch per model request adds a client round trip to every request and can't serve headless work once the client leaves. From f30b11a3ef52fa0677b2d9ae0f1af6c9a367b772 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Tue, 24 Nov 2026 15:36:31 -0500 Subject: [PATCH 11/11] docs: restore registry definitions and trim host policy fields Address the second round of registry review: - Put `definition` back on `ModelSource` so clients can see a source's endpoint, with suggested shapes for each recognized format. `nonce` still versions it for reducers. - Drop `credentialOrigins`; clients check the definition itself. - Drop the host-issued `credentialNonce` and its `Conflict` fencing; the `modelSource` target names only the source, as MCP's does. - Make `formats` a list of `ModelSourceFormatInfo` objects so the capability can grow. - Drop `gracePeriod` and `principalPolicy` from the capability; both stay host policy. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/proposals/model-source-registry.md | 198 +++++++++++------------- 1 file changed, 87 insertions(+), 111 deletions(-) diff --git a/docs/proposals/model-source-registry.md b/docs/proposals/model-source-registry.md index 4db8f9894..3b80237dd 100644 --- a/docs/proposals/model-source-registry.md +++ b/docs/proposals/model-source-registry.md @@ -18,7 +18,7 @@ It assumes the direction #543 is taking after review: - A **model source** is #543's term for an independently selectable source of model access, described by `ModelSourceInfo` in an agent's catalog. - A **registered model source**, or **registration**, is an entry in the host's registry, `RootState.modelSources`: a model source a client or the host added, with its status. -- A **model source definition** is what tells the agent how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. It travels on the action that registers the source, and isn't kept in state. +- A **model source definition** is what tells the agent how to reach the source: the endpoint, the wire format, and any curated model list, in a format the agent understands. It's part of the registration, so every client can see it. - A **contributing client** is a client that registered a source and hasn't left. The host tracks contributing clients itself, from the origin of each registering action. They aren't in state. - A **principal** is the user or account a host has verified a client acts for. AHP doesn't define how a host verifies one. - An **agent provider** is the existing `provider` field (`AgentInfo.provider`). Nothing new is called a "provider". @@ -57,7 +57,7 @@ AHP carries only four things: 3. **Credential.** A client supplies a secret, scoped to one registered source. 4. **Selection.** The source's models appear in the agent's catalog and are selected like any other model. -AHP suggests a few recognized format names ([§4.1](#_4-1-the-registry)), but doesn't define what a definition contains, even for those. `definition` is opaque to AHP and belongs to the agent. +AHP suggests a few recognized format names, and a shape for each ([§4.1](#_4-1-the-registry)), but doesn't validate definitions. `definition` belongs to the agent. --- @@ -68,7 +68,7 @@ AHP suggests a few recognized format names ([§4.1](#_4-1-the-registry)), but do - **Keyed collections.** The registry follows the `Set` and `Removed` convention used for `activeClients`, `customizations`, and other keyed lists. - **MCP server authentication.** An MCP server publishes `McpServerAuthRequiredState`, and the client answers with `authenticate` and a `target` naming that server. The [authentication spec](/specification/authentication#why-keyed-by-resource-and-optional-target) notes that `target.kind` is extensible for exactly this kind of addition. - **MCP server status.** The host reports a server's lifecycle with `session/mcpServerStateChanged`, a narrow action that updates only the server's state. A registration's status works the same way. -- **No per-client ownership.** Any client in a session can start, stop, or enable an MCP server and answer its authentication challenge. AHP checks a `clientId` only to route a client tool's result back from the client that runs it. Registrations follow the same model by default: every connected client can use and change them. A host that can verify principals MAY restrict them ([§4.7](#_4-7-discovering-support)). +- **No per-client ownership.** Any client in a session can start, stop, or enable an MCP server and answer its authentication challenge. AHP checks a `clientId` only to route a client tool's result back from the client that runs it. Registrations follow the same model: every connected client can use and change them. A host that can verify principals MAY restrict them ([§4.7](#_4-7-discovering-support)). - **Container provenance and `nonce`.** A client-published plugin carries a `nonce`, an opaque version token the host compares to detect changes without re-reading the plugin, and a host-reported `load` state that is absent until the host reports one. A registered source carries a `nonce` for its definition the same way, and its host-reported fields are absent until the host reports them. - **Action origin.** Every client-dispatched action's envelope carries the dispatcher's `clientId` in `ActionEnvelope.origin`. The host learns who registered a source from it, so the registry itself doesn't need client IDs. @@ -94,9 +94,7 @@ export interface RootState { /** * A model source registered on this host by a client, or by the host - * itself. The definition that tells the agent named by `provider` how to - * reach it travels on `root/modelSourceSet` and isn't kept here. Nothing - * here is a credential. + * itself. Nothing here is a credential. * * @category Root State * @stability 1.0 @@ -116,7 +114,7 @@ export interface ModelSource { /** Icons for UI display. */ icons?: Icon[]; /** - * The definition's format, one of the agent's + * The definition's format: the `format` of one of the agent's * `ModelSourceRegistrationCapability.formats`. Recognized values include: * * - `'openaiCompatible'`: an endpoint that implements OpenAI's API, such @@ -130,10 +128,30 @@ export interface ModelSource { */ format: string; /** - * Opaque version token for the definition, such as a hash of it, chosen - * by whoever registers the source. A client compares it with its own copy - * instead of the definition, and the reducer compares it to tell an update - * from a re-registration of the same definition. + * How to reach the source, in `format`: endpoint, wire API, models, and + * so on. The agent reads it, and AHP doesn't validate it. Every client + * can read it, so it MUST NOT contain a credential. + * + * Suggested shapes for the recognized formats. Agents MAY read more + * members, and MAY discover models when `models` is absent. + * + * - `openaiCompatible`: `{ endpoint, wireApi?: 'chatCompletions' | 'responses', models? }` + * - `anthropic`: `{ endpoint, models? }` + * - `azureOpenai`: `{ endpoint, apiVersion?, models? }`, with each + * deployment name as a model `id` + * - `gemini`: `{ endpoint, models? }` + * + * `endpoint` is the API's base URI, such as `https://api.example.com/v1`. + * Each `models` entry is `{ id, name?, maxContextWindow?, + * maxOutputTokens?, supportsVision?, supportsTools? }`, named as in + * `SessionModelInfo`, where `id` is the endpoint's own model identifier. + */ + definition: Record; + /** + * Opaque version token for `definition`, such as a hash of it, chosen by + * whoever registers the source. Reducers compare it, instead of the + * definition, to tell an update from a re-registration of the same + * definition. */ nonce: string; /** What happens when the last contributing client leaves. Absent means `contributingClient`. */ @@ -145,11 +163,6 @@ export interface ModelSource { /** Host-reported status. */ state?: ModelSourceState; - /** - * Host-issued token that a client echoes when it delivers the credential, - * and that tags every agent operation on the source. See §4.4. - */ - credentialNonce?: string; /** * RFC 9728 metadata for the endpoint the credential is for. Present * whenever the source takes a credential, in every state, so any client @@ -157,11 +170,6 @@ export interface ModelSource { * credential. */ credentialResource?: ProtectedResourceMetadata; - /** - * Every origin the host sends the credential to, such as - * `https://api.example.com`. Present whenever `credentialResource` is. - */ - credentialOrigins?: URI[]; /** * The `accountId` the client sent with the credential the host most * recently accepted. While the state is `starting` or `ready`, the host @@ -174,11 +182,11 @@ export interface ModelSource { } ``` -The `format` values follow the pattern of `Changeset.changeKind`: AHP recognizes a few names so clients and agents can agree on common cases, but it doesn't define what a definition contains, even for those ([§9](#_9-open-questions)). `definition` is opaque to AHP and belongs to the agent. +The `format` values follow the pattern of `Changeset.changeKind`: AHP recognizes a few names, and suggests a shape for each, so clients and agents can agree on common cases. It doesn't validate definitions, even for those, and an agent may expect more than the suggested shape ([§9](#_9-open-questions)). `definition` belongs to the agent. -The definition travels only on `root/modelSourceSet` ([§4.3](#_4-3-registering-updating-and-removing)). The host hands it to the agent and keeps it privately, and the reducer stores the source without it. Clients don't need the definition after it's submitted: they compare `nonce` with their own copy, and check where a key would go with the host-reported `credentialOrigins`. Actions are broadcast and replayed, so the definition is still never secret, and it MUST NOT contain a credential. +The definition is part of the registration, so any client can show, for example, which endpoint a source uses, and check it against its own copy before it sends a key ([§7](#_7-credential-rules)). Root state and the action stream are broadcast and replayed, so a definition is never secret, and it MUST NOT contain a credential. `nonce` versions the definition, so reducers compare a string rather than JSON ([§4.3](#_4-3-registering-updating-and-removing)). -`credentialResource.resource` is the endpoint URL as the definition names it, and the value a client passes back as `authenticate({ resource })`. `credentialResource.resource_name` labels the prompt, for example "OpenRouter API key". A source that accepts OAuth access tokens advertises `authorization_servers` and `scopes_supported`. A source that takes a user-supplied secret omits them. A source whose models use several endpoints lists every origin in `credentialOrigins`, so a client can check them all before it sends a key ([§7](#_7-credential-rules)). +`credentialResource.resource` is the endpoint URI as the definition names it, and the value a client passes back as `authenticate({ resource })`. `credentialResource.resource_name` labels the prompt, for example "OpenRouter API key". A source that accepts OAuth access tokens advertises `authorization_servers` and `scopes_supported`. A source that takes a user-supplied secret omits them. A host may register sources itself, for example from configuration on a remote machine. Those sources have no contributing clients, and their retention behaves as `host`. @@ -301,17 +309,14 @@ export interface RootModelSourceStateChangedAction { type: ActionType.RootModelSourceStateChanged; // 'root/modelSourceStateChanged' id: string; state: ModelSourceState; - credentialNonce: string; /** Replaces the source's `credentialResource`. Absent clears it. */ credentialResource?: ProtectedResourceMetadata; - /** Replaces the source's `credentialOrigins`. Absent clears it. */ - credentialOrigins?: URI[]; /** Replaces the source's `accountId`. Absent clears it. */ accountId?: string; } ``` -Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the host-reported fields, it can't overwrite a client's newer definition. The host also tags every agent operation on the registration, such as validation, model discovery, and inference, with its current `credentialNonce`, and discards any result whose nonce is no longer current ([§4.4](#_4-4-credential-delivery-through-authenticate)). A slow result from before an update, a removal and re-add under the same `id`, or a key change therefore can't mark the current source `ready`, even when the definition has changed back to the same value. +Because the reducer ignores an unknown `id`, a status report that arrives after a registration is removed can't bring it back. Because it changes only the host-reported fields, it can't overwrite a client's newer definition. ### 4.3 Registering, updating, and removing @@ -325,14 +330,8 @@ Because the reducer ignores an unknown `id`, a status report that arrives after */ export interface RootModelSourceSetAction { type: ActionType.RootModelSourceSet; // 'root/modelSourceSet' - /** The model source, without host-reported fields. */ + /** The model source, including its `definition`, without host-reported fields. */ modelSource: ModelSource; - /** - * How to reach the source, in `modelSource.format`: endpoint, wire - * format, models, and so on. The host hands it to the agent. The reducer - * doesn't store it. MUST NOT contain a credential. - */ - definition: Record; } /** @@ -349,7 +348,7 @@ export interface RootModelSourceRemovedAction { The reducers follow the keyed-collection convention, with one twist so that re-registering the same definition doesn't disturb a working source: - **Add.** When no model source has the `id`, `Set` appends `modelSource`. -- **Re-register.** When one has, with the same `provider`, `format`, and `nonce`, `Set` keeps its host-reported fields (`state`, `credentialNonce`, `credentialResource`, `credentialOrigins`, and `accountId`) and takes `displayName`, `icons`, `retention`, and `_meta` from the action. The status, nonce, and credential are undisturbed. +- **Re-register.** When one has, with the same `provider`, `format`, and `nonce`, `Set` keeps its host-reported fields (`state`, `credentialResource`, and `accountId`) and takes everything else from the action. The status and credential are undisturbed. - **Update.** When any of the three differs, `Set` replaces the source. Its host-reported fields are absent until the host reports again. - **Remove.** `Removed` deletes the source by `id`, or returns the state unchanged. @@ -365,7 +364,7 @@ The host rejects a client-dispatched `Set`, through `ActionEnvelope.rejectionRea - the agent named by `provider` doesn't advertise `modelSourceRegistration`, or doesn't list `format`; - `modelSource` includes any host-reported field; -- its `provider`, `format`, and `nonce` match the existing source's, but `definition` differs from the definition the host holds. A re-registration must not carry a different definition, because reducers keep the credential for it; +- its `provider`, `format`, and `nonce` match the existing source's, but its `definition` differs. A re-registration must not carry a different definition, because reducers keep the credential for it; - `id` equals a `ModelSourceInfo.id` that the agent declares itself. The catalog entry the host publishes for this same source doesn't count, so a ready source can still be re-registered or updated; - the host won't honor the requested `retention`. The client can register again with `contributingClient` retention; - the source is one the host registered itself; @@ -375,7 +374,7 @@ A host MAY reject a client's `Removed` for a source it registered itself, or one The host tracks contributing clients itself, from `ActionEnvelope.origin`. An add or a re-registration adds the dispatching client. An update makes the dispatching client the only one, because the others registered a different definition. When the last contributing client leaves, retention decides what happens ([§6](#_6-lifecycle)). -When `Set` updates a source, because its `provider`, `format`, or `nonce` changed, the host drops its credential, issues a new `credentialNonce`, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A re-registration, or a change to `displayName`, `icons`, `retention`, or `_meta`, keeps the credential and the nonce. +When `Set` updates a source, because its `provider`, `format`, or `nonce` changed, the host drops its credential, and the source goes back through `starting`. A changed definition must never receive a key that was supplied for a different one. A re-registration, or a change to `displayName`, `icons`, `retention`, or `_meta`, keeps the credential. ### 4.4 Credential delivery through `authenticate` @@ -400,11 +399,6 @@ export interface ModelSourceAuthenticateTarget { kind: AuthenticateTargetKind.ModelSource; /** The model source's `id`. */ modelSourceId: string; - /** - * The model source's current `credentialNonce`, as published in root - * state. The host rejects a stale one with `Conflict` (-32011). - */ - credentialNonce: string; } export type AuthenticateTarget = @@ -425,8 +419,7 @@ export type AuthenticateTarget = "accountId": "keychain-5c2a", "target": { "kind": "modelSource", - "modelSourceId": "2f6c0e1a-model-source", - "credentialNonce": "9b41d7" + "modelSourceId": "2f6c0e1a-model-source" } } } @@ -438,15 +431,9 @@ Clients MUST include a `modelSource` target when they deliver a registered sourc Clients SHOULD include the existing `accountId` parameter when they deliver a credential, and omit it when they revoke one. The host publishes it as the source's `accountId`, which lets a client that reloads, or one on another device, tell whether the host holds its current key. `accountId` is opaque and MUST NOT be derived from the secret. For an API key that has no account of its own, a client uses an ID that changes whenever the user replaces the key, such as one derived from where it stores the key and when the key last changed. -`credentialNonce` fences every credential change, and works as the source's generation. The host issues a new nonce whenever a source is added, including one registered again under a removed `id`, and whenever `Set` updates it, whether or not it held a credential. It also issues one whenever it installs or drops a credential: on delivery, rotation, expiry, rejection, and revocation. An `authenticate` built before any of those changes is stale, so: - -- a key meant for an old definition never reaches a new one, even when the endpoint didn't change; -- a rotation that crosses a revocation can't undo the revocation; -- when two clients answer the same `authRequired`, the first wins, and the second gets `Conflict`, re-reads state, and finds the source ready. +As with MCP servers, the target names the source but not a version of it. A delivery replaces whatever credential the host holds for the source, so when two clients answer the same `authRequired`, the later one wins. -The host tags every agent operation on the source with the current nonce and discards any result, success or failure, that carries an older one. A late failure can't drop a key that has since replaced it, and a late success can't mark an updated or re-added source `ready`, even after an edit that changes the definition back. Random values meet the rule that a nonce is never reused for the same `id`. - -The credential fields stay in root state for as long as the source takes a credential, not only while it's `authRequired`. Any client, including one that connected after the source became ready, can build an `authenticate` request at any time: to rotate a short-lived token before it expires, or to revoke a key with an empty token. +`credentialResource` stays in root state for as long as the source takes a credential, not only while it's `authRequired`. Any client, including one that connected after the source became ready, can build an `authenticate` request at any time: to rotate a short-lived token before it expires, or to revoke a key with an empty token. **When a client delivers.** A client delivers a credential only in answer to the source's current state, reading it from its own secure storage or token provider each time. It MUST NOT cache a credential it delivered, or replay one, for example after a reconnect. It delivers one when: @@ -467,7 +454,6 @@ When `target.kind` is `modelSource`, the host: - MUST apply the credential only to that model source. It never applies it to other model sources, MCP servers, or agent-level resources, even when they share `resource`. - MUST require `resource` to equal the source's current `credentialResource.resource`. - MUST reject an unknown `modelSourceId` with `InvalidParams` (`-32602`). -- MUST reject a `credentialNonce` other than the one it most recently issued for that source with `Conflict` (`-32011`). The client re-reads root state and, if the source still needs a credential, sends it again with the current nonce. - MUST publish the request's `accountId` as the source's `accountId` when it accepts a credential, and clear it when the request has none. - MUST treat an empty `token` as revocation: it stops using the credential at once, drops it, and reports `authRequired` with `reason: revoked`. @@ -532,7 +518,7 @@ The host rejects `host` retention when it won't honor it ([§4.3](#_4-3-register ### 4.7 Discovering support -A client needs to know whether an agent accepts registrations, in what format, how long the host tolerates a disconnect, and whether the registry is shared across principals. Unlike the per-agent markers #543 dropped, this capability carries information a client can't get any other way. +A client needs to know whether an agent accepts registrations, and in what formats. Unlike the per-agent markers #543 dropped, this capability carries information a client can't get any other way. ```ts // types/channels-root/state.ts @@ -549,44 +535,32 @@ export interface AgentCapabilities { * @preserveUnknownMembers */ export interface ModelSourceRegistrationCapability { - /** - * Definition formats the agent reads, most preferred first: recognized - * values of `ModelSource.format`, or namespaced names for formats the - * agent defines itself. - */ - formats: string[]; - /** - * How long, in milliseconds, the host keeps counting a disconnected - * client as a contributing client before it treats the client as having - * left. - * - * @integer - * @minimum 0 - */ - gracePeriod?: number; - /** Whether clients acting for different principals share the registry. Absent means `shared`. */ - principalPolicy?: ModelSourcePrincipalPolicy; + /** Definition formats the agent reads, most preferred first. */ + formats: ModelSourceFormatInfo[]; } /** + * A definition format an agent reads. An object rather than a string so it + * can grow, for example with a JSON Schema for the format's definitions. + * * @category Root State - * @nonexhaustive + * @stability 1.0 + * @preserveUnknownMembers */ -export const enum ModelSourcePrincipalPolicy { - /** Every connected client may change, supply credentials for, and select every model source. */ - Shared = 'shared', +export interface ModelSourceFormatInfo { /** - * The host verifies principals, and limits changes, credentials, and - * selection of each model source to clients of the principal that - * registered it. + * A recognized `ModelSource.format` value, or a namespaced name for a + * format the agent defines itself. */ - Isolated = 'isolated', + format: string; } ``` -A client that knows none of an agent's formats doesn't register with it. AHP recognizes a few format names ([§4.1](#_4-1-the-registry)) but doesn't define what a definition contains. +A client that knows none of an agent's formats doesn't register with it. AHP recognizes a few format names and suggests a shape for each ([§4.1](#_4-1-the-registry)), but doesn't validate definitions. + +How long the host waits for a disconnected client to come back ([§6](#_6-lifecycle)), and whether it restricts sources by principal, are host policy. They aren't in the capability, because a client doesn't change what it does or shows because of them. -**Principals.** AHP doesn't verify which client is which, so by default every connected client is trusted equally, as with MCP servers. Where a host can verify principals, it MAY restrict changes, credentials, and use of a model source to clients of the principal that registered it, and advertises `isolated`. Root state still lists every model source to every client, and the action stream carries every definition, so neither is private. A host whose connections carry credentials scoped to one client, such as a relay that forwards each client's own sign-in, SHOULD NOT let one client's model source be used by another: it uses `isolated`, or doesn't advertise `modelSourceRegistration`. +**Principals.** AHP doesn't verify which client is which, so every connected client is trusted equally, as with MCP servers. Where a host can verify principals, it MAY restrict changes, credentials, and use of a model source to clients of the principal that registered it, and rejects the rest through the usual failure paths. Root state still lists every model source, with its definition, to every client, so neither is private. A host whose connections carry credentials scoped to one client, such as a relay that forwards each client's own sign-in, SHOULD NOT let one client's model source be used by another: it restricts sources by principal, or doesn't advertise `modelSourceRegistration`. ### 4.8 Change table @@ -594,15 +568,15 @@ What a follow-up implementation would touch: | Symbol | File | Kind | | --- | --- | --- | -| `RootState.modelSources`, `ModelSource` (including `nonce`, the recognized `format` values, and the host-reported `credentialNonce`, `credentialResource`, `credentialOrigins`, and `accountId`) | `channels-root/state.ts` | added | +| `RootState.modelSources`, `ModelSource` (including `definition` with suggested shapes for the recognized `format` values, `nonce`, and the host-reported `credentialResource` and `accountId`) | `channels-root/state.ts` | added | | `ModelSourceStatus`, four `ModelSource*State` variants, `ModelSourceState`, `ModelSourceAuthRequirement`, `ModelSourceAuthRequiredReason` | `channels-root/state.ts` | added (lifecycle union) | | `ModelSourceRetentionPolicy` | `channels-root/state.ts` | added | -| `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability`, `ModelSourcePrincipalPolicy` | `channels-root/state.ts` | added (capability) | -| `root/modelSourceSet` (with `definition`, which the reducer doesn't store), `root/modelSourceRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | +| `AgentCapabilities.modelSourceRegistration`, `ModelSourceRegistrationCapability`, `ModelSourceFormatInfo` | `channels-root/state.ts` | added (capability) | +| `root/modelSourceSet`, `root/modelSourceRemoved` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (client-dispatchable, introduced in the development version) | | `root/modelSourceStateChanged` | `channels-root/actions.ts`, `common/actions.ts`, `version/registry.ts` | added (host-only, introduced in the development version) | | Root reducer | `channels-root/reducer.ts` | add, re-register, update, remove, and status change, with fixtures for every branch | | Client reducers | `clients/{go,rust,kotlin,swift,dotnet}/` | apply the three root actions, so they pass the shared fixtures | -| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId` and `credentialNonce`), `AuthenticateTarget` | `common/commands.ts` | added, widened | +| `AuthenticateTargetKind.ModelSource`, `ModelSourceAuthenticateTarget` (with `modelSourceId`), `AuthenticateTarget` | `common/commands.ts` | added, widened | | `AuthenticateParams.target`, `resource`, and `accountId` docs | `common/commands.ts` | generalized beyond MCP servers, including opaque secrets that aren't Bearer tokens | | `ErrorInfo.errorType` docs | `common/state.ts` | the well-known `modelSourceUnavailable` value | | `ModelSourceInfo`, `SessionModelInfo.modelSourceId` docs | `channels-root/state.ts` | registered sources, provenance, and reserved IDs | @@ -621,17 +595,17 @@ sequenceDiagram participant E as Model endpoint C->>H: initialize - H-->>C: root snapshot (agent advertises modelSourceRegistration with formats and gracePeriod) + H-->>C: root snapshot (agent advertises modelSourceRegistration with its formats) - C->>H: root/modelSourceSet (modelSource with nonce, definition) + C->>H: root/modelSourceSet (modelSource with definition and nonce) H->>A: read and validate the definition - H-->>C: root/modelSourceStateChanged (authRequired, credentialNonce, credentialResource, credentialOrigins) + H-->>C: root/modelSourceStateChanged (authRequired, credentialResource) - C->>H: authenticate({ resource, token, accountId, target: { kind: 'modelSource', modelSourceId, credentialNonce } }) + C->>H: authenticate({ resource, token, accountId, target: { kind: 'modelSource', modelSourceId } }) H-->>C: {} A->>E: list models (credential attached) E-->>A: models - H-->>C: root/modelSourceStateChanged (ready, new credentialNonce, accountId) + H-->>C: root/modelSourceStateChanged (ready, accountId) H-->>C: root/agentsChanged (the source and its models join the agent catalog) C->>H: chat/turnStarted in any session on that agent (message.model: { id }) @@ -642,10 +616,10 @@ sequenceDiagram ``` 1. The client reads the agent's `modelSourceRegistration` capability and picks a format it can write. -2. It dispatches `root/modelSourceSet` with the source, its `nonce`, and the definition. The host counts the client as a contributing client, the agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. -3. If a credential is needed, the host reports `authRequired` with a `credentialNonce`, the `credentialResource` the key is for, and every origin it would send the key to. The client checks those against its own copy and calls `authenticate` with that `resource`, an `accountId` naming its key, and a `modelSource` target that echoes the nonce. -4. The agent lists models. The host reports `ready`, with a new nonce because a key was installed, and the `accountId` of the key it now holds. It adds the source and its models to the agent's catalog. -5. Another window or device that has the same source configured dispatches the same `Set`. Its `nonce` matches, so it becomes a contributing client without disturbing the status, nonce, or credential. It sees the `accountId` and doesn't send its key again. +2. It dispatches `root/modelSourceSet` with the source, including its definition and `nonce`. The host counts the client as a contributing client, the agent reads and validates the definition, and the host reports `starting` with `root/modelSourceStateChanged`. +3. If a credential is needed, the host reports `authRequired` with the `credentialResource` the key is for. The client checks the source's definition against its own copy and calls `authenticate` with that `resource`, an `accountId` naming its key, and a `modelSource` target. +4. The agent lists models. The host reports `ready`, with the `accountId` of the key it now holds. It adds the source and its models to the agent's catalog. +5. Another window or device that has the same source configured dispatches the same `Set`. Its `nonce` matches, so it becomes a contributing client without disturbing the status or credential. It sees the `accountId` and doesn't send its key again. 6. Any client can select those models in any session on that agent, and so can automations if the source has `host` retention. 7. When the last contributing client leaves, the retention policy decides whether the source stays (see [§6](#_6-lifecycle)). @@ -655,12 +629,12 @@ sequenceDiagram ### When a contributing client leaves -A contributing client leaves when its connection closes and it doesn't reconnect with the same `clientId` within the host's grace period, which the host advertises as `gracePeriod`. The host stops counting it. While other contributing clients remain, nothing else changes. When the last one leaves: +A contributing client leaves when its connection closes and it doesn't reconnect with the same `clientId` within a grace period the host chooses. The host stops counting it. While other contributing clients remain, nothing else changes. When the last one leaves: - **`contributingClient` retention (the default).** The host stops new work on the source and withdraws its models from the catalog: a new turn or a pending message that names one of its models fails. Turns already running on it SHOULD finish, and the host MAY bound how long it waits. Any client can still cancel such a turn with the existing cancellation actions. The host then removes the source with `root/modelSourceRemoved` and drops its credential. - **`host` retention.** The source stays, with its credential in memory and no contributing clients, until a client removes it or host policy expires it. A restart drops its credential (see below). It keeps serving every client and automation. If its credential expires or is rejected, the source goes to `authRequired`, and work that needs it fails until a client answers. -A client that comes back with the same `clientId` within the grace period is still counted, and dispatches `Set` only for the sources it changed. A client that comes back with a new `clientId` and the same configuration re-registers with `Set`, which keeps the status, nonce, and credential. +A client that comes back with the same `clientId` within the grace period is still counted, and dispatches `Set` only for the sources it changed. A client that comes back with a new `clientId` and the same configuration re-registers with `Set`, which keeps the status and credential. ### Removal and revocation stop work at once @@ -675,10 +649,10 @@ A selection that names a removed source's model fails. The host MUST NOT run the ### Rotation, expiry, rejection, and revocation -- **Rotation.** A new `authenticate` with the current nonce replaces the credential, and the host issues a new nonce and publishes the new `accountId`. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. -- **Expiry.** When a credential's lifetime or lease lapses, the host drops it, and the source goes to `authRequired` with `reason: expired` and a new nonce. A client may renew it: a fresh token, or the same static key with a new lease. Clients holding short-lived tokens or leases SHOULD renew before `expiresIn` elapses. -- **Rejection.** When the endpoint refuses a credential, the source goes to `authRequired` with `reason: rejected` and a new nonce, and `accountId` still names the refused key. No client sends a credential with that `accountId` again. A client whose key differs may send it, or ask the user for a new one. -- **Revocation.** An empty `token` drops the credential at once, and the source goes to `authRequired` with `reason: revoked` and a new nonce. No client delivers a credential again without a user's action, including other devices that have the key stored, and the new nonce rejects a delivery that was already in flight. +- **Rotation.** A new `authenticate` replaces the credential, and the host publishes the new `accountId`. The host MAY pass through `starting` while the agent re-lists models, keeping the models listed and their IDs stable. +- **Expiry.** When a credential's lifetime or lease lapses, the host drops it, and the source goes to `authRequired` with `reason: expired`. A client may renew it: a fresh token, or the same static key with a new lease. Clients holding short-lived tokens or leases SHOULD renew before `expiresIn` elapses. +- **Rejection.** When the endpoint refuses a credential, the source goes to `authRequired` with `reason: rejected`, and `accountId` still names the refused key. No client sends a credential with that `accountId` again. A client whose key differs may send it, or ask the user for a new one. +- **Revocation.** An empty `token` drops the credential at once, and the source goes to `authRequired` with `reason: revoked`. No client delivers a credential again without a user's action, including other devices that have the key stored. ### Turns on an unavailable source @@ -692,21 +666,21 @@ Credentials are gone after a restart, because they were never persisted. `contri ## 7. Credential rules -1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes the definition on `root/modelSourceSet`, `nonce`, `_meta`, `ErrorInfo`, `credentialResource`, `credentialOrigins`, `accountId`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`, and neither `nonce` nor `accountId` is derived from it. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. +1. **Never in state, actions, or notifications.** All of these are broadcast to subscribers. That includes the `definition`, `nonce`, `_meta`, `ErrorInfo`, `credentialResource`, `accountId`, and `ModelSourceAuthRequirement`. A secret travels only in `authenticate`, and neither `nonce` nor `accountId` is derived from it. The host writes `description` and `ErrorInfo` itself, and SHOULD NOT copy upstream response bodies or headers into them: an endpoint's error text can echo part of a key, and every client can read root state. 2. **Memory only.** The host holds it only in memory. It is never persisted and never placed in environment variables, command lines, logs, telemetry, or error messages. The host SHOULD also redact it from tool output before storing that output or sending it to the model. That's best effort: rule 4 keeps the host from handing the secret to tools, but the same secret can also live where the agent can read it, such as a `.env` file or the user's shell environment, and a host can only redact values it knows. -3. **Scoped to one model source and one `credentialNonce`.** It is never shared with other model sources, MCP servers, or the agent's own protected resources, and a key sent for an earlier definition never reaches a later one. -4. **Sent only where the host says.** The host attaches it only to that source's requests, as its definition specifies, and only to origins in `credentialOrigins`. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. +3. **Scoped to one model source.** It is never shared with other model sources, MCP servers, or the agent's own protected resources. +4. **Sent only where the definition says.** The host attaches it only to that source's requests, as its definition specifies, and only to the endpoints its definition names. It is never sent to another origin, including on redirect, and never exposed to the model, tools, terminals, or hooks. 5. **Dropped** when the source is removed, when `Set` updates it, when it's revoked, when its lease lapses, and when the host restarts. 6. **Re-requested through state.** The host asks again by setting `authRequired`. State survives reconnects; `auth/required` notifications are not replayed. 7. **Delivered only in answer to state.** Clients MUST NOT cache a model source credential they delivered, or replay one, for example on reconnect. They deliver one only in answer to the source's current state ([§4.4](#_4-4-credential-delivery-through-authenticate)), reading it from their own secure storage or token provider. Clients SHOULD NOT prompt the user for a key they don't have. -8. **Checked by the client.** A client MUST NOT send a stored secret unless the source's `provider`, `format`, and `nonce` match its own copy, and every origin in `credentialOrigins` is one its own copy of the definition sends the key to. The host derives `credentialOrigins` from the definition it actually holds, so the origin check doesn't depend on another client choosing `nonce` honestly. `credentialNonce` stops a delayed reply, but not a device whose copy is out of date or a source another client has changed. +8. **Checked by the client.** A client MUST NOT send a stored secret unless the source's `provider` and `format` match its own copy, and every endpoint in the source's `definition` that the key would reach is one its own copy sends the key to. It checks the definition itself rather than trusting `nonce`, which another client chooses. 9. **Reached from the host.** Endpoints in a definition, including loopback and private addresses, are resolved and reached from the host machine: `localhost` in a source registered with a remote host is that host, not the client's machine. Hosts SHOULD apply an egress policy to registered endpoints: deny link-local and cloud metadata addresses, and require `https` for any credentialed endpoint that isn't a loopback address, unless the host has opted in to plain `http`. --- ## 8. Out of scope for AHP -- Defining what a definition contains, even for the recognized `format` values. `definition` stays opaque and belongs to the agent. +- Validating definitions. AHP suggests a shape for each recognized `format` value ([§4.1](#_4-1-the-registry)), but `definition` is open JSON that belongs to the agent. - Endpoint validation beyond rule 9's egress policy, model discovery, capability derivation, and wire protocols. These belong to the agent. - Client-side credential storage, and keys the host stores itself. That is host-owned authentication ([#404](https://github.com/microsoft/agent-host-protocol/pull/404)); see the open questions. - How a host verifies principals. @@ -720,9 +694,9 @@ Hosts apply policy appropriate to the source, for example by declining registrat ## 9. Open questions - **Holding a turn for a credential.** A turn whose credential fails ends with the resumable `modelSourceUnavailable` error (see [§6](#turns-on-an-unavailable-source)). Should a host instead be able to hold the turn visibly, with a `modelSourceAuthentication` input request in `SessionState.inputNeeded`? It would carry a `ModelSourceAuthRequirement`, the way MCP's tool authentication request carries an `McpAuthRequirement`. -- **Definitions for the recognized formats.** AHP recognizes a few `format` names but doesn't define what their definitions contain, so two agents that both read `openaiCompatible` may still expect different definitions. Should AHP define a small shared definition for each recognized format, for example in [Open Plugins](https://open-plugins.com/), so one definition works with any agent? +- **Definitions for the recognized formats.** AHP suggests a shape for each recognized `format` but doesn't require it, so two agents that both read `openaiCompatible` may still expect different definitions. Should the suggested shapes become normative, for example as a JSON Schema on `ModelSourceFormatInfo`, or in [Open Plugins](https://open-plugins.com/), so one definition works with any agent? - **Keys that survive a restart, and host-owned authentication.** `host` retention keeps a key only in memory. Keeping it across restarts needs the host to store it, which #404 doesn't cover yet: its flows are OAuth only, and its account consumers are agents and MCP servers. Once host-owned authentication lands, it's likely to become the canonical place for model source credentials, and the `modelSource` target and the `accountId` published here would follow it. An API key also has no authority-qualified account for [#459](https://github.com/microsoft/agent-host-protocol/pull/459)'s revocation. -- **Hiding sources from other principals.** `isolated` lets a host restrict who changes, supplies credentials for, and uses a model source, but root state still lists every source, and the action stream carries every definition, to every client. Should a host be able to hide sources from clients of other principals? That would be a new pattern for root state. +- **Hiding sources from other principals.** A host that restricts sources by principal limits who changes, supplies credentials for, and uses a model source, but root state still lists every source, with its definition, to every client. Should a host be able to hide sources from clients of other principals? That would be a new pattern for root state. - **Duplicates.** Clients that derive different `id`s for the same service get two sources. Should a host merge them? --- @@ -747,9 +721,11 @@ Hosts apply policy appropriate to the source, for example by declining registrat - Per-session enablement and per-session model sets, which the customization lifecycle provides, don't match how BYOK is configured. - **A `SessionActiveClient.modelSources` field with host-published copies.** The first draft of #619. It makes the client the source of truth for model metadata it can't validate, and has the same session-scope problems. - **Host configuration.** Model sources could be values in `RootConfigState`, changed with `root/configChanged`. Config has no per-entry provenance, status, or credential target, so each would need adding anyway. -- **Per-client sharing and ownership.** An earlier draft let the contributing client limit who could use a source and who could change it, so one client couldn't spend another's key. AHP can't verify which client is which, any connected client can already run tools as the host's user, and MCP servers have no such limits. The rules added complexity without protection, so they were dropped. A host that can verify principals advertises `isolated` instead ([§4.7](#_4-7-discovering-support)). +- **Per-client sharing and ownership.** An earlier draft let the contributing client limit who could use a source and who could change it, so one client couldn't spend another's key. AHP can't verify which client is which, any connected client can already run tools as the host's user, and MCP servers have no such limits. The rules added complexity without protection, so they were dropped. A host that can verify principals may restrict sources instead ([§4.7](#_4-7-discovering-support)). - **Client IDs in state.** Earlier drafts recorded the client that last wrote a source, and then a list of contributing clients with a per-client withdrawal action. A source can outlive the connections that registered it, so those IDs mean little to other clients. The host learns who registered a source from `ActionEnvelope.origin` and tracks contributing clients itself, which is all `contributingClient` retention needs. -- **Definitions in state.** An earlier draft kept each definition in root state so clients could compare it with their own, which forced every client's reducer to compare JSON values the same way. Only the host and its agent need the definition after it's submitted. A `nonce` lets clients compare versions, as `ClientPluginCustomization.nonce` does, and the host-reported `credentialOrigins` lets them check where a key would go. +- **Definitions only on the action.** An earlier revision kept the definition out of root state: it traveled only on `root/modelSourceSet`, and the host published the origins a key would reach as `credentialOrigins`. Clients then couldn't show which endpoint a source uses, so the definition is back in state. `nonce` still spares reducers from comparing JSON, as `ClientPluginCustomization.nonce` does. +- **A host-issued credential nonce.** An earlier revision had the host issue a `credentialNonce` that every `authenticate` echoed and that tagged every agent operation, so a delayed delivery or agent result couldn't apply to a newer definition or key. MCP server authentication has no such fence, the races it closed need a delivery to cross another client's change to the same source, and a host can discard stale agent results without a protocol field, so it was dropped. +- **Host policy in the capability.** An earlier revision advertised the host's disconnect grace period and whether it restricted sources by principal. A client doesn't change what it does or shows because of either, so both stay host policy. - **Hiding registrations per connection.** Root state is one shared, replayable state, and this proposal trusts every connected client, so it doesn't project different registries to different clients. - **Reporting status by rewriting the registration.** An earlier draft had the host dispatch the whole registration back with `state` added. A late status write could then bring back a removed registration or overwrite a newer definition, which took several extra rules to prevent. A narrow status action, as MCP uses, prevents both by construction. - **Host-to-client credential fetch per request.** The host would ask the contributing client for the key on each request, so it never rests on the host. AHP has host-to-client requests, such as the `resource*` family, but a fetch per model request adds a client round trip to every request and can't serve headless work once the client leaves. @@ -763,7 +739,7 @@ Applying the [doctrine's design tests](/guide/doctrine#design-tests): - **Can a minimal client ignore this and still render a coherent session?** Yes. It sees ordinary models in the agent's catalog, and turns use whichever model it picks. - **Is the durable, user-visible result represented in state?** Yes. Registrations, their status, and their models live in root state. The credential is deliberately not state, because it is a secret. - **Does the host remain the authority?** Yes. The host validates registrations, decides status and policy, mints model IDs, and checks every selection. Clients send a definition and a secret, never a catalog. -- **Does this expose an agent implementation detail?** Only the format name. The definition's content, discovery, wire protocol, model ID mapping, and how a key is attached stay with the agent. +- **Does this expose an agent implementation detail?** Only the format name, and a suggested definition shape for the recognized formats. Reading the definition, discovery, wire protocol, model ID mapping, and how a key is attached stay with the agent. - **Does it fit an existing channel?** Yes. The registry is root state, and the credential uses root `authenticate`. No new channel. - **Can clients discover support through capabilities or optional state?** Yes, through the agent's `modelSourceRegistration` capability and its formats. - **Is provider-specific metadata an enhancement rather than a requirement?** Yes. `_meta` on registrations and models stays optional.