lab / agent framework chat

Agent Framework: Conversational Chat

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

Contents

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:

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:

An unhandled error has occurred. Reload ๐Ÿ—™

Reconnecting… Still reconnecting… Connection lost Session paused Session expired

The connection to the server dropped. This usually only takes a moment.

No answer yet. Trying again in 0s.

Couldn't reach the server. Check your connection, then try again.

This tab sat idle, so the server set the session aside. Pick up where you left off.

The server no longer has this session. Reload the page to start fresh.