Skip to main content

Transport

AGUI.Client separates the chat client from the wire protocol with IAGUITransport. AGUIChatClient builds a RunAgentInput, passes it to the transport, and consumes the resulting AG-UI BaseEvent stream.

IAGUITransport

IAGUITransport has a single method:
The input contains the AG-UI thread id, run id, message history, tools, state, context, forwarded properties, and any resume entries for interrupted runs. The output is the ordered AG-UI event stream described in the event reference.

HTTP transport

The AGUIChatClientOptions(HttpClient, endpoint) constructor creates the built-in HTTP transport internally:
The built-in transport sends the request as an HTTP POST whose body is the serialized RunAgentInput. The response is read as Server-Sent Events, and each SSE item is deserialized as a BaseEvent.
AGUIHttpTransport is the built-in HTTP+SSE implementation used by the AGUIChatClientOptions(HttpClient, endpoint) constructor. Most applications do not need to instantiate a transport directly.

Custom transports

Implement IAGUITransport when you want to test without a server or use a different transport. Then pass the implementation to AGUIChatClient.

Event conversion

The transport returns AG-UI protocol events. AGUIChatClient then converts them to ChatResponseUpdate values:
  • RUN_STARTED establishes the AG-UI thread id and run id.
  • Text message events become streamed text updates.
  • Tool call events become MEAI function call content.
  • Interrupt outcomes become ToolApprovalRequestContent or InterruptRequestContent.
  • RUN_ERROR becomes an ErrorContent update. Its message maps to ErrorContent.Message, and its optional code maps to ErrorContent.ErrorCode. When the event carries partial usage, the client also emits UsageContent updates so ChatResponse.Usage includes the tokens consumed before the failure.
ResponseId on each update corresponds to the AG-UI run id. The client clears ConversationId before yielding updates so callers continue sending full message history to stateless AG-UI servers.

Cancellation

SendAsync receives the caller’s CancellationToken. Custom transports should observe it while sending the request and while producing events: