AGUIChatClient
AGUIChatClient is an IChatClient implementation for AG-UI. It converts
ChatMessage values and ChatOptions into a RunAgentInput, sends that input
to an AG-UI endpoint, and converts the returned event stream into
ChatResponseUpdate values.
The .NET client does not define an
AbstractAgent equivalent. The integration
point is Microsoft.Extensions.AI.IChatClient.Construction
Create a client from anAGUIChatClientOptions. The simplest form builds the
built-in HTTP transport from an HttpClient and the AG-UI endpoint URL:
AGUIChatClient has a single constructor that takes AGUIChatClientOptions:
AGUIChatClientOptions carries the transport and optional serializer settings:
Transport directly when you need a custom transport for tests or an
alternative wire protocol. See Transport.
Streaming responses
GetStreamingResponseAsync streams AG-UI output as MEAI
ChatResponseUpdate objects:
ChatResponseUpdate objects. Text events become text deltas, tool call events
become MEAI tool call content, and lifecycle events remain available through
RawRepresentation.
Non-streaming responses
GetResponseAsync is also implemented. It consumes the streaming response and
returns a final ChatResponse:
Statelessness and ConversationId
AGUIChatClient is stateless. It sends the full message history on every turn
and never surfaces a ConversationId on returned updates.
This is intentional. In Microsoft.Extensions.AI, a non-null ConversationId
signals a service-managed conversation. Agent wrappers may then send only the
new message deltas on the next turn. That would truncate history when talking to
a stateless AG-UI server.
Use these identifiers instead:
ChatResponseUpdate.ResponseIdis the AG-UI run id.update.RawRepresentation as RunStartedEventexposes the AG-UIThreadIdandRunIdfrom theRUN_STARTEDevent.update.AdditionalProperties["agui_thread_id"]also contains the resolved AG-UI thread id on theRUN_STARTEDupdate.
Thread continuity
To keep a stable AG-UI thread, reuse the sameChatOptions instance across
turns. The client pins the resolved thread id onto that options instance without
setting ConversationId.
For explicit continuation or branching, set RunAgentInput.ThreadId and
RunAgentInput.ParentRunId through ChatOptions.RawRepresentationFactory.
This is the AG-UI-native way to control wire-level fields:
Interrupts and approvals
When an AG-UI server finishes a run with an interrupt outcome, the client surfaces the pause as MEAI content:- Tool-call approvals become
ToolApprovalRequestContent. - Other interrupts become
InterruptRequestContent.
ToolApprovalResponseContent and InterruptResponseContent from the
latest message and sends them as RunAgentInput.Resume.
InterruptResponseContent: