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:
- AIAgent.RunStreamingAsyncStreaming responses from an AIAgent, part of the Agent Framework overview.