Skip to content

models: add model source registry - #627

Draft
Logan Ramos (lramos15) wants to merge 21 commits into
agents/model-provider-selection-20261022from
lramos15/model-source-customizations-impl
Draft

Logan Ramos (lramos15) wants to merge 21 commits into
agents/model-provider-selection-20261022from
lramos15/model-source-customizations-impl

Conversation

@lramos15

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

Copy link
Copy Markdown
Member

Refs #619

Implements the model source registry proposal from #622 (docs/proposals/model-source-registry.md). Stacked on #543 and includes #622's proposal commits. GitHub retargets this to main when #543 merges.

  • State: RootState.modelSourceRegistrations with ModelSourceRegistration, its retention policy (contributingClient, host), and three host-reported fields: a state (starting, ready, authRequired, error), a credentialNonce that works as the registration's generation, and a credentialResource with the RFC 9728 metadata for the endpoint the key is for. Like MCP servers, registrations have no per-client ownership: clientId records who last wrote one.
  • Actions (introduced in 1.2.0, no protocol version bump):
    • client-dispatchable root/modelSourceRegistrationSet and root/modelSourceRegistrationRemoved;
    • host-only root/modelSourceStateChanged { id, state, credentialNonce, credentialResource? }, modeled on session/mcpServerStateChanged. It's a no-op for an unknown id, so a late status can't revive a removed registration or overwrite a newer definition.
  • Capability: AgentCapabilities.modelSourceRegistration { formats }.
  • Auth: authenticate gains a modelSource target (modelSourceId, credentialNonce). The host issues a new nonce when a registration is added or its definition changes and on every credential install or drop, rejects a stale one with Conflict, and discards agent results tagged with an older one. A delayed key can't reach a changed definition or undo a revocation, and a late result can't mark a changed source ready.
  • Reducers: the TypeScript root reducer and the Go, Rust, Kotlin, Swift, and .NET client reducers, with shared fixtures for every branch.
  • Also: registration in all five generators; round-trip fixtures for every state, the capability, all three actions, and the auth target; the root channel and authentication specs; the naming dictionary; and changelog fragments.

No wire deviations from the proposal. Beyond its sketches, the new fields and actions carry @stability 1.0 and @see links, and a migration fragment covers exhaustive matches, TypeScript narrowing of AuthenticateTarget, and Rust struct literals. The proposal's open questions (§9) stay open.

Validation

Command Result
npm run generate (twice) Idempotent
npm test 677 passed; types/reducers.ts and the root reducer at 100% branches
cd clients/typescript && npm ci && npm test && npm run build 79 passed; build OK
cd clients/rust && cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace Clean; 104 passed
cd clients/go && gofmt -l . && go vet ./... && go test ./... Passed, including 361 reducer fixtures
./gradlew build in eclipse-temurin:17-jdk BUILD SUCCESSFUL
dotnet format whitespace --verify-no-changes && dotnet build -c Release && dotnet test -c Release in dotnet/sdk:10.0 717 passed
swift build && swift test 104 passed
npm run generate:docs && npm run docs:versions && npx vitepress build docs Passed; diagrams and new anchors checked in vitepress preview

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Client-declared BYOK endpoints and cross-client credential retention warrant human architecture review because endpoint-policy enforcement, credential isolation, and erasure depend on host/agent implementations outside this PR.

No open issues 🎉

What changed in this PR

Implements #622’s model source customizations proposal on top of #543’s model catalogs. Clients can contribute bring-your-own-key model sources through plugins, deliver credentials through authenticate, and select their models within a session.

Changes:

  • Adds model source lifecycle types, sharing and retention policies, and a scoped authentication target.
  • Updates native generators, client models, reducers, and schemas, with shared round-trip and reducer fixtures.
  • Documents credential handling, model selection, and migration requirements without adding commands or bumping the protocol version.
File Description
types/​test-cases/​round-trips/​105-model-source-sharing-retention.json Covers published policies and an empty model catalog.
types/​test-cases/​round-trips/​104-active-client-child-model-sources.json Covers client policy options and defaults.
types/​test-cases/​round-trips/​103-authenticate-model-source-target.json Covers targeted credential delivery.
types/​test-cases/​round-trips/​102-model-source-customization-states.json Covers all four lifecycle states.
types/​test-cases/​reducers/​332-session-customizationremoved-model-source-child.json Covers removal while preserving siblings.
types/​test-cases/​reducers/​331-session-customizationtoggled-model-source-clears-enablement.json Covers clearing explicit enablement.
types/​test-cases/​reducers/​330-session-customizationtoggled-plugin-model-source.json Covers setting explicit enablement.
types/​common/​state.ts Documents model source endpoint scheme exceptions.
types/​common/​commands.ts Adds the model source authentication target and credential contract.
types/​channels-session/​state.ts Defines model source customizations, lifecycle, and policies.
types/​channels-session/​reducer.ts Applies scoped enablement to model sources.
types/​channels-session/​actions.ts Clarifies model source toggle documentation.
types/​channels-root/​state.ts Documents session model identity and source references.
scripts/​read-stability.test.ts Updates the expected generated stability marker count.
scripts/​generate-swift.ts Registers Swift model source types and unions.
scripts/​generate-rust.ts Registers Rust types, unions, and the auth reason import.
scripts/​generate-kotlin.ts Registers Kotlin model source types and unions.
scripts/​generate-go.ts Registers Go model source types and unions.
scripts/​generate-csharp.ts Registers C# model source types and unions.
schema/​state.schema.json Adds model source state definitions.
schema/​notifications.schema.json Includes model sources in notification state schemas.
schema/​actions.schema.json Includes model sources in action payload schemas.
docs/​specification/​root-channel.md Defines session model selection and reserved IDs.
docs/​specification/​authentication.md Specifies credential isolation, revocation, and recovery.
docs/​guide/​customizations.md Explains lifecycle, enablement, sharing, and retention.
docs/​.changes/​20261123-model-source-customizations.json Records the new protocol feature.
docs/​.changes/​20261123-model-source-customizations-migration.json Records exhaustive-match and Rust literal migrations.
clients/​swift/​AgentHostProtocol/​Sources/​AgentHostProtocol/​NativeReducer.swift Handles model source IDs and enablement.
clients/​swift/​AgentHostProtocol/​Sources/​AgentHostProtocol/​Generated/​Commands.generated.swift Adds generated authentication target support.
clients/​rust/​crates/​ahp/​src/​reducers.rs Handles model source IDs and enablement.
clients/​rust/​crates/​ahp-types/​src/​state.rs Adds generated lifecycle, customization, and policy models.
clients/​rust/​crates/​ahp-types/​src/​commands.rs Adds generated authentication target support.
clients/​rust/​crates/​ahp-types/​src/​actions.rs Mirrors updated toggle documentation.
clients/​kotlin/​src/​main/​kotlin/​com/​microsoft/​agenthostprotocol/​Reducers.kt Handles model source IDs and enablement.
clients/​kotlin/​src/​main/​kotlin/​com/​microsoft/​agenthostprotocol/​generated/​State.generated.kt Adds generated models and lifecycle serialization.
clients/​kotlin/​src/​main/​kotlin/​com/​microsoft/​agenthostprotocol/​generated/​Commands.generated.kt Adds authentication target models and serialization.
clients/​go/​ahptypes/​state.generated.go Adds generated models and lifecycle serialization.
clients/​go/​ahptypes/​commands.generated.go Adds authentication target models and serialization.
clients/​go/​ahptypes/​actions.generated.go Mirrors updated toggle documentation.
clients/​go/​ahp/​reducers.go Handles model source IDs and enablement.
clients/​dotnet/​src/​AgentHostProtocol/​Reducers.cs Handles model source IDs and enablement.
clients/​dotnet/​src/​AgentHostProtocol.Abstractions/​Generated/​JsonSerializerContext.generated.cs Registers new models for source-generated serialization.
clients/​dotnet/​src/​AgentHostProtocol.Abstractions/​Generated/​Commands.generated.cs Adds authentication target records and converter registration.
clients/​dotnet/​src/​AgentHostProtocol.Abstractions/​Generated/​Actions.generated.cs Mirrors updated toggle documentation.
.github/​instructions/​protocol-naming.instructions.md Defines model source and contributing client terminology.

Review effort: Balanced

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>
…ations' into lramos15/model-source-customizations-impl
Implements the host-wide model source registry from the model source
registry proposal (#622):

- `RootState.modelSourceRegistrations` with `ModelSourceRegistration`,
  its sharing and retention policies, and the `starting`, `ready`,
  `authRequired`, and `error` states.
- Client-dispatchable `root/modelSourceRegistrationSet` and
  `root/modelSourceRegistrationRemoved` actions (introduced in 1.2.0)
  with root reducers in TypeScript and every client.
- `AgentCapabilities.modelSourceRegistration` listing the definition
  formats an agent reads.
- A `modelSource` `authenticate` target for delivering a registered
  source's credential.
- Generator registration, reducer and round-trip fixtures, spec and
  naming docs, and changelog fragments.

Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lramos15
Logan Ramos (lramos15) force-pushed the lramos15/model-source-customizations-impl branch from 29c5961 to 0ae73ce Compare November 23, 2026 23:04
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lramos15 Logan Ramos (lramos15) changed the title customizations: add model source customizations models: add model source registry Nov 23, 2026
Logan Ramos (lramos15) and others added 16 commits November 24, 2026 07:43
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>
- 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>
…20261022' into lramos15/model-source-customizations-impl
…ations' into lramos15/model-source-customizations-impl
- `ModelSourceRegistration.credentialNonce` and the required
  `ModelSourceAuthenticateTarget.credentialNonce`, so a delayed
  `authenticate` can't reach a changed definition. The host rejects a
  stale nonce with `Conflict`.
- Specs follow #622: `Removed` is checked only against the stored
  registration, status updates are built from the current
  registration, revocation reports `reason: expired`, moving the
  endpoint mints new model IDs, clients send a stored secret only when
  the definition matches their copy, and the host writes status text
  and errors itself.
- Untargeted model source credentials are rejected with
  `InvalidParams`, and `ProtectedResourceMetadata.resource` notes the
  model source scheme exception.
- Renumber the registry round-trip fixtures after main's new fixture,
  align the Azure fixture's resource with its endpoint, and note the
  TypeScript `AuthenticateTarget` narrowing in the migration fragment.

Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
…ations' into lramos15/model-source-customizations-impl
Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove `ModelSourceSharingPolicy`, the `sharing` field, takeover, and
  the ownership checks on `Set`, `Removed`, and credential delivery.
  Any client may change or remove any registration and deliver or
  revoke its credential. `clientId` records who last wrote it.
- Add the host-only `root/modelSourceStateChanged { id, state,
  credentialNonce }` action, modeled on `session/mcpServerStateChanged`,
  with reducers in TypeScript and every client. It is a no-op for an
  unknown `id` and changes only `state` and `credentialNonce`.
- Only a change to `provider`, `format`, or `definition` drops the
  credential. The host issues a new nonce on every credential install
  or drop and ignores failures from requests made with an older key.
- Automations may use registrations with `host` retention, or ones the
  host registered.
- Update the specs, naming dictionary, fixtures, and changelog.

Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ations' into lramos15/model-source-customizations-impl
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>
…ations' into lramos15/model-source-customizations-impl
Once a registration has been ready, the host keeps its models in the
catalog through `starting` and `authRequired`, and 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. The snapshot fixture now lists the models of a source
whose key expired.

Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
…ations' into lramos15/model-source-customizations-impl
- `ModelSourceRegistration.credentialResource` is host-reported RFC 9728
  metadata for the endpoint the credential is for, kept in every state
  while the source takes a credential. `ModelSourceAuthRequirement`
  keeps only `reason` and `description`.
- `root/modelSourceStateChanged` gains an optional `credentialResource`
  and sets it with `state` and `credentialNonce`. Absent clears it.
  Reducers in TypeScript and every client follow.
- A client-dispatched `Set` must not include `credentialResource`, and
  `authenticate` matches `resource` against it.
- `credentialNonce` is the registration's generation: the host issues a
  new one when a registration is added or its provider, format, or
  definition changes, and discards any agent result tagged with an
  older one.
- Box the Rust `RootModelSourceRegistrationSet` variant, since the
  larger registration trips `large_enum_variant`.

Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The authentication documentation points clients to a nonexistent resource field, and the new registration field uses name instead of the required displayName convention.

2 open issues

Review effort: Balanced

Comment thread types/channels-root/state.ts Resolved
Comment thread docs/specification/authentication.md Resolved
Address review feedback on #627:

- Rename `ModelSourceRegistration.name` to `displayName`. The naming
  dictionary reserves `name` for stable or machine-oriented names, and
  the field is published as `ModelSourceInfo.displayName`.
- Point the authentication spec's Token Delivery paragraph at
  `ModelSourceRegistration.credentialResource.resource`, since
  `ModelSourceAuthRequiredState` no longer carries a resource.

Refs #619

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants