Agent Framework: Conversational Chat

The minimum code needed for multi-turn, streaming chat with the Agent Framework - no model picker, no chrome.

Table of Contents

How It Works

Try It

Conversation "state" here is nothing more than a growing List<(string role, string content)> kept in the component. Every send re-sends the whole history to the agent - there's no server-side thread or session involved.

How It Works

ChatService.ChatStreamAsync maps that tuple list onto ChatMessage objects and forwards it to AIAgent.RunStreamingAsync, yielding text deltas as they arrive:

Loading Monaco Editor...

The UI below appends each delta to a buffer, and once the stream ends, commits the buffer as a new ("assistant", ...) entry in the same list - so the next send includes it as history.

Try It

Need a model picker, reasoning-effort controls, token usage badges, and auto-scroll? See the full-featured Azure AI Chat Bot example - it's built on the exact same IChatService API used here.
References

For more detailed information and advanced scenarios, check out these helpful resources:

AIAgent.RunStreamingAsync

Streaming responses from an AIAgent, part of the Agent Framework overview.
An unhandled error has occurred. Reload 🗙