Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cf4ab42
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 23, 2026
0ae73ce
models: add model source registry
lramos15 Nov 23, 2026
ce8b39b
models: document registered sources on SessionModelInfo.modelSourceId
lramos15 Nov 23, 2026
673c5b4
Merge remote-tracking branch 'origin/agents/model-provider-selection-…
lramos15 Nov 24, 2026
9ae8ceb
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
f3a60a0
models: add credentialNonce and tighten registry rules
lramos15 Nov 24, 2026
2058825
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
a781589
models: follow MCP for registry ownership and status
lramos15 Nov 24, 2026
a59d465
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
bd038f8
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
2f076e5
models: keep registered models listed across re-auth
lramos15 Nov 24, 2026
36c8dd7
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
70e8b1f
models: move the credential resource onto the registration
lramos15 Nov 24, 2026
5d7790d
models: name the registration's display field displayName
lramos15 Nov 24, 2026
bba6978
Merge commit '913d8648' into lramos15/model-source-customizations-impl
lramos15 Nov 24, 2026
8dfdaeb
Merge commit '43836efec1c87e5bbbd9e51aef2405444dd7e573' into lramos15…
lramos15 Nov 24, 2026
e06ed62
models: contributors, credential identity, and turn rules for the reg…
lramos15 Nov 24, 2026
8d85795
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
a03a5a1
models: rename to ModelSource and keep definitions out of state
lramos15 Nov 24, 2026
22bc2f8
Merge remote-tracking branch 'origin/lramos15/model-provider-customiz…
lramos15 Nov 24, 2026
d4f0aac
models: keep source definitions in state and trim host policy fields
lramos15 Nov 24, 2026
a4a01c0
Merge remote-tracking branch 'origin/agents/model-provider-selection-…
lramos15 Nov 24, 2026
b50e1f2
Merge remote-tracking branch 'origin/main' into lramos15/model-source…
lramos15 Nov 24, 2026
6a80f57
models: fold ModelSourceInfo into ModelSource and address review
lramos15 Nov 25, 2026
6abefee
docs: shorten the model source sections of the root channel spec
lramos15 Nov 25, 2026
7d0c327
docs: move model source details into a guide page
lramos15 Nov 25, 2026
d564d5f
Merge remote-tracking branch 'origin/main' into lramos15/model-source…
lramos15 Nov 25, 2026
0cdf3dc
Merge remote-tracking branch 'origin/main' into lramos15/model-source…
lramos15 Nov 25, 2026
281a82a
models: add ErrorInfo.errorCode and apply review suggestions
lramos15 Nov 25, 2026
2b520a3
models: register model sources through a request and a host-only Set
lramos15 Nov 25, 2026
cddbc7e
models: keep model source retention on the registration request only
lramos15 Nov 25, 2026
322dc21
docs: let clients wait for the model source after a registration request
lramos15 Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ public ActionType(string value)

public static readonly ActionType RootConfigChanged = new ActionType("root/configChanged");

public static readonly ActionType RootModelSourceRegisterRequested = new ActionType("root/modelSourceRegisterRequested");

public static readonly ActionType RootModelSourceSet = new ActionType("root/modelSourceSet");

public static readonly ActionType RootModelSourceRemoved = new ActionType("root/modelSourceRemoved");

public static readonly ActionType TerminalData = new ActionType("terminal/data");

public static readonly ActionType TerminalInput = new ActionType("terminal/input");
Expand Down Expand Up @@ -348,6 +354,71 @@ public sealed record RootConfigChangedAction
public bool? Replace { get; init; }
}

/// <summary>Adds a model source, or replaces the one with the same `id`. Only the host
/// dispatches it, to publish a registration, a source an agent provides
/// itself, or a change in a source's status.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record RootModelSourceSetAction
{
public ActionType Type { get; init; } = ActionType.RootModelSourceSet;

/// <summary>The model source to add or replace, matched by `id`.</summary>
public required ModelSource ModelSource { get; init; }
}

/// <summary>Removes the model source with the given `modelSourceId`, for every client.
/// A no-op when none matches.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record RootModelSourceRemovedAction
{
public ActionType Type { get; init; } = ActionType.RootModelSourceRemoved;

/// <summary>The model source's `id`.</summary>
public required string ModelSourceId { get; init; }
}

/// <summary>Asks the host to register a model source, or to update the one with the
/// same `modelSourceId`. The reducer leaves state unchanged. The host counts
/// the dispatching client as a contributing client, validates the
/// registration, and publishes the result with
/// {@link RootModelSourceSetAction | `root/modelSourceSet`}. It keeps the
/// source's status and credential when the registration is unchanged.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record RootModelSourceRegisterRequestedAction
{
public ActionType Type { get; init; } = ActionType.RootModelSourceRegisterRequested;

/// <summary>The model source's `id`, chosen by the client.</summary>
public required string ModelSourceId { get; init; }

/// <summary>Agent provider whose agent serves the source's models.</summary>
public required string Provider { get; init; }

/// <summary>Human-readable name.</summary>
public required string DisplayName { get; init; }

/// <summary>Icons for UI display.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<Icon>? Icons { get; init; }

/// <summary>The source's format and definition.</summary>
public required ModelSourceRegistration Registration { get; init; }

/// <summary>What happens to the source when the last contributing client leaves.
/// Absent means `contributingClient`. The host keeps it privately.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ModelSourceRetentionPolicy? Retention { get; init; }

/// <summary>Additional implementation-defined metadata for this model source.
/// MUST NOT contain a credential.</summary>
[JsonPropertyName("_meta")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, JsonElement>? Meta { get; init; }
}

/// <summary>Session backend initialized successfully.</summary>
public sealed record SessionReadyAction
{
Expand Down Expand Up @@ -2961,6 +3032,9 @@ public StateActionConverter()
["root/agentsChanged"] = typeof(RootAgentsChangedAction),
["root/activeSessionsChanged"] = typeof(RootActiveSessionsChangedAction),
["root/configChanged"] = typeof(RootConfigChangedAction),
["root/modelSourceSet"] = typeof(RootModelSourceSetAction),
["root/modelSourceRemoved"] = typeof(RootModelSourceRemovedAction),
["root/modelSourceRegisterRequested"] = typeof(RootModelSourceRegisterRequestedAction),
["session/ready"] = typeof(SessionReadyAction),
["session/creationFailed"] = typeof(SessionCreationFailedAction),
["session/turnStarted"] = typeof(SessionTurnStartedAction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ public AuthenticateTargetKind(string value)

public static readonly AuthenticateTargetKind McpServer = new AuthenticateTargetKind("mcpServer");

/// <summary>A {@link ModelSourceAuthenticateTarget}.</summary>
public static readonly AuthenticateTargetKind ModelSource = new AuthenticateTargetKind("modelSource");

/// <inheritdoc />
public bool Equals(AuthenticateTargetKind other) => string.Equals(Value, other.Value, StringComparison.Ordinal);

Expand Down Expand Up @@ -2001,14 +2004,30 @@ public sealed record McpServerAuthenticateTarget
public required string CustomizationId { get; init; }
}

/// <summary>A registered model source. The host applies the credential only to that
/// source, and publishes the request's `accountId` as the source's
/// `ModelSource.accountId`.
///
/// Stability: 1.0 - Early development.</summary>
public sealed record ModelSourceAuthenticateTarget
{
public AuthenticateTargetKind Kind { get; init; } = AuthenticateTargetKind.ModelSource;

/// <summary>The source's `ModelSource.id`.</summary>
public required string ModelSourceId { get; init; }
}

/// <summary>Pushes a Bearer token for a protected resource. The `resource` field MUST
/// match a protected-resource identifier the client has discovered from the
/// server — whether declared statically in `AgentInfo.protectedResources`,
/// or discovered dynamically from a live `McpServerAuthRequiredState.resource`
/// or `ToolCallAuthRequiredState.auth.resource` (both surfaced only once the
/// corresponding MCP server or tool call actually challenges for auth).
/// or `ToolCallAuthRequiredState.auth.resource` (each surfaced only once the
/// corresponding MCP server or tool call actually challenges for auth), or
/// from a registered model source's `ModelSource.credentialResource`.
/// Servers MUST accept any `resource` value they have themselves advertised
/// through one of these three mechanisms.
/// through one of these mechanisms, subject to the `target` rules. A
/// `modelSource` target takes only the source's current
/// `credentialResource.resource`.
///
/// Tokens are delivered using [RFC 6750](https://datatracker.ietf.org/doc/html/rfc6750)
/// (Bearer Token Usage) semantics. The client obtains the token from the
Expand All @@ -2027,7 +2046,8 @@ public sealed record AuthenticateParams
/// <summary>The protected resource identifier. MUST match a `resource` value the
/// server has advertised — via `ProtectedResourceMetadata` in
/// `AgentInfo.protectedResources`, or via a live
/// `McpServerAuthRequiredState.resource` / `ToolCallAuthRequiredState.auth.resource`.</summary>
/// `McpServerAuthRequiredState.resource`, `ToolCallAuthRequiredState.auth.resource`,
/// or `ModelSource.credentialResource`.</summary>
public required string Resource { get; init; }

/// <summary>Bearer token obtained from the resource's authorization server</summary>
Expand Down Expand Up @@ -2058,15 +2078,22 @@ public sealed record AuthenticateParams

/// <summary>Optional consumer of the token. Clients SHOULD include this when answering
/// a specific MCP server's `McpServerAuthRequiredState` or
/// `ToolCallAuthRequiredState` challenge, and omit it for provider-level
/// `ToolCallAuthRequiredState` challenge, MUST include it when delivering a
/// registered model source's credential, and omit it for provider-level
/// resources (`AgentInfo.protectedResources` or `AuthRequired` -32007 data).
///
/// When present, the host MUST apply the token only to that MCP server in
/// that session, never to sibling servers, other sessions, or agent-level
/// resources, even if they share the resource and scopes. `resource` MUST
/// still equal that server's advertised `McpAuthRequirement.resource.resource`.
/// The host MUST reject an unknown session or customization, or a
/// customization that is not an MCP server, with `InvalidParams` (-32602).
/// For an `mcpServer` target, the host MUST apply the token only to that MCP
/// server in that session, never to sibling servers, other sessions, or
/// agent-level resources, even if they share the resource and scopes.
/// `resource` MUST still equal that server's advertised
/// `McpAuthRequirement.resource.resource`. The host MUST reject an unknown
/// session or customization, or a customization that is not an MCP server,
/// with `InvalidParams` (-32602).
///
/// A registered model source takes its credential only through a
/// `modelSource` target, and the host rejects an untargeted `resource` that
/// matches only model source challenges with `InvalidParams` (-32602). See
/// [Model source credentials](/specification/authentication#model-source-credentials).
///
/// Without a target, resource/scope matching is unchanged; the token may
/// satisfy every matching pending challenge. Older hosts ignore this field.</summary>
Expand Down Expand Up @@ -2499,6 +2526,7 @@ public AuthenticateTargetConverter()
variants: new Dictionary<string, Type>
{
["mcpServer"] = typeof(McpServerAuthenticateTarget),
["modelSource"] = typeof(ModelSourceAuthenticateTarget),
},
allowUnknown: true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static class AhpErrorCodes
public const int Conflict = -32011;
/// <summary>The host could not open the requested TCP connection.</summary>
public const int TcpConnectionOpenFailed = -32012;
/// <summary>A request or turn needs a registered model source that can't serve it, for example because the source needs a credential or was removed. A turn carries it in its error part's `ErrorInfo.errorCode`. @see {@link /guide/model-sources#unavailable-sources | Model Sources guide}</summary>
public const int ModelSourceUnavailable = -32013;
}

/// <summary>Detail payload of an AuthRequired (-32007) error.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,20 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(MessageOrigin))]
[JsonSerializable(typeof(MessageResourceAttachment))]
[JsonSerializable(typeof(ModelSelection))]
[JsonSerializable(typeof(ModelSourceInfo))]
[JsonSerializable(typeof(ModelSource))]
[JsonSerializable(typeof(ModelSourceAuthenticateTarget))]
[JsonSerializable(typeof(ModelSourceAuthRequiredReason))]
[JsonSerializable(typeof(ModelSourceAuthRequiredState))]
[JsonSerializable(typeof(ModelSourceAuthRequirement))]
[JsonSerializable(typeof(ModelSourceErrorState))]
[JsonSerializable(typeof(ModelSourceFormatInfo))]
[JsonSerializable(typeof(ModelSourceReadyState))]
[JsonSerializable(typeof(ModelSourceRegistration))]
[JsonSerializable(typeof(ModelSourceRegistrationCapability))]
[JsonSerializable(typeof(ModelSourceRetentionPolicy))]
[JsonSerializable(typeof(ModelSourceStartingState))]
[JsonSerializable(typeof(ModelSourceState))]
[JsonSerializable(typeof(ModelSourceStatus))]
[JsonSerializable(typeof(MoveChatParams))]
[JsonSerializable(typeof(MoveChatResult))]
[JsonSerializable(typeof(MultipleChatProvidersCapability))]
Expand Down Expand Up @@ -373,6 +386,9 @@ namespace Microsoft.AgentHostProtocol;
[JsonSerializable(typeof(RootAgentsChangedAction))]
[JsonSerializable(typeof(RootConfigChangedAction))]
[JsonSerializable(typeof(RootConfigState))]
[JsonSerializable(typeof(RootModelSourceRegisterRequestedAction))]
[JsonSerializable(typeof(RootModelSourceRemovedAction))]
[JsonSerializable(typeof(RootModelSourceSetAction))]
[JsonSerializable(typeof(RootState))]
[JsonSerializable(typeof(RootTerminalsChangedAction))]
[JsonSerializable(typeof(RuleCustomization))]
Expand Down
Loading
Loading