agui-dotnet-troubleshoot
AG-UI .NET — troubleshooting
Goal: map a symptom to its cause and fix in an AG-UI .NET app.
The agent forgets earlier turns / history is truncated
The server is stateless and keeps nothing between turns, so the client must resend the full history each turn. If you send only the latest message, the model loses all prior context.
Fix: keep a running List<ChatMessage>, append the assistant reply (history.AddMessages(updates.ToChatResponse())), and resend the whole list. For a server that holds the conversation, keep the thread id stable by reusing the same ChatOptions instance across turns.
update.ConversationId is always null
This is by design — the SDK never surfaces a service conversation id. A non-null ConversationId would make Microsoft.Extensions.AI wrappers send only deltas, which truncates history against a stateless server.
Fix: don't track conversations by ConversationId. Use the thread id from the RUN_STARTED event (update.RawRepresentation as RunStartedEvent), or just reuse the same ChatOptions to keep one stable thread.
State, reasoning, or lifecycle updates never arrive
These ride on content-less updates — update.RawRepresentation (a StateSnapshotEvent, RunStartedEvent, RawEvent, …) with no text. The non-streaming GetResponseAsync aggregation drops updates that carry no message content.