Repository navigation
models: add model source registry - #627
Draft
Logan Ramos (lramos15) wants to merge 21 commits into
Draft
Logan Ramos (lramos15) wants to merge 21 commits into
Logan Ramos (lramos15) wants to merge 21 commits into
Conversation
There was a problem hiding this comment.
🔵 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>
Logan Ramos (lramos15)
force-pushed
the
lramos15/model-source-customizations-impl
branch
from
November 23, 2026 23:04
29c5961 to
0ae73ce
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 tomainwhen #543 merges.RootState.modelSourceRegistrationswithModelSourceRegistration, its retention policy (contributingClient,host), and three host-reported fields: a state (starting,ready,authRequired,error), acredentialNoncethat works as the registration's generation, and acredentialResourcewith the RFC 9728 metadata for the endpoint the key is for. Like MCP servers, registrations have no per-client ownership:clientIdrecords who last wrote one.root/modelSourceRegistrationSetandroot/modelSourceRegistrationRemoved;root/modelSourceStateChanged { id, state, credentialNonce, credentialResource? }, modeled onsession/mcpServerStateChanged. It's a no-op for an unknownid, so a late status can't revive a removed registration or overwrite a newer definition.AgentCapabilities.modelSourceRegistration { formats }.authenticategains amodelSourcetarget (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 withConflict, 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.No wire deviations from the proposal. Beyond its sketches, the new fields and actions carry
@stability 1.0and@seelinks, and a migration fragment covers exhaustive matches, TypeScript narrowing ofAuthenticateTarget, and Rust struct literals. The proposal's open questions (§9) stay open.Validation
npm run generate(twice)npm testtypes/reducers.tsand the root reducer at 100% branchescd clients/typescript && npm ci && npm test && npm run buildcd clients/rust && cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspacecd clients/go && gofmt -l . && go vet ./... && go test ./..../gradlew buildineclipse-temurin:17-jdkdotnet format whitespace --verify-no-changes && dotnet build -c Release && dotnet test -c Releaseindotnet/sdk:10.0swift build && swift testnpm run generate:docs && npm run docs:versions && npx vitepress build docsvitepress preview