AgentHostBuilder Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
|
| 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 |
| 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., |
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 |
| 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 |