Skip to content

Hosted Endpoints ​

This reference lists the ASP.NET Core hosted runtime endpoints at contract level. Routes are relative to the route group prefix configured by MapHPDAgent(...). Created-resource Location headers include the mapped route prefix.

Endpoint examples use DTO names and status families. Event payload fields are delegated to Events, because exhaustive event schemas should be generated from source rather than hand-authored.

Scope Rules ​

A run is agentId + sessionId + threadId, and the three are independent. Routes follow that:

  • session and thread routes name the session and thread, never an agent
  • input names the agent that runs it in its body, and fork names the agent whose fork defaults apply in its body; either one left out uses the runtime's default agent
  • agent definitions, code and stored, and their capabilities live under /agents
  • what the runtime can run agents with lives under /composition

Mapping Surfaces ​

MapHPDAgent(...) maps the complete surface. Its HPDAgentEndpointOptions overload sets a RoutePrefix and turns individual surfaces off with flags such as MapAgents, MapComposition, MapCapabilities, MapClientToolProviders, MapContent, or MapStreaming; each is on by default. Applications can instead map separate groups:

MapperSurface
MapHPDAgentRuntimeApi(...)sessions, threads, executions, agent capabilities, composition, content, streaming, runtime state, responses, and the runtime-extension catalog
MapHPDAgentClientToolProvidersApi()client-tool provider inspection and development attachment
MapHPDAgentAdministrationApi(...)agent definitions and runtime-extension schema management; select either with HPDAgentAdministrationEndpointOptions

Each mapper returns a RouteGroupBuilder, so runtime and administration routes can receive different ASP.NET Core authorization policies:

csharp
var hpd = app.MapGroup("/hpd");

hpd.MapHPDAgentRuntimeApi("assistant")
   .RequireAuthorization("AgentUser");

hpd.MapGroup("/admin")
   .MapHPDAgentAdministrationApi("assistant")
   .RequireAuthorization("AgentAdmin");

The client-tool connection included by MapHPDAgentClientToolProvidersApi() and the full composite is not authorized by an IClientToolProviderConnectionAuthorizer. Production gateways should map MapAuthorizedHPDClientToolProviderConnection(...) instead.

Sessions ​

MethodRouteBodySuccessCommon failures
POST/sessionsCreateSessionRequest?201 SessionDto400 validation problem
GET/sessionsnone200 List<SessionDto>400
POST/sessions/searchSearchSessionsRequest?200 List<SessionDto>400
GET/sessions/{sessionId}none200 SessionDto404, 400
PATCH/sessions/{sessionId}UpdateSessionRequest200 SessionDto404, 400
DELETE/sessions/{sessionId}none204404, 400

CreateSessionRequest has optional sessionId and metadata. Missing session ids are generated. Creating a session through the hosted API creates a thread named main. Threads are not bound to an agent: each input route names the agent that runs it.

The initial thread is a convenience default. It is not protected and can be deleted. A session can remain valid with zero threads after its last thread is deleted.

SearchSessionsRequest filters by exact stringified metadata value and supports offset and limit. UpdateSessionRequest merges metadata and removes keys whose values are null.

Threads ​

MethodRouteBodySuccessCommon failures
GET/sessions/{sessionId}/threadsnone200 List<ThreadDto>404, 400
GET/sessions/{sessionId}/thread-graphnone200 ThreadGraphDto404, 400
GET/sessions/{sessionId}/threads/{threadId}none200 ThreadDto404, 400
POST/sessions/{sessionId}/threadsCreateThreadRequest201 ThreadDto404, 409, 400
POST/sessions/{sessionId}/threads/{threadId}/forkForkThreadRequest (optional agentId)201 ThreadForkResultDto404, 400
PATCH/sessions/{sessionId}/threads/{threadId}UpdateThreadRequest200 ThreadDto404, 400
DELETE/sessions/{sessionId}/threads/{threadId}?recursive=falsenone204404, 409, 400

ForkThreadRequest has newThreadId, fromMessageId, optional display metadata, tags, metadata, and an optional polymorphic compaction override. The override may inherit configured fork compaction, disable it, or apply an explicit CompactionSpecification. Its agentId names the agent whose fork defaults apply; omitted, the default agent's apply, and a runtime without a default agent returns 400 AgentIdRequired.

fromMessageId is optional. A string forks through that committed message; null creates a root fork before any messages. main is deletable like any other thread. Deleting a thread with children returns a validation error unless recursive=true, and recursive deletion also requires server configuration that allows it.

ThreadGraphDto returns full thread descriptors and fork groups. A thread another thread created carries that thread's parentSessionId and parentThreadId.

Thread Executions ​

MethodRouteBodySuccessCommon failures
GET/executions?agentId=&sessionId=&limit=none200 List<ThreadExecutionDto>400
GET/sessions/{sessionId}/threads/{threadId}/executionsnone200 List<ThreadExecutionDto>404, 400
GET/sessions/{sessionId}/threads/{threadId}/executions/{threadExecutionId}none200 ThreadExecutionDto404, 400
POST/sessions/{sessionId}/threads/{threadId}/executions/{threadExecutionId}/cancelnone200 cancellation result404, 409, 400

GET /executions lists one agent's executions across sessions, newest first. agentId is required; sessionId limits the list to one session; limit caps how many come back and must be positive. The agent is a filter on runs, not a route segment: a thread has no agent of its own.

ThreadExecutionDto carries threadExecutionId, agentId, sessionId, threadId, status, startedAt, finishedAt, error, operations, and models: the distinct { providerKey, modelId } pairs the run called, in the order it first used them. Either field is null when the client did not report it.

Projected execution status values are active, succeeded, failed, cancelled, and recovery-only interrupted.

Only one active hosted thread execution is allowed for a given sessionId + threadId. The session store's execution controller owns it. A UserMessagesInputEvent sent to a busy thread joins the running turn (steered, with the running threadExecutionId) or starts the next turn (started); it never names a threadExecutionId. Other work on a busy thread returns 409 ThreadExecutionActive.

The dedicated cancel route targets one exact runtime-owned execution and waits for its terminal fact. Messages that joined the cancelled turn before it read them are answered in one follow-up turn.

Agent Definitions ​

MethodRouteBodySuccessCommon failures
POST/agentsCreateAgentRequest201 AgentDefinitionDto400, 409
GET/agentsnone200 List<AgentDefinitionDto>400
GET/agents/{agentId}none200 AgentDefinitionDto404, 400
PATCH/agents/{agentId}UpdateAgentRequest200 AgentDefinitionDto404, 409, 400
DELETE/agents/{agentId}none204404, 409, 400
GET/agents/{agentId}/capabilitiesnone200 AgentCapabilitiesDto404, 500 agent_build_failed

Each route is the runtime.Agents read or write of the same name; the capability route is runtime.InspectCapabilitiesAsync(agentId), which builds the agent on first use. The definition routes are mapped by MapHPDAgentAdministrationApi(...); the capability route by MapHPDAgentRuntimeApi(...).

AgentDefinitionDto carries id, source (Code or Stored), config (the definition's portable part; the agent's name is config.name), processLocal (one { path, kind, description, details } entry per process-local part of a code agent; empty for a stored agent), isDefault, and isEditable, plus createdAt and updatedAt (stored agents), owner (code agents: runtime or the declaring harness capability), and metadata. The list returns full definitions, code agents first.

CreateAgentRequest requires agentId and config, with optional metadata. UpdateAgentRequest is a patch: omitted sections stay unchanged, metadata replaces the metadata, and clearMetadata: true clears it. Create and update validate the definition against the runtime's validation limits (WithDefinitionValidationLimits(...)) and against the runtime's composition. A refused definition returns a 400 validation problem whose errors are keyed by code, each message naming its definition path (for example 'toolHarnesses[0].name'):

KeyMeaning
agent_provider_unknownclients.{family}.provider.key names no provider of the composition
agent_provider_family_unsupportedThe provider does not implement the family
agent_harness_unknowntoolHarnesses[i].name is not the exact activation identity of a harness of the composition
agent_harness_function_unknowntoolHarnesses[i].functions[j] is not declared by the harness
agent_middleware_unknownmiddlewares[i].name names no middleware of the composition
agent_definition_process_localThe definition carries a process-local part (in-process only; such members do not deserialize)
configErrors without a code, such as shape errors and validation limits

Conflicts return 409 problems with a code extension:

codeWhen
agent_definition_read_onlyPOST, PATCH, or DELETE names a code agent's id
agent_definition_existsPOST names an id the agent store already has
agent_definition_changedThe stored agent changed between the read and the write of a PATCH

An updated stored agent takes effect on its next run.

Each AddHPDAgentRuntime(...) registration hosts one runtime with one agent store. Its code agents are the ones its recipe registers with AddAgent(...), and its default agent is one of them; the registration name is not an agent id. A runtime whose recipe registers no code agent lists only its stored agents and has no default agent. Code agents are never written to the agent store. Runtime requests resolve code and stored agents only and never synthesize, persist, or recreate one.

Composition ​

MethodRouteSuccessOperation id
GET/composition/providers200 List<ProviderDescriptorDto>ListCompositionProviders
GET/composition/harnesses200 List<ToolHarnessDescriptorDto>ListCompositionHarnesses
GET/composition/middleware200 List<MiddlewareDescriptorDto>ListCompositionMiddleware
GET/composition/events200 EventCatalogDtoGetCompositionEvents
GET/composition/inputs200 InputCatalogDtoGetCompositionInputs

Each route is the runtime.Composition read of the same name: what the runtime was built with. Reading it builds no agent and reads no storage. The routes carry the OpenAPI tag Composition.

DTOFields
ProviderDescriptorDtokey, displayName, aliases, families (enum names such as Chat), documentationUri, secretNames, models
ProviderModelDescriptorDtoid, displayName, modelFamily, contextWindow, maxInputTokens, maxOutputTokens, inputModalities, outputModalities, supportsReasoning, supportsToolCalls, supportsAttachments, releaseDate, status
ToolHarnessDescriptorDtoidentity (the exact activation identity a definition names), name, description, inheritedHarnessIdentities, functions (name, description, requiresApproval), configType
MiddlewareDescriptorDtoidentity, name, configType, keepsSessionState, keepsThreadState
EventCatalogDtoevents (discriminator, contractName, durability as an enum name such as Durable, moduleId, contractDigest) and digest
InputCatalogDtoinputs (discriminator, contractName, moduleId, isPublic) and digest

A provider's models is empty unless the runtime was built with a model catalog (WithProviderModelCatalog(...) or WithModelsDev(...)). The event and input catalogs are the runtime's own composition, so a runtime with its own event composition reports its own. Clients compare digest with the digest they were generated against before decoding events.

Content ​

MethodRouteBodySuccessCommon failures
POST/sessions/{sessionId}/threads/{threadId}/contentmultipart/form-data, field file201 ContentDto404, 400
GET/sessions/{sessionId}/threads/{threadId}/contentnone200 List<ContentDto>404, 400
GET/sessions/{sessionId}/threads/{threadId}/content/{contentId}nonebinary file404, 400
DELETE/sessions/{sessionId}/threads/{threadId}/content/{contentId}none204404, 400

Default hosted content storage is in-memory. Do not assume durability unless the recipe configures durable content storage, for example with WithFileSessionStore(...) or WithContentStore(...).

Streaming And Responses ​

MethodRouteBody or protocolSuccessCommon failures
POST/sessions/{sessionId}/threads/{threadId}/inputsStreamTextRequest or input event envelope, each with optional agentId202 InputSubmissionDto400, 404, 409 ThreadExecutionActive (work other than a message), 500
GET/sessions/{sessionId}/threads/{threadId}/statenone200 ThreadRuntimeStateDto404
GET/sessions/{sessionId}/threads/{threadId}/events?after={sequence}SSEcatch-up then live text/event-stream404 before headers, cursor conflict after headers
POST/sessions/{sessionId}/threads/{threadId}/context-usageContextUsageRequest200 ThreadContextUsage404, 400, 500
POST/sessions/{sessionId}/threads/{threadId}/responsesserialized AgentEvent envelope implementing IAgentResponseEvent200 AgentRespondResult404, 409, 400

ThreadRuntimeStateDto contains observedCursor, the backend-owned activeExecution, and durable answerable pendingRequests owned by that exact thread execution. It does not contain event history. Query a child thread directly for its pending requests. InputSubmissionDto contains a disposition, the targeted or assigned threadExecutionId, startedAt when an execution started, and result for input that completes within the request. Read /state for the thread's active execution.

SSE sends committed events after the requested applied cursor, catches up to the current head, and remains open for future commits. Every canonical frame has id: {ThreadSequenceNumber} as a plain integer, event: agent-event for catch-up or event: live-agent-event for live deliveries, and the exact serialized event in data:. The server accepts Last-Event-ID when after is absent; comment heartbeats keep quiet streams alive. HTTP clients post any serialized AgentEvent envelope implementing IAgentResponseEvent to the single /responses route. Ordinary response races are typed 200 results rather than HTTP conflicts.

/inputs is the only semantic-input mutation route. Every input gets the same checks: an input type reserved for the runtime returns 400 InternalInput, and a missing session, thread, or named agent returns 404. The input's agentId selects the answering agent on the hosted runtime: a code agent, a code-owned subagent, or a stored definition. An input that names no agent runs on the default agent; a runtime without one returns 400 AgentIdRequired. An unknown agentId returns 404. A UserMessagesInputEvent returns started with a newly assigned execution id, or steered with the running execution id when it joined the running turn. A message that names a threadExecutionId returns 400 ThreadExecutionIdNotAllowed. Other work returns started, or 409 ThreadExecutionActive on a busy thread. A client tool result returns accepted, or no_active_execution when its operation has already ended. Cancellation uses the dedicated execution cancel route. See Hosted Lifecycle And Recovery.

context-usage estimates the scoped thread's current input-token pressure against the supplied runConfig, including model context-window metadata when the client has it. It does not start a thread execution and does not compact history.

Multi-Agent Workflows ​

The multi-agent activation API is mapped separately with MapHPDMultiAgentApi(...). It currently exposes workflow discovery and durable run enqueue, not the same session/thread surface as a hosted chat agent:

MethodRouteBody or protocolSuccess
GET/multi-agent/workflowsnone200 MultiAgentWorkflowListResponse
POST/multi-agent/workflows/{workflowId}/runsMultiAgentRunRequest and Idempotency-Key headerdurable activation acceptance

See ASP.NET Multi-Agent Workflows for setup requirements and the current run-observation boundary.

Concurrency ​

Thread executions and thread operation locks are separate:

  • thread execution ownership allows one active execution per sessionId + threadId
  • thread operation locks protect exclusive thread mutations such as deletion
  • middleware responses require an active thread runtime but are not thread executions

Built for production .NET agent applications.