-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Description
Description
Create a .NET MAUI sample application that connects to an AG-UI server and demonstrates streaming AI agent conversations with a mobile/desktop-friendly UI.
Goals
- Port console AG-UI client to MAUI
- Implement SSE streaming in MAUI
- Create chat UI suitable for mobile/desktop
- Demonstrate server connection and authentication
Sample Features
UI
- Chat message list (conversation history)
- Text input for user messages
- Send button
- Streaming response indicator
- Connection status indicator
- Server configuration (URL, endpoint)
Functionality
// MAUI client using AG-UI
public class ChatViewModel : ObservableObject
{
private readonly AGUIChatClient _chatClient;
private readonly AIAgent _agent;
public ChatViewModel()
{
var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
_chatClient = new AGUIChatClient(httpClient, ServerUrl);
_agent = _chatClient.CreateAIAgent(
name: "maui-client",
description: "AG-UI MAUI Client");
}
public async Task SendMessageAsync(string message)
{
_messages.Add(new ChatMessage(ChatRole.User, message));
// Stream response
await foreach (var update in _agent.RunStreamingAsync(_messages, _thread))
{
var chatUpdate = update.AsChatResponseUpdate();
foreach (var content in update.Contents)
{
if (content is TextContent textContent)
{
// Update UI with streaming text
CurrentResponse += textContent.Text;
}
}
}
}
}Server Integration
- Connects to existing AG-UI ASP.NET server
- Supports server configuration (URL)
- Handles connection errors gracefully
- Maintains conversation thread
Technical Notes
- Use
HttpClientwith extended timeout for SSE - Handle SSE streaming on UI thread appropriately
- Consider using
ObservableCollectionfor message history - Test network error scenarios (server down, timeout)
- Reference existing console sample for protocol details
Server Setup Reference
Sample uses standard AG-UI server from Microsoft Learn docs:
- Endpoint:
http://localhost:8888(configurable) - Requires Azure OpenAI endpoint and deployment
- Uses
DefaultAzureCredentialfor auth
Notes
- Focus on clean, mobile-friendly UI
- Demonstrate MAUI-specific patterns (MVVM, data binding)
- Keep server setup documented but reference official docs
- Consider offline/error states in UI