AgentHostBuilder Class

Definition

Composable builder for configuring and starting an agent server. Wraps WebApplicationBuilder (via CreateSlimBuilder(String[])) and exposes protocol registration, health checks, tracing, shutdown, and escape hatches.

public sealed class AgentHostBuilder
type AgentHostBuilder = class
Public NotInheritable Class AgentHostBuilder
Inheritance
AgentHostBuilder

Properties

Name Description
Configuration

Escape hatch to the underlying configuration.

Services

Escape hatch to the underlying service collection.

VersionRegistry

Registry for protocol version identity segments appended to the x-platform-server response header. Protocol extensions register their identity during route mapping.

WebApplicationBuilder

Access the WebApplicationBuilder for advanced scenarios.

Methods

Name Description
Build()

Finalize configuration and build the runnable AgentHostApp.

Configure(Action<AgentHostOptions>)

Configure agent server options (port, shutdown timeout, identity).

ConfigureHealth(Action<IHealthChecksBuilder>)

Add custom health checks alongside the default liveness probe.

ConfigureShutdown(TimeSpan)

Set the graceful shutdown timeout. This is a convenience shorthand for Configure(o => o.ShutdownTimeout = timeout).

ConfigureTracing(Action<TracerProviderBuilder>)

Add custom tracing sources or configure the OpenTelemetry.Trace.TracerProviderBuilder.

RegisterProtocol(String, Action<IEndpointRouteBuilder>)

Registers a protocol with the builder. Throws if the protocol is already registered. Called by protocol extension methods (e.g., AddResponses, AddInvocations).

Extension Methods

Name Description
AddInvocations(AgentHostBuilder, Func<IServiceProvider,InvocationHandler>, Action<InvocationsServerOptions>)

Registers the Invocations protocol with a factory delegate that creates the handler. Use this overload when you need full control over handler construction while still having access to the IServiceProvider.

AddInvocations(AgentHostBuilder, InvocationHandler, Action<InvocationsServerOptions>)

Registers the Invocations protocol with a pre-constructed handler instance.

AddInvocations<THandler>(AgentHostBuilder, Action<InvocationsServerOptions>)

Registers the Invocations protocol with the agent server builder using the specified THandler as the invocation handler.

AddResponses(AgentHostBuilder, Func<IServiceProvider,ResponseHandler>, Action<ResponsesServerOptions>)

Registers the Responses protocol with a factory delegate that creates the handler. Use this overload when you need full control over handler construction while still having access to the IServiceProvider.

AddResponses(AgentHostBuilder, ResponseHandler, Action<ResponsesServerOptions>)

Registers the Responses protocol with a pre-constructed handler instance.

AddResponses<THandler>(AgentHostBuilder, Action<ResponsesServerOptions>)

Registers the Responses protocol with the agent server builder using the specified THandler as the response handler.

Applies to